({{, (RefLink[ImageCompose, paclet:ref/ImageCompose])[image,overlay]
gives the result of overlaying overlay onto image. }, {, (RefLink[ImageCompose, paclet:ref/ImageCompose])[image,{overlay,α}]
gives the result of alpha blending overlay into image using blending fraction α.}, {, (RefLink[ImageCompose, paclet:ref/ImageCompose])[image,overlay,pos]
places the center of overlay at position pos in image.}, {, (RefLink[ImageCompose, paclet:ref/ImageCompose])[image,overlay,pos,opos]
places the point opos in overlay at position pos in image.}, {, (RefLink[ImageCompose, paclet:ref/ImageCompose])[image,overlay,pos,opos,{(Subscript[f, i]),(Subscript[f, o]),mode}]
uses the compositing fractions (Subscript[f, k]) and the specified compositing mode.}})

OpenersNotesSection(Spacer1)Details

(RefLink[ImageCompose, paclet:ref/ImageCompose])[image,…] always gives an image with the same pixel size as image.

(RefLink[ImageCompose, paclet:ref/ImageCompose])[image,overlay] composes overlay pixel-by-pixel onto image, without changing the size of overlay.

The overlay can be either an explicit image object or a graphics object that is automatically rasterized to have the same image size as image.

(RefLink[ImageCompose, paclet:ref/ImageCompose])[image,overlay] does alpha blending if overlay has an alpha channel.

(RefLink[ImageCompose, paclet:ref/ImageCompose])[image,{overlay,α}] effectively sets the alpha value for overlay to α, or multiplies an existing alpha channel by α.

(RefLink[ImageCompose, paclet:ref/ImageCompose])[image,overlay] centers overlay in image.

The position pos in image or the position opos in overlay can be specified in the following ways:

Possible named positions include (RefLink[Top, paclet:ref/Top]), (RefLink[Bottom, paclet:ref/Bottom]), (RefLink[Left, paclet:ref/Left]), (RefLink[Right, paclet:ref/Right]), (RefLink[Center, paclet:ref/Center]).

If only one of (Subscript[pos, x]) and (Subscript[pos, y]) is given, the other is assumed to be (RefLink[Center, paclet:ref/Center]).

The pixel offsets {x,y} can be negative, indicating a point outside of image or overlay.

(RefLink[ImageCompose, paclet:ref/ImageCompose])[image,…] yields an image with an alpha channel only if image has an alpha channel.

(RefLink[ImageCompose, paclet:ref/ImageCompose])[{image,(Subscript[α, i])},…] effectively adds an alpha channel with value (Subscript[α, i]) to image.

(RefLink[ImageCompose, paclet:ref/ImageCompose])[…,{(Subscript[f, i]),(Subscript[f, o]),mode}] combines a fraction (Subscript[f, i]) of every pixel value in image with a fraction (Subscript[f, o]) of every pixel value in overlay, in all cases taking account of alpha channels.

With value 1 for mode, overlay is treated as on top of image. With value -1 it is treated as underneath. And with value 0, image and overlay are treated symmetrically.

The following choices of {(Subscript[f, i]),(Subscript[f, o]),mode} correspond to standard Duff–Porter compositing operators:

The "over" operators given by {1,1,1} and {1,1,-1} effectively perform alpha blending.

The "in" operators given by {0,0,1} and {0,0,-1} mask one image with the alpha channel of the other image.

The "out" operators {0,1,0} and {1,0,0} mask one image with the complement of the alpha channel of the other image.

The "atop" operators given by {0,1,1} and {1,0,-1} effectively combine the alpha channels of the two images before performing alpha blending.

(RefLink[ImageCompose, paclet:ref/ImageCompose])[image,{(Subscript[o, 1]),(Subscript[o, 2]),…}] composes multiple images onto image.

Using (RefLink[ImageCompose, paclet:ref/ImageCompose])[image,{{(Subscript[o, 1]),(Subscript[α, 1])},…}], different alpha values can be set for different overlays.

Corresponding lists of positions, overlay positions, and compositing fractions and modes can also be specified when composing with multiple overlays.

OpenersPrimaryExamplesSection(Spacer1)Examples  (12)

OpenersExampleSection0(Spacer1)Basic Examples  (5)

Overlay images that are partially transparent:

ImageCompose[, ]

Specify a scaled position for the center of the overlay:

ImageCompose[, ,Scaled[{.5,.9}]]

Specify an explicit position for the overlay:

ImageCompose[, ,{Center,Top},{Center,Top}]

Specify an alpha-blending parameter:

ImageCompose[, {Graphics[{Yellow,Disk[]}], 0.5}]

Overlay two partially transparent images:

ImageCompose[,]

OpenersExampleSection1(Spacer1)Scope  (1)

Overlay multiple images on a background image:

ImageCompose[,{,},{Center,Scaled[{.5,.9}]}]

OpenersExampleSection3(Spacer1)Applications  (5)

Create a motion blur effect:

Nest[ ImageCompose[#,{#,0.9}, {-1,0},{0,0}]&, , 50]

Visual watermarking of an image:

img=;{w,h}=ImageDimensions[img];
ImageCompose[img,{,.3},Flatten[Table[{x,y},{x,-50,w,60},{y,10,h,30}],1]]

Emphasize differences by using an overlay with false coloring:

ImageCompose[ImageMultiply[,Magenta],{ImageMultiply[,Green],.5}]

Overlay a legend on a plot:

ImageCompose[Plot[{Sin[x],Cos[x]},{x,-π,π},ImageSize->250],Rasterize[LineLegend[{ColorData[97][1],ColorData[97][2]},{"sine","cosine"}]],{Left,Top},{Left,Top}]

Overlay the same image at circular positions:

ImageCompose[Image[ConstantArray[1,{300,300}]],{,.05},150+Table[40{Sin[i],Cos[i]},{i,0,2 Pi, Pi/12}],{Center,Center}]

OpenersExampleSection4(Spacer1)Interactive Examples  (1)

Explore the full range of alpha-compositing modes and parameters:

Manipulate[Row[ {ImageCompose[ ,,Center,Center,{fob,fim,mode}],{Round[fob],Round[fim],mode} /. { {1,0,1}-> "object",{0,1,-1}-> "image", {1, 1,1}->"object over image",  {1,1,-1}-> "image over object", {0,0,1}-> "object in image", {0,0,-1}-> "image in object",{1,0,0}-> "object out image",{0,1,0}-> "image out object",{0,1,1}-> "object atop image",{1,0,-1}-> "image atop object",{0,0,0}-> "clear",{1,1,0}-> "object xor image",  _-> "" }}],{{mode,1},{1->"object",-1->"image", 0-> "none"}}, {{fob,1},0,1},{{fim,1},0,1}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Blend, paclet:ref/Blend])  ▪  (RefLink[HighlightImage, paclet:ref/HighlightImage])  ▪  (RefLink[ImageExposureCombine, paclet:ref/ImageExposureCombine])  ▪  (RefLink[ImageCollage, paclet:ref/ImageCollage])  ▪  (RefLink[ImageAssemble, paclet:ref/ImageAssemble])  ▪  (RefLink[ImageAdd, paclet:ref/ImageAdd])  ▪  (RefLink[ImageMultiply, paclet:ref/ImageMultiply])  ▪  (RefLink[Show, paclet:ref/Show])  ▪  (RefLink[Inset, paclet:ref/Inset])  ▪  (RefLink[Opacity, paclet:ref/Opacity])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Basic Image Manipulation, paclet:guide/BasicImageManipulation])}, {▪(RefLinkPlain[Image Composition, paclet:guide/ImageComposition])}, {▪(RefLinkPlain[Image Processing & Analysis, paclet:guide/ImageProcessing])}, {▪(RefLinkPlain[Computational Photography, paclet:guide/ComputationalPhotography])}})}})