This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

ImageData

ImageData[image]
gives the array of pixel values in image.
ImageData
gives the array of pixel values converted to the specified type.
  • ImageData[image] by default gives a 2D array whose elements are lists of values for each channel.
  • 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.
  • For binary images, ImageData[image] returns integer values 0 or 1. For all other images, ImageData[image] returns real values, normally between 0 and 1.
"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)
  • For images of type or , ImageData[image] always normalizes values to lie between 0 and 1. For images of type , ImageData[image] returns whatever real values are used in the image.
Channel data for the first five pixels of the first row:
Construct a byte-valued image:
Extract normalized raster data:
Extract raw bytes:
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]=
By default, data is returned from the top to the bottom:
Reverse the order of rows:
Data of multichannel images is by default returned in interleaved form:
This gives the pixel data in planar form:
Retrieve the image data in interleaved form:
Retrieve the image data in planar form:
ImageData and Raster assume a different ordering of the rows:
To visualize image data using Raster, the rows need to be reversed:
New in 7 | Last modified in 8