This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
How to | Create an Image Object
Images are an important standard data structure, tightly integrated with the Mathematica front end and kernel. Image objects are created by default when you import any file with a supported image format. However, you can create image objects directly with some basic knowledge of the structure and properties of an image expression.
The simplest way to create an image object is to wrap Image around a matrix of real values ranging from 0 to 1:
 Out[17]=
Conveniently, the display of this tiny 2×2 image is larger than it actually is—this is an automatic feature of the front end. In creating the image Mathematica makes several assumptions, selecting automatic values for some properties of the image.
To verify these automatic settings, view the Options for the image:
 Out[27]=
Create a grayscale image by explicitly specifying the ColorSpace:
 Out[18]=
The ColorSpace now reflects your explicit setting:
 Out[11]=
An RGB color image is defined by a rectangular array of triples of real or integer values. Any data with such a structure can be viewed as a color image.
Use Tuples to create triplets of values corresponding to the primary and secondary colors:
 Out[19]=
Use Partition to put the list into 4 columns:
 Out[20]=
Use Image to create the color image:
 Out[21]=
Use InputForm to see the internal structure of the Image expression:
 Out[15]//InputForm=
Use ImageData to extract the array of pixel values. By default, ImageData returns a 2D array of color values as real numbers in the range of 0 to 1:
 Out[16]=
Sometimes you may wish to view the raw image data as a list of matrices, one for each color channel. Set Interleaving to False to convert the image data to this form:
 Out[33]=

Any matrix or list of two or more matrices with the same dimensions can be used to form a new image. Sample the cosine function and use Image to create an image of a wave pattern from the data:
 Out[18]=
You can create an RGB color image by combining three such patterns, one for each of the color channels. First, generate the data by using Map to repeat the sampling calculation for a list of three different functions:
Now create the image:
 Out[20]=
Alternatively, you can form an RGB image by combining a list of three grayscale images.
Use Map with Image to generate a grayscale image from each sampling calculation in :
 Out[35]=
Now use ColorCombine with the list of grayscale images to create the RGB image:
 Out[22]=

Two-channel images are useful in visualizing complex functions:
 Out[23]=