Mathematica 9 is now available

Structure of ImageData

The color image data structure is encapsulated in an ImageData Mathematica expression. ImageData is a graphics primitive that facilitates the easy manipulation and handling of single and multi-channel images. This reads in a small example image in RGB color format.

[Graphics:Images/Jankowski_ImageProcessing_gr_21.gif]

ImageData like other graphics primitives may be displayed using Show command.

[Graphics:Images/Jankowski_ImageProcessing_gr_22.gif]

[Graphics:Images/Jankowski_ImageProcessing_gr_23.gif]

Here is the input form of ImageData.

[Graphics:Images/Jankowski_ImageProcessing_gr_24.gif]
ImageData[{{{255, 0, 0}, {0, 255, 0}, {0, 0,
255}, {255, 255, 255}, {0, 0, 0}}, 
  {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {255, 255, 255}, {0, 0, 0}},
  {{196, 225, 242}, {96, 204, 248}, {106, 122, 211}, {219, 112, 131},
   {144, 42, 55}}, {{202, 172, 172}, {111, 229, 152}, {227, 140, 232},
   {175, 149, 115}, {249, 229, 3}}, {{2, 168, 101}, {176, 116, 98}, {206, 37, 113},
   {185, 107, 237}, {76, 76, 45}}}, PixelInterleave -> True,
ColorFunction -> RGBColor]

The default ... This converts the image to a planar format.

[Graphics:Images/Jankowski_ImageProcessing_gr_25.gif]
ImageData[{{{255, 0, 0, 255, 0}, {255, 0, 0,
255, 0}, {196, 96, 106, 219, 144}, 
   {202, 111, 227, 175, 249}, {2, 176, 206, 185, 76}},
  {{0, 255, 0, 255, 0}, {0, 255, 0, 255, 0}, {225, 204, 122, 112, 42},
   {172, 229, 140, 149, 229}, {168, 116, 37, 107, 76}},
  {{0, 0, 255, 255, 0}, {0, 0, 255, 255, 0}, {242, 248, 211, 131, 55},
   {172, 152, 232, 115, 3}, {101, 98, 113, 237, 45}}}, PixelInterleave -> False,
ColorFunction -> {RGBColor[#1, 0, 0] & , RGBColor[0, #1, 0] & ,
   RGBColor[0, 0, #1] & }]

This returns a monochrome (i.e. single channel) image.

[Graphics:Images/Jankowski_ImageProcessing_gr_26.gif]
ImageData[{{85., 85., 85., 255., 0}, {85.,
85., 85., 255., 0}, 
  {221., 182.66666666666666, 146.33333333333331, 154., 80.33333333333333},
  {182., 164., 199.66666666666666, 146.33333333333331, 160.33333333333331},
  {90.33333333333333, 130., 118.66666666666666, 176.33333333333331,
   65.66666666666666}}, PixelInterleave -> None, ColorFunction -> GrayLevel]

This converts from the default RGB format to HSV.

[Graphics:Images/Jankowski_ImageProcessing_gr_27.gif]
ImageData[{{{0., 1., 1.},
{0.33333333333333337, 1., 1.}, 
   {0.6666666666666666, 1., 1.}, {0, 0, 1.}, {0, 0, 0}},
  {{0., 1., 1.}, {0.33333333333333337, 1., 1.}, {0.6666666666666666, 1., 1.},
   {0, 0, 1.}, {0, 0, 0}}, {{0.5595413379513471, 0.1900826446280991,
    0.9490196078431372}, {0.5453797791150686, 0.6129032258064515,
    0.9725490196078431}, {0.6440842331116621, 0.49763033175355453,
    0.8274509803921568}, {0.973391114828529, 0.4885844748858448,
    0.8588235294117647}, {0.9813236988642904, 0.7083333333333334,
    0.5647058823529412}}, {{2.371593461809983*^-9, 0.14851485148514842,
    0.792156862745098}, {0.3889176340426471, 0.5152838427947598,
    0.8980392156862745}, {0.8256392086959877, 0.39655172413793094,
    0.9098039215686274}, {0.09556097125631627, 0.34285714285714286,
    0.6862745098039216}, {0.1550068744474194, 0.9879518072289156,
    0.9764705882352941}}, {{0.4343074457102995, 0.9880952380952381,
    0.6588235294117647}, {0.035362577189995255, 0.44318181818181823,
    0.6901960784313725}, {0.9258994821488294, 0.8203883495145632,
    0.807843137254902}, {0.7682965987600818, 0.5485232067510548,
    0.9294117647058824}, {0.16666666666666666, 0.4078947368421053,
    0.2980392156862745}}}, PixelInterleave -> True, ColorFunction -> Hue]

Further reading

User's Guide: Section 2.4.

Function Index: ImageRead, ToGrayLevel, ToHSVColor, PlanarImageData.