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.
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 pixel 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 markerimage a 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:
-
Automatic using 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 all close allBasic Examples (2)
Scope (11)
Data (3)
A single pixel value of a grayscale image:
PixelValue[Image[(| | |
| -- | -- |
| 0 | .2 |
| .4 | 1 |)], {1, 1}]A single pixel value of a color image:
PixelValue[[image], {1, 1}]A single pixel value of a 3D image:
PixelValue[[image], {3, 1, 3}]Position (5)
A single pixel value of a grayscale image:
PixelValue[[image], {10, 10}]Specify a noninteger position:
PixelValue[[image], {9.9, 10.4}]PixelValue[[image], {{10, 10}, {20, 20}, {30, 30}}]Pixel values at a range of positions:
PixelValue[[image], {10 ;; 20, 1 ;; 2}]Use All to extract all pixels in one dimension:
PixelValue[[image], {41, All}]Pixel values at positions specified by a marker image:
PixelValue[[image], [image]]Type (3)
By default, pixel values are returned in "Real" type:
PixelValue[[image], {50, 50}]PixelValue[[image], {50, 50}, "Byte"]Use Automatic to return values in the original image data type:
PixelValue[[image], {50, 50}, Automatic]Options (1)
Applications (4)
Compute mean pixel value of a region of interest:
PixelValue[[image], [image]]//MeanRGBColor@%Pixel values on a path defined in a marker image:
PixelValue[[image], [image]]Plot the distribution of pixel values in a region of interest:
Histogram[PixelValue[[image], [image]], {0, 1, 0.1}]Extract image pixel values where corners are detected:
i = [image];corners = ImageCorners[i, 4, 0.001, 3, MaxFeatureDisplacement -> 7]HighlightImage[i, {PointSize[Large], corners}]PixelValue[i, corners]Properties & Relations (2)
Use ImageData to extract pixel values. Value of the bottom-left pixel:
PixelValue[[image], {1, 1}]ImageData[[image], DataReversed -> True][[1, 1]]PixelValue[[image], {All, 1}]ImageData[[image], DataReversed -> True][[1]]Extract pixel values using ImageValue and special settings of Resampling and DataRange:
PixelValue[[image], Table[{i, i}, {i, 3}]]ImageValue[[image], Table[{i, i}, {i, .75, 3, 1}], Resampling -> "Nearest", DataRange -> {{.5, 3.5}, {.5, 3.5}}]Possible Issues (2)
When coordinates lie on a boundary between pixels, the average of surrounding pixel values is returned:
PixelValue[[image], {1.5, 1.5}]When converting to "Bit" type, pixel values will get rounded:
PixelValue[[image], {2, 2}]PixelValue[[image], {2, 2}, "Bit"]Related Guides
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_2026_pixelvalue, author="Wolfram Research", title="{PixelValue}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/PixelValue.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_pixelvalue, organization={Wolfram Research}, title={PixelValue}, year={2014}, url={https://reference.wolfram.com/language/ref/PixelValue.html}, note=[Accessed: 13-June-2026]}