Pages

Thursday, April 9, 2009

The Incredible Convenience of Mathematica Image Processing

Article from Theodore Gray, Co-founder, Director of User Interfaces
Full Article: http://blog.wolfram.com/2008/12/01/the-incredible-convenience-of-mathematica-image-processing/

Here’s a clown fish, and a command that breaks it into 40-pixel squares.

Fish image broken into 40-pixel squares

By the way, we’re seeing another neat thing about the integration of images with Mathematica’s typeset input/output system. This result isn’t an image, it’s a list of images. Lists are general things in Mathematica, and lists of images are no exception. For example, here are the image patches in reverse order.

Fish image's patches in reverse order

And here they are sorted by average pixel value (roughly by brightness):

Fish image's patches sorted by average pixel value

And here are the images sorted into a scatter plot where the x axis represents the red component, the y axis represents the green component, and the size represents the blue component. (Image processing commands are fully integrated and compatible with charting commands. This is, after all, Mathematica, where one comes to expect things to work with each other.)

Image patches in a scatter plot

See how all the green patches are smooth and all the red patches are high-contrast? It might be interesting to look at these patches in a similarity network rather than a scatter plot. Here’s some code to do that.

Coding a function to make similarity graphs

This function identifies patches that are similar in color, then connects them into a network. The parameter says how many neighbors to look at before building the network.

Building a three-neighbor similarity network

Remember how we made a Manipulate to play with the contrast of an image? How about a Manipulate to play with the number of neighbors?

Manipulating the number of neighbors in our similarity graph

No comments: