PixelValue

PixelValue[image,ppos]

gives the pixel value of image at position pos.

PixelValue[image,ppos,"type"]

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
    {xmin;;xmax;;xstep,}span of positions with steps
    {pos1,pos2,}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.

Examples

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:

Wolfram Research (2010), PixelValue, Wolfram Language function, https://reference.wolfram.com/language/ref/PixelValue.html (updated 2014).

Text

Wolfram Research (2010), PixelValue, Wolfram Language function, https://reference.wolfram.com/language/ref/PixelValue.html (updated 2014).

CMS

Wolfram Language. 2010. "PixelValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/PixelValue.html.

APA

Wolfram Language. (2010). PixelValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PixelValue.html

BibTeX

@misc{reference.wolfram_2023_pixelvalue, author="Wolfram Research", title="{PixelValue}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/PixelValue.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_pixelvalue, organization={Wolfram Research}, title={PixelValue}, year={2014}, url={https://reference.wolfram.com/language/ref/PixelValue.html}, note=[Accessed: 19-March-2024 ]}