ReplaceImageValue

ReplaceImageValue[image,posval]

changes the pixel values at position pos in image to val.

ReplaceImageValue[image,posval,"type"]

assumes val to be of the specified type.

Details and Options

  • ReplaceImageValue is typically used for image correction or annotation of 2D and 3D images by replacing image values at selected positions.
  • ReplaceImageValue by default assumes position pos to be in the standard image coordinate system.
  • Positions pos 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
    {pos1,pos2,}a list of position specifications
    markerimagea marker image
  • ReplaceImageValue[image,{pos1->val1,}] 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.
  • Use ReplacePixelValue to specify exact pixel positions with integer indices.
  • Image value val can be in one of the following forms:
  • sa scalar
    colora color
    {s1,s2,}a list of channel values
  • Possible settings for "type" include:
  • "Bit"integer 0 or 1
    "Byte"integer 0 through 255
    "Bit16"integer 0 through 65535
    "Real32"single-precision real (32 bit)
    "Real64"double-precision real (64 bit)
  • Other coordinate systems can be specified by setting the DataRange option. Typical settings include:
  • Automatic{{0,1},{0,h/w}} in 2D, {{0,1},{0,d/w},{0,h/w}} in 3D
    Full{{0,w},{0,h}} in 2D, {{0,w},{0,d},{0,h}} in 3D (default)
    {{left,right},{bottom,top}}explicit coordinate ranges in 2D
    {{left,right},{front,back},{bottom,top}}explicit coordinate ranges in 3D
  • ReplaceImageValue typically gives an image that has the same type as image.

Examples

open allclose all

Basic Examples  (3)

Set a pixel to white:

Replace a list of pixels in an image:

Specify the data type of the replacement value:

Scope  (15)

Data  (4)

Replace a value in a grayscale image:

Replace a value in a color image:

Replace a value in a grayscale 3D image:

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

Position  (6)

Replace a single image value:

Replace image values at multiple positions:

Replace multiple image values:

Use Span to replace multiple image values:

Replace all values in a row:

Use a marker image to replace image values:

Value  (3)

Replace a single image value:

Replace a single image value with a given color:

Specify the value as a color triplet:

Include an opacity value:

Replace a monochrome pixel with a color value:

Type  (2)

Replace a single image value:

Specify the data type of the replacement value:

Options  (5)

DataRange  (5)

Replace image values sampled on a circle using a normalized data range:

Use the default data range:

Replace values sampled on a circle in an image with a non-unity aspect ratio using the default data range:

Use an explicit data range:

Use the Full data range:

Applications  (1)

Copy random pixels between images:

Properties & Relations  (5)

ReplaceImageValue only affects pixels inside the image:

Any position within the bounds of a pixel may be used:

Image values are set in the given order:

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

Read set pixels using ImageValue with "Nearest" resampling and "Fixed" padding:

Introduced in 2012
 (9.0)
 |
Updated in 2014
 (10.0)