SimpleCV Examples

Fork me on GitHub

Make computers see with SimpleCV
The Open Source Framework for Vision

Loading and Saving Images

To load an image, specify the file path in the constructor:

my_image = Image("path/to/image.jpg")

To save the image, use the save method. It will automatically use the file you loaded the image from:

my_image.save()

You can also specify a new file to save to, similar to a "Save As...", and future calls to save() will save to this new file:

my_image.save("path/to/new_image.jpg") my_image.save()

You can also show the image:

my_image.show()

Image Manipulation

You can scale images using the "scale" function, so for instance to create a thumbnail.

thumbnail = my_image.scale(90, 90)

You can erode an image using:

eroded = my_image.erode()

You can crop an image using:

cropped = my_image.crop()

you can find all the Image operations here in the documentation

Features

Search type functions return Feature Sets, for instance, finding all lines in an image:

image = Image() lines = image.findLines()

To find blobs its as easy as:

image = Image() blobs = image.findBlobs()

most of the features functions are prefixed with find they can be found in the Image documentation or you can also view a the types of features in the documentations

Color

You can use color to define various types of color for displaying text or marking up images:

black = Color.BLACK yellow = Color.YELLOW

see the color documentation for more information.

ColorCurve is a color spline class for performing color correction. It can takeas parameters a SciPy Univariate spline, or an array with at least 4 point pairs. Either of these must map in a 255x255 space. The curve can then be used in the applyRGBCurve, applyHSVCurve, and applyInstensityCurve functions:

clr = ColorCurve([[0,0], [100, 120], [180, 230], [255, 255]]) image.applyIntensityCurve(clr)

see the color curve documentation for more info

A color map takes a start and end point in 3D space and lets you map a range of values to it. Using the colormap like an array gives you the mapped color.

This is useful for color coding elements by an attribute:

blobs = image.findBlobs() cm = ColorMap(startcolor = Color.RED, endcolor = Color.Blue, startmap = min(blobs.area()) , endmap = max(blobs.area()) for b in blobs: b.draw(cm[b.area()])

see the color map documentation for more info

More Examples

Please check out the youtube channel for demos, or join the mailing list to find out more.