({{, (RefLink[SetAlphaChannel, paclet:ref/SetAlphaChannel])[image]
adds a fully opaque alpha channel to image.}, {, (RefLink[SetAlphaChannel, paclet:ref/SetAlphaChannel])[image,a]
sets the opacity of all pixels to a.}, {, (RefLink[SetAlphaChannel, paclet:ref/SetAlphaChannel])[image,aimage]
sets the alpha channel of image to aimage.}})

OpenersNotesSection(Spacer1)Details

(RefLink[SetAlphaChannel, paclet:ref/SetAlphaChannel])[image] is equivalent to (RefLink[SetAlphaChannel, paclet:ref/SetAlphaChannel])[image,1].

(RefLink[SetAlphaChannel, paclet:ref/SetAlphaChannel])[image,…] ignores opacity properties of image.

(RefLink[SetAlphaChannel, paclet:ref/SetAlphaChannel])[image,graphics] uses an arbitrary Wolfram Language graphics object as the alpha channel.

(RefLink[SetAlphaChannel, paclet:ref/SetAlphaChannel]) works with images of explicit color spaces—that is, any setting of the (RefLink[ColorSpace, paclet:ref/ColorSpace]) option other than (RefLink[Automatic, paclet:ref/Automatic]).

(RefLink[SetAlphaChannel, paclet:ref/SetAlphaChannel]) works with (RefLink[Image3D, paclet:ref/Image3D]) objects.

OpenersPrimaryExamplesSection(Spacer1)Examples  (10)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Set the pixel opacities in an image:

SetAlphaChannel[,]

Specify the alpha channel using a graphics object:

SetAlphaChannel[,Graphics[{Gray,Disk[]}]]

OpenersExampleSection1(Spacer1)Scope  (2)

Add a constant white alpha channel to an RGB image:

SetAlphaChannel[]

ImageChannels[%]

Add a constant alpha channel to a color image:

SetAlphaChannel[,.8]

OpenersExampleSection3(Spacer1)Applications  (4)

Segment the background to be used as an alpha channel:

i=;
bg=Binarize[i,.05]

Set the alpha channel to a detected background:

SetAlphaChannel[i,bg]

Use an alpha channel to mask regions of an image:

i=;

SetAlphaChannel[i,ChanVeseBinarize[i,"TargetColor"->Blue]]

Use an alpha channel to highlight a region of interest:

i = ;

Find individual cells that do not touch the border and have only one hole:

foreground=FillingTransform@SelectComponents[DeleteBorderComponents[Binarize[i,{0,.8}]],"Holes",#==1&]

Highlight the detected foreground while keeping the background half transparent:

SetAlphaChannel[i,ImageAdd[Image[foreground,"Real"],.5]]

Set the alpha channel of an RGB image to be the negative of its blue channel:

i=;

SetAlphaChannel[i,ColorNegate[Last[ColorSeparate[i]]]]

OpenersExampleSection4(Spacer1)Properties & Relations  (1)

Color images are converted to grayscale when used as an alpha channel:

SetAlphaChannel[,]

SetAlphaChannel[,]

OpenersExampleSection5(Spacer1)Interactive Examples  (1)

Use an alpha channel to focus on a region of interest in an image:

DynamicModule[{pt={61,61}},
LocatorPane[Dynamic[pt],
Dynamic@SetAlphaChannel[,Image[Graphics[{GrayLevel[1],Rectangle[Floor[pt-30],Floor[pt]+30]},PlotRange->{{1,120},{1,120}},Background->GrayLevel[0.3]],ImageSize->{120,120}]],{{30,30},{90,90}}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[RemoveAlphaChannel, paclet:ref/RemoveAlphaChannel])  ▪  (RefLink[AlphaChannel, paclet:ref/AlphaChannel])  ▪  (RefLink[ColorCombine, paclet:ref/ColorCombine])  ▪  (RefLink[ColorSeparate, paclet:ref/ColorSeparate])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Basic Image Manipulation, paclet:guide/BasicImageManipulation])}, {▪(RefLinkPlain[Image Processing & Analysis, paclet:guide/ImageProcessing])}, {▪(RefLinkPlain[Color Processing, paclet:guide/ColorProcessing])}})}})