ImageData

ImageData[image]
gives the array of pixel values in an Image or Image3D object image.

ImageData[image,"type"]
gives the array of pixel values converted to the specified type.

Details and OptionsDetails and Options

  • ImageData[image] by default gives a 2D or 3D array whose elements are lists of values for each channel. For a single-channel image, only a value and not a list of values is returned.
  • In 2D, the array generated by ImageData[image] is arranged in the same way that the image is displayed, with the first row corresponding to the top row of pixels in the image.
  • In 3D, the array generated by ImageData[image] is arranged such that the first part corresponds to the top slice, with rows running from back to front, and columns running from left to right.
  • For binary images, ImageData[image] returns integer values 0 or 1. For images of type or , ImageData[image] always normalizes values to lie between 0 and 1. For images of a real type, ImageData[image] returns whatever real values are used in the image.
  • Possible types specified by ImageData[image,"type"] are:
  • "Bit"integer 0 or 1
    "Byte"integer 0 through 255
    "Bit16"integer 0 through 65535
    "Real32"single-precision real (32-bit)
    "Real"double-precision real (64-bit)
  • ImageData[image,Automatic] is equivalent to ImageData[image,ImageType[image]].
  • ImageData has the option Interleaving.
  • With the default setting Interleaving->True, ImageData returns a 2D or 3D array of lists of channel values.
  • With Interleaving->False, ImageData returns a list of 2D or 3D arrays of values for each channel.
  • Interleaving->Automatic returns in the native form used to store the image.
  • ImageData accepts a DataReversed option. With DataReversed->True, the order of the rows is reversed.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Channel data for the first five pixels of the first row:

In[1]:=
Click for copyable input
Out[1]=

Construct a byte-valued image:

In[1]:=
Click for copyable input
Out[1]=

Extract normalized raster data:

In[2]:=
Click for copyable input
Out[2]=

Extract raw bytes:

In[3]:=
Click for copyable input
Out[3]=

Extract data from a 3D image:

In[1]:=
Click for copyable input
Out[1]//MatrixForm=
Introduced in 2008
(7.0)
| Updated in 2012
(9.0)