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 allclose allScope (11)
Data (3)
Position (5)
A single pixel value of a grayscale image:
Specify a noninteger position:
Pixel values at a range of positions:
Use All to extract all pixels in one dimension:
Type (3)
By default, pixel values are returned in "Real" type:
Use Automatic to return values in the original image data type:
Options (1)
Applications (4)
Properties & Relations (2)
Use ImageData to extract pixel values. Value of the bottom-left pixel:
Extract pixel values using ImageValue and special settings of Resampling and DataRange:
Possible Issues (2)
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