ReplacePixelValue

ReplacePixelValue[image,pposval]
changes the pixel values at pixel position ppos in image to val.

ReplacePixelValue[image,pposval,"type"]
assumes val to be of the specified type.

DetailsDetails

  • Pixel positions ppos can be in one of the following forms:
  • {x,y}or {x,y,z}single position in 2D or 3D
    {xmin;;xmax,}span of positions
    {ppos1,ppos2,}a list of position specification
    markerimagea marker image
  • In ReplacePixelValue[image,{xp,yp}->val], the pixel position with assumed to be in the standard image coordinate system, where the values of x range from to width and y from to height.
  • In ReplacePixelValue, integer coordinates correspond to the centers of the pixels. In 2D, pixel position represents the center of the bottom-left pixel. In 3D, pixel position corresponds to the center of the bottom-left front pixel.
  • The pixel value val can be a scalar, a list of channel values, or a color.
  • ReplacePixelValue[image,{ppos1->val1,}] can be used to set pixel values for multiple positions.
  • When the pixel position ppos lies on a boundary between pixels, all adjacent pixels are modified.
  • ReplacePixelValue typically gives an image that has the same type as image.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Set a pixel in an image:

In[1]:=
Click for copyable input
Out[1]=

Unset a pixel to separate connected components:

In[1]:=
Click for copyable input
Out[1]=

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

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2012
(9.0)
| Updated in 2014
(10.0)