Many functions in the Wolfram Language work on images. It’s easy to get an image into the Wolfram Language, for example by copying or dragging it from the web or from a photo collection. You can also just capture an image directly from your camera using the function CurrentImage.

CurrentImage[ ]

You can apply functions to images just like you apply functions to numbers or lists or anything else. The function ColorNegate that we saw in connection with colors also works on images, giving a “negative image”.

ColorNegate[]

Blur[]

Blur[,10]

Table[Blur[,n],{n,0,15,5}]

ImageCollage[Table[Blur[,n],{n,0,15,5}]]

There’s lots of analysis one can do on images. For example, DominantColors finds a list of the most important colors in an image.

DominantColors[]

Binarize[]

DominantColors[Binarize[]]

Another type of analysis is edge detection: finding where in the image there are sharp changes in color. The result looks a bit like a sketch derived from the original image.

EdgeDetect[]

ImageAdd[,]

It’s often convenient to do image processing interactively, creating interfaces using Manipulate. For example, Binarize lets you specify a threshold for what will be turned black as opposed to white. And often the best way to find the right threshold is just to interactively experiment with it.

Manipulate[Binarize[,t],{t,0,1}]

Color negate the result of edge detecting an image. (Use CurrentImage[ ] or any other image.) »

Use Manipulate to make an interface for blurring an image from 0 to 20. »

Make a table of the results from edge detecting an image with blurring from 1 to 10. »

Make an image collage of an image together with the results of blurring, edge detecting and binarizing it. »

Add an image to a binarized version of it. »

Create a Manipulate to display edges of an image as it gets blurred from 0 to 20. »

Image operations work on Graphics and Graphics3D. Edge detect a picture of a sphere. »

Make a Manipulate to make an interface for blurring a purple pentagon from 0 to 20. »

Create a collage of 9 images of disks, each with a random color. »

Use ImageCollage to make a combined image of spheres with hues from 0 to 1 in steps of 0.2. »

Make a table of blurring a disk by an amount from 0 to 30 in steps of 5. »

Use ImageAdd to add an image to an image of a disk. »

Use ImageAdd to add an image to an image of a red octagon. »

Add an image to the color negated version of the edge detected image. »

Edge detect a binarized image. »

Color negate the result of edge detecting an image of a regular pentagon. »

Use ImageAdd to add an image to itself. »

Use ImageAdd to add together the images of regular polygons with between 3 and 100 sides. »

What if I don’t have a camera on my computer, or can’t use it?

Instead of CurrentImage[], just get a test image using for example ExampleData[{"TestImage","Mandrill"}].

What does the number in Blur mean?

It’s the range of pixels that get blurred together.

How does Binarize decide what’s black and what’s white?

If you don’t tell it a threshold, it will pick one based on analyzing the distribution of colors in the image.

Tech Notes