How to | Create an Image Object
Images are an important standard data structure, tightly integrated with the Wolfram System 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:
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 the Wolfram Language makes several assumptions, selecting automatic values for some properties of the image.
To verify these automatic settings, view the Options for the image:
Create a grayscale image by explicitly specifying the ColorSpace:
The ColorSpace now reflects your explicit setting:
Use Tuples to create triplets of values corresponding to the primary and secondary colors:
Use Partition to put the list into 4 columns:
Use Image to create the color image:
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:
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 use ColorCombine with the list of grayscale images to create the RGB image: