({{, (RefLink[ReplaceImageValue, paclet:ref/ReplaceImageValue])[image,pos->val]
changes the pixel values at position pos in image to val.}, {, (RefLink[ReplaceImageValue, paclet:ref/ReplaceImageValue])[image,pos->val,"type"]
assumes val to be of the specified type.}})

OpenersNotesSection(Spacer1)Details and Options

Pixel positions pos can be in one of the following forms:

(RefLink[ReplaceImageValue, paclet:ref/ReplaceImageValue]) by default assumes the standard image coordinate system.

Other coordinate systems can be specified by setting the (RefLink[DataRange, paclet:ref/DataRange]) option. Typical settings include:

Use (RefLink[ReplacePixelValue, paclet:ref/ReplacePixelValue]) to specify exact pixel positions with integer indices.

The pixel value val can be a scalar, a list of channel values, or a color.

(RefLink[ReplaceImageValue, paclet:ref/ReplaceImageValue])[image,{(Subscript[pos, 1])->(Subscript[val, 1]),…}] can be used to set pixel values for multiple positions.

When a position pos lies on a boundary between pixels, all adjacent pixels are modified.

(RefLink[ReplaceImageValue, paclet:ref/ReplaceImageValue]) typically gives an image that has the same type as image.

OpenersPrimaryExamplesSection(Spacer1)Examples  (17)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Set a pixel in the center of the eye to white:

ReplaceImageValue[,{105.5,50.5}->White]

Set a list of pixels to black:

ReplaceImageValue[,{{10.5,16.5},{11.5,17.5},{10.5,14.5},{11.5,13.5},{28.5,16.5},{27.5,17.5},{28.5,14.5},{27.5,13.5},{8.5,6.5},{7.5,7.5},{8.5,4.5},{7.5,3.5},{30.5,6.5},{31.5,7.5},{30.5,4.5},{31.5,3.5}}->0]

Set a list of pixels to a list of colors:

ReplaceImageValue[,Table[{i,11-i}-1/2->Hue[(i-1)/10] ,{i,10}]]

Set a pixel in the top-left front corner of a 3D image to gray:

ReplaceImageValue[,{0.5,0.5,2.5}->Gray]

OpenersExampleSection1(Spacer1)Scope  (7)

Replace a single image value:

ReplaceImageValue[,{0.5,0.5}->Yellow]

Specify the data type of the replacement value:

ReplaceImageValue[,{1.5,0.5}->{220,220,220},"Byte"]

Specify list of replacement rules:

ReplaceImageValue[,{{0.5,0.5}->Yellow, {1.5,0.5}->Brown}]

Replace multiple image values:

ReplaceImageValue[,{{0.5,0.5},{1.5,0.5}}->Cyan]

Use (RefLink[Span, paclet:ref/Span]) to replace multiple image values:

ReplaceImageValue[,{0.5;;1.5,0.5}->Cyan]

Replace all values in a row:

ReplaceImageValue[,{All,3.5}->0]

Use a marker image to replace image values:

ReplaceImageValue[,->Red]

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)DataRange  (1)

Replace pixels sampled on an ellipse using a normalized data range:

ReplaceImageValue[,Table[{Cos[α],Sin[α]},{α,0.,2*π,π/50}]->Red,DataRange->{{-1,1},{-1,1}}]

OpenersExampleSection3(Spacer1)Applications  (1)

Copy random pixels between images:

pos=RandomReal[{0,1},{5000,2}];
ReplaceImageValue[,Thread[pos->ImageValue[,pos, DataRange->{{0,1},{0,1}}]], DataRange->{{0,1},{0,1}}]

OpenersExampleSection4(Spacer1)Properties & Relations  (3)

Pixels are set in the given order:

ReplaceImageValue[,{{0.5,0.5}->Red,{1.5,0.5}->Red,{1.5,0.5}->Black}]

When coordinates correspond to a boundary between pixels, all surrounding pixels are replaced:

ReplaceImageValue[,{{1.2,1.7}->Red,{0,5}->Green,{3,4}->Blue,{7,0}->Orange,{8,7.8}->Pink ,{3,6.5}-> Purple,{6.5,4}->Cyan}]

Read set pixels using (RefLink[ImageValue, paclet:ref/ImageValue]) with "Nearest" resampling and "Fixed" padding:

img=RandomImage[1,{100,200}];
pos={{0,0},{100,0},{100,200},{0,200},{50,100},{12.5,12.5}};
val=RandomReal[1,Length[pos]];
ImageValue[ReplaceImageValue[img,Thread[pos->val]],pos,Resampling->"Nearest",Padding->"Fixed"]===val

OpenersExampleSection5(Spacer1)Possible Issues  (1)

(RefLink[ReplaceImageValue, paclet:ref/ReplaceImageValue]) only affects pixels inside the image:

ReplaceImageValue[,{10,10}->Red]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ImageValue, paclet:ref/ImageValue])  ▪  (RefLink[ImageValuePositions, paclet:ref/ImageValuePositions])  ▪  (RefLink[Image, paclet:ref/Image])  ▪  (RefLink[ImageData, paclet:ref/ImageData])  ▪  (RefLink[ReplacePixelValue, paclet:ref/ReplacePixelValue])  ▪  (RefLink[ColorReplace, paclet:ref/ColorReplace])  ▪  (RefLink[ReplacePart, paclet:ref/ReplacePart])  ▪  (RefLink[SparseArray, paclet:ref/SparseArray])}})}})

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