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
    {ppos1,ppos2,}a list of position specifications
    markerimagea 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:
  • 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)
  • The following options can be given:
  • DataRangeFullrange of image coordinates
    Padding0padding 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 all

Basic Examples  (2)

Image value in a color image:

Image value in "Byte" type:

Scope  (12)

Data  (4)

A single value of a grayscale image:

ImageValue typically returns interpolated values:

A single value of a color image:

A single value of a 3D image:

Position  (5)

A single value of an image:

Multiple values:

Image values at a range of positions:

Use All to extract all values in one dimension:

Image values at positions specified by a marker image:

Type  (3)

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

Specify a different type:

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

Options  (3)

DataRange  (1)

By default, image value assumes a data range of {{0,width},{0,height}}:

Pixel value at the center of an image using a normalized data range:

Padding  (1)

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

Specify a padding scheme:

Resampling  (1)

By default, the linear resampling is used:

Specify a different resampling:

Use the nearest value to avoid resampling:

Applications  (4)

Compute mean image value of a region of interest:

Image values along a path defined in a marker image:

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

Extract image values where corners are detected:

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:

Interactive Examples  (1)

Profile of a single image row:

Introduced in 2010
 (8.0)
 |
Updated in 2012
 (9.0)
2014
 (10.0)