gives the pixel value of image at position pos.


gives the pixel value converted to the specified type.

Details and Options

  • PixelValue is used to extract interpolated values of a 2D or 3D image and is typically used for sampling the image.
  • 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 specifications
    markerimagea marker image
  • PixelValue assumes a pixel-aligned coordinate system that is shifted by 0.5 to the left and down with respect to the standard image coordinate system.
  • In PixelValue, 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.
  • PixelValue gives the value of the pixel nearest to {xp,yp}, except that when the position {xp,yp} lies on a boundary between pixels, the average of the pixels surrounding {xp,yp} is returned.
  • Use ImageValue to extract interpolated values at {x,y} in the standard image coordinate system.
  • With PixelValue[image,marker], nonzero pixels of the image marker are used as the list of positions.
  • PixelValue[image,ppos] by default returns values between 0 and 1.
  • Using PixelValue[image,ppos,"type"] returns a pixel value in the range specified by "type". Possible settings for "type" include:
  • Automaticusing data type of image
    "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)
  • PixelValue can take a Padding option that is used when a specified position is beyond an image.


open allclose all

Basic Examples  (2)

Value of the bottom-left corner pixel:

Pixel value in "Byte" type:

Scope  (11)

Data  (3)

A single pixel value of a grayscale image:

A single pixel value of a color image:

A single pixel value of a 3D image:

Position  (5)

A single pixel value of a grayscale image:

Specify a noninteger position:

Multiple pixel values:

Pixel values at a range of positions:

Use All to extract all pixels in one dimension:

Pixel values at positions specified by a marker image:

Type  (3)

By default, pixel values are returned in "Real" type:

Specify a different type:

Use Automatic to return values in the original image data type:

Options  (1)

Padding  (1)

By default, pixels outside of an image are assumed to be zero:

Specify a padding scheme:

Applications  (4)

Compute mean pixel value of a region of interest:

Pixel values on a path defined in a marker image:

Plot the distribution of pixel values in a region of interest:

Extract image pixel values where corners are detected:

Properties & Relations  (2)

Use ImageData to extract pixel values. Value of the bottom-left pixel:

Bottom row of the image:

Extract pixel values using ImageValue and special settings of Resampling and DataRange:

Possible Issues  (2)

When coordinates lie on a boundary between pixels, the average of surrounding pixel values is returned:

When converting to "Bit" type, pixel values will get rounded:

Interactive Examples  (1)

Profile of a single image row:

Introduced in 2010
Updated in 2014