Bases: object
For a discussion of bag of features please see: http://en.wikipedia.org/wiki/Bag_of_words_model_in_computer_vision
Initialize the bag of features extractor. This assumes you don’t have the feature codebook pre-computed. patchsz = the dimensions of each codebook patch numcodes = the number of different patches in the codebook. imglayout = the shape of the resulting image in terms of patches padding = the pixel padding of each patch in the resulting image.
This method builds the bag of features codebook from a list of directories with images in them. Each directory should be broken down by image class. imgdirs = This list of directories. patchsz = the dimensions of each codebook patch numcodes = the number of different patches in the codebook. imglayout = the shape of the resulting image in terms of patches padding = the pixel padding of each patch in the resulting image. imgs_per_dir = this method can use a specified number of images per directory
i.e. min(#imgs_in_dir,imgs_per_dir)
verbose = print output
Once the method has completed it will save the results to a local file using the file name codebook.png
WARNING: THIS METHOD WILL TAKE FOREVER
Bases: SimpleCV.Features.Features.Feature
A blob is a typicall a cluster of pixels that form a feature or unique shape that allows it to be distinguished from the rest of the image Blobs typically are computed very quickly so they are used often to find various items in a picture based on properties. Typically these things like color, shape, size, etc. Since blobs are computed quickly they are typically used to narrow down search regions in an image, where you quickly find a blob and then that blobs region is used for more computational intensive type image processing
This mehtod returns the center of the blob’s bounding box
Draw the blob, in the given color, to the appropriate layer
By default, this draws the entire blob filled in, with holes. If you provide a width, an outline of the exterior and interior contours is drawn.
color = The color to render the blob. alpha = The alpha value of the rendered blob. width = The width of the drawn blob in pixels, if -1 then filled then the polygon is filled. layer = if layer is not None, the blob is rendered to the layer versus the source image.
This method renders all of the holes (if any) that are present in the blob
color = The color to render the blob’s holes. alpha = The alpha value of the rendered blob hole. width = The width of the drawn blob hole in pixels, if w=-1 then the polygon is filled. layer = if layer is not None, the blob is rendered to the layer versus the source image.
Draw the blob’s convex hull to either the source image or to the specified layer given by layer.
color = The color to render the blob’s convex hull. alpha = The alpha value of the rendered blob. width = The width of the drawn blob in pixels, if w=-1 then the polygon is filled. layer = if layer is not None, the blob is rendered to the layer versus the source image.
Draw the actual pixels of the blob to another layer. This is handy if you want to examine just the pixels inside the contour.
offset = The offset from the top left corner where we want to place the mask.
Draw the blob contour the given layer – if no layer is provided, draw to the source image
color = The color to render the blob. alpha = The alpha value of the rendered blob. width = The width of the drawn blob in pixels, -1 then the polygon is filled. layer = if layer is not None, the blob is rendered to the layer versus the source image.
Given a tolerance, test the blob against the rectangle distance to see if it is rectangular
Given a tolerance, test if the blob is a rectangle, and how close its bounding rectangle’s aspect ratio is to 1.0
This function returns a tuple representing the average color of the blob
Rotate the blob given the angle in degrees most of the blob elements will be rotated, not however this will “break” drawing back to the original image. To draw the blob create a new layer and draw to that layer.
Blob maker encapsulates all of the contour extraction process and data, so it can be used inside the image class, or extended and used outside the image class. The general idea is that the blob maker provides the utilites that one would use for blob extraction. Later implementations may include tracking and other features.
Extract blobs using a color model img - The input image colormodel - The color model to use. minsize - The minimum size of the returned features. maxsize - The maximum size of the returned features 0=uses the default value.
Bases: SimpleCV.Features.Features.Feature
The Barcode Feature wrappers the object returned by findBarcode(), a python-zxing object.
Bases: SimpleCV.Features.Features.Feature
This class is used for Calibration, it uses a chessboard to calibrate from pixels to real world measurements
Bases: SimpleCV.Features.Features.Feature
The Corner feature is a point returned by the FindCorners function Corners are used in machine vision as a very computationally low way to find unique features in an image. These corners can be used in conjunction with many other algorithms.
Bases: SimpleCV.Features.Features.Feature
The HaarFeature is a rectangle returned by the FindHaarFeature() function.
Bases: SimpleCV.Features.Features.Feature
The Line class is returned by the findLines function, but can also be initialized with any two points:
l = Line(Image, point1, point2) Where point1 and point2 are coordinate tuples
l.points will be a tuple of the two points
Bases: SimpleCV.Features.Features.Feature
This class is used for template (pattern) matching in images The template matching cannot handle scale or rotation
Bases: SimpleCV.Features.FeatureExtractorBase.FeatureExtractorBase
Create a 1D edge length histogram and 1D edge angle histogram.
This method takes in an image, applies an edge detector, and calculates the length and direction of lines in the image.
bins = the number of bins
Bases: object
The featureExtractorBase class is a way of abstracting the process of collecting descriptive features within an image. A feature is some description of the image like the mean color, or the width of a center image, or a histogram of edge lengths. This feature vectors can then be composed together and used within a machine learning algorithm to descriminate between different classes of objects.
Bases: object
The Feature object is an abstract class which real features descend from. Each feature object has:
This function returns the largest bounding box for an image.
Returns Image
This function will automatically draw the features on the image and show it. It is a basically a shortcut function for development and is the same as:
>>> img = Image("logo")
>>> feat = img.findBlobs()
>>> if feat: feat.draw()
>>> img.show()
Bases: list
FeatureSet is a class extended from Python’s list which has special functions so that it is useful for handling feature metadata on an image.
In general, functions dealing with attributes will return numpy arrays, and functions dealing with sorting or filtering will return new FeatureSets.
Example: >>> image = Image(“/path/to/image.png”) >>> lines = image.findLines() #lines are the feature set >>> lines.draw() >>> lines.x() >>> lines.crop()
Return a FeatureSet which is filtered on a numpy boolean array. This will let you use the attribute functions to easily screen Features out of return FeatureSets.
Some examples:
Return all lines < 200px >>> my_lines.filter(my_lines.length() < 200) # returns all lines < 200px >>> my_blobs.filter(my_blobs.area() > 0.9 * my_blobs.length**2) # returns blobs that are nearly square >>> my_lines.filter(abs(my_lines.angle()) < numpy.pi / 4) #any lines within 45 degrees of horizontal >>> my_corners.filter(my_corners.x() - my_corners.y() > 0) #only return corners in the upper diagonal of the image
This function will automatically draw the features on the image and show it. It is a basically a shortcut function for development and is the same as:
>>> img = Image("logo")
>>> feat = img.findBlobs()
>>> if feat: feat.draw()
>>> img.show()
Create a single Haar feature and optionally set the regions that define the Haar feature and its name. The formal of the feature is
The format is [[[TL],[BR],SIGN],[[TL],[BR],SIGN].....] Where TR and BL are the unit coorinates for the top right and bottom left coodinates.
For example [[[0,0],[0.5,0.5],1],[[0.5.0],[1.0,1.0],-1]]
Takes the right side of the image and subtracts from the left hand side of the image.
Set the list of regions. The regions are square coordinates on a unit sized image followed by the sign of a region.
The format is [[[TL],[BR],SIGN],[[TL],[BR],SIGN].....] Where TR and BL are the unit coorinates for the top right and bottom left coodinates.
For example [[[0,0],[0.5,0.5],1],[[0.5.0],[1.0,1.0],-1]]
Takes the right side of the image and subtracts from the left hand side of the image.
Bases: SimpleCV.Features.FeatureExtractorBase.FeatureExtractorBase
This is used generate Haar like features from an image. These Haar like features are used by a the classifiers of machine learning to help identify objects or things in the picture by their features, or in this case haar features.
For a more in-depth review of Haar Like features see: http://en.wikipedia.org/wiki/Haar-like_features
Bases: SimpleCV.Features.FeatureExtractorBase.FeatureExtractorBase
Create a Hue Histogram feature extractor. This feature extractor takes in an image, gets the hue channel, bins the number of pixels with a particular Hue, and returns the results.
mNBins - the number of Hue bins.
Bases: SimpleCV.Features.FeatureExtractorBase.FeatureExtractorBase
This feature extractor collects some basic morphology infromation about a given image. It is assumed that the object to be recognized is the largest object in the image. The user must provide a segmented white on black blob image. This operation then straightens the image and collects the data.
The threshold operation is a function of the form binaryimg = threshold(img)
the simplest example would be: def binarize_wrap(img):
return img.binarize()