ImageValue
ImageValue[image,pos]
gives the interpolated value of image at position pos.
ImageValue[image,pos,"type"]
gives the value converted to the specified type.
Details and Options
- ImageValue is used to extract interpolated values of a 2D or 3D image and is typically used for sampling the image.
- Pixel 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 {xmin;;xmax;;xstep,…} span of positions with steps {pos1,pos2,…} a list of position specifications markerimage a marker image - ImageValue assumes the standard image coordinate system.
- Use PixelValue to use integer indices for extracting exact pixel values of the image.
- ImageValue[image,pos] by default returns values between 0 and 1.
- ImageValue[image,pos,"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) - The following options can be given:
-
DataRange Full range of image coordinates Padding 0 padding method to use Resampling "Linear" interpolation method to use - Possible settings for DataRange 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,1},{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 - With Resampling->"Nearest", when the position pos lies on a boundary between pixels, the average of the pixels surrounding pos is returned. »
Examples
open allclose allScope (12)
Data (4)
A single value of a grayscale image:
ImageValue typically returns interpolated values:
Position (5)
Image values at a range of positions:
Use All to extract all values in one dimension:
Type (3)
By default, image values are returned in "Real" type:
Use Automatic to return values in the original image data type:
Options (3)
DataRange (1)
Applications (4)
Possible Issues (3)
With Resampling->"Nearest" and integer coordinates, the average of the pixels surrounding the specified coordinate is returned:
When converting to "Bit" type, pixel values will get rounded:
Extracting value at multiple positions is much faster if done at once rather than extracting one at a time:
Text
Wolfram Research (2010), ImageValue, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageValue.html (updated 2014).
CMS
Wolfram Language. 2010. "ImageValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/ImageValue.html.
APA
Wolfram Language. (2010). ImageValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageValue.html