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 extracts a bag of features histogram for the input image using the provided codebook. The result are the bin counts for each codebook code.
Get patches from a single images. This is an external access method. The user will need to maintain the list of features. See the generate method as a guide to doing this by hand. Sz is the image patch size.
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.
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
This method gives the names of each field in the feature vector in the order in which they are returned. For example, ‘xpos’ or ‘width’
This method returns the total number of fields in the feature vector.
Load a codebook from file using the datafile. The datafile should point to a local image for the source patch image.
This method will return the centroids of the k-means analysis of a large number of images. Ncodes is the number of centroids to find.
This is a “just for fun” method as a sanity check for the BOF codeook. The method takes in an image, extracts each codebook code, and replaces the image at the position with the code.
Save the bag of features codebook and data set to a local file.
Bases: SimpleCV.Features.Features.Feature
SUMMARY
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.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blobs[-1].draw()
>>> img.show()
SEE ALSO findBlobs() BlobMaker findBlobsFromMask()
SUMMARY
This method returns the angle between the horizontal and the minimum enclosing rectangle of the blob. The minimum enclosing rectangle IS NOT not the bounding box. Use the bounding box for situations where you need only an approximation of the objects dimensions. The minimum enclosing rectangle is slightly harder to maninpulate but gives much better information about the blobs dimensions.
RETURNS
Returns the angle between the minimum bounding rectangle and the horizontal.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blob[-1].angle()
SUMMARY
This method returns the area of the blob in terms of the number of pixels inside the contour.
RETURNS
An integer of the area of the blob in pixels.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> print blobs[-1].area()
>>> print blobs[0].area()
SUMMARY
This method automatically copies all of the image data around the blob and puts it in a new image. The resulting image has the size of the blob, with the blob data copied in place. Where the blob is not present the background is black.
RETURNS
Returns just the image of the blob (cropped to fit).
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blobs[-1].blobImage().show()
SUMMARY
This method returns an image of the blob’s mask. Areas where the blob are present are white while all other areas are black. The image is cropped to match the blob area.
RETURNS
Returns a SimplecV image of the blob’s mask, cropped to fit.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blobs[-1].blobMask().show()
SUMMARY
Return the centroid (mass-determined center) of the blob. Note that this is differnt from the bounding box center.
RETURNS
An (x,y) tuple that is the center of mass of the blob.
EXAMPLE >>> img = Image(“lenna”) >>> blobs = img.findBlobs() >>> img.drawCircle((blobs[-1].x,blobs[-1].y),10,color=Color.RED) >>> img.drawCircle((blobs[-1].centroid()),10,color=Color.BLUE) >>> img.show()
SUMMARY
Compare the hull mask to an ideal circle and count the number of pixels that deviate as a fraction of total area of the ideal circle.
RETURNS
The difference, as a percentage, between the hull of our blob and an idealized circle of our blob.
SUMMARY
This function returns the contour points as a list of x,y tuples.
RETURNS
A list of x,y tuples.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> print blobs[-1].contour()
SUMMARY
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.
PARAMETERS
RETURNS
This method either works on the original source image, or on the drawing layer provided. The method does not modify object itself.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blobs[-2].draw(color=Color.PUCE,width=-1,alpha=128)
>>> img.show()
SUMMARY
This method renders all of the holes (if any) that are present in the blob.
PARAMETERS
RETURNS
This method either works on the original source image, or on the drawing layer provided. The method does not modify object itself.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs(128)
>>> blobs[-1].drawHoles(color=Color.GREEN,width=3,alpha=128)
>>> img.show()
SUMMARY
Draw the blob’s convex hull to either the source image or to the specified layer given by layer.
PARAMETERS
RETURNS
This method either works on the original source image, or on the drawing layer provided. The method does not modify object itself.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs(128)
>>> blobs[-1].drawHoles(color=Color.GREEN,width=3,alpha=128)
>>> img.show()
SUMMARY
Draw the actual pixels of the blob to another layer. This is handy if you want to examine just the pixels inside the contour.
PARAMETERS
RETURNS
This method either works on the original source image, or on the drawing layer provided. The method does not modify object itself.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs(128)
>>> dl = DrawingLayer((img.width,img.height))
>>> blobs[-1].drawMaskToLayer(layer = dl)
>>> dl.show()
SUMMARY
Draws the minimum bounding rectangle for the blob. The minimum bounding rectangle is the smallest rotated rectangle that can enclose the blob.
PARAMETERS
RETURNS
Returns none, this operation works on the supplied layer or the source image.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> for b in blobs:
>>> b.drawMinRect(color=Color.RED, width=-1,alpha=128)
>>> img.show()
SUMMARY
Draw the blob contour the provided layer – if no layer is provided, draw to the source image.
PARAMETERS
RETURNS
This method either works on the original source image, or on the drawing layer provided. The method does not modify object itself.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blobs[-2].drawOutline(color=Color.GREEN,width=3,alpha=128)
>>> img.show()
SUMMARY
Draws the bounding rectangle for the blob.
PARAMETERS
RETURNS
Returns None, this operation works on the supplied layer or the source image.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blobs[-1].drawRect(color=Color.RED, width=-1,alpha=128)
>>> img.show()
SUMMARY
This function returns the convex hull points as a list of x,y tuples.
RETURNS
A list of x,y tuples.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> print blobs[-1].hull()
SUMMARY
The convex hull of a blob is the shape that would result if you snapped a rubber band around the blob. So if you had the letter “C” as your blob the convex hull would be the letter “O.” This method returns an image where the source image around the convex hull of the blob is copied ontop a black background.
RETURNS Returns a SimpleCV Image of the convex hull, cropped to fit.
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blobs[-1].hullImage().show()
SUMMARY
The convex hull of a blob is the shape that would result if you snapped a rubber band around the blob. So if you had the letter “C” as your blob the convex hull would be the letter “O.” This method returns an image where the area of the convex hull is white and the rest of the image is black. This image is cropped to the size of the blob.
RETURNS
Returns a binary SimpleCV image of the convex hull mask, cropped to fit the blob.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blobs[-1].hullMask().show()
SUMMARY
Return the radius of the convex hull contour from the centroid
SUMMARY
Test circle distance against a tolerance to see if the blob is circlular.
PARAMETERS
RETURNS
True if the feature is within tolerance for being a circle, false otherwise.
SUMMARY
Given a tolerance, test the blob against the rectangle distance to see if it is rectangular.
PARAMETERS
RETURNS
Boolean True if the blob is withing the rectangle tolerage, false otherwise.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs(128)
>>> if(blobs[-1].isRecangle() ):
>>> print "it is hip to be square."
SUMMARY
Given a tolerance, test if the blob is a rectangle, and how close its bounding rectangle’s aspect ratio is to 1.0.
PARAMETERS
RETURNS
Boolean True if our object falls within tolerance, false otherwise.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs(128)
>>> if(blobs[-1].isSquare() ):
>>> print "it is hip to be square."
SUMMARY
Compare the Hu moments between two blobs to see if they match. Returns a comparison factor – lower numbers are a closer match.
PARAMETERS
RETURNS
A single floating point value that is the match quality.
EXAMPLE
>>> cam = Camera()
>>> img1 = cam.getImage()
>>> img2 = cam.getImage()
>>> b1 = img1.findBlobs()
>>> b2 = img2.findBlobs()
>>> for ba in b1:
>>> for bb in b2:
>>> print ba.match(bb)
SUMMARY
This function returns a tuple representing the average color of the blob.
RETURNS
A RGB triplet of the average blob colors.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> print blobs[-1].meanColor()
Returns the corners for the smallest rotated rectangle to enclose the blob. The points are returned as a list of (x,y) tupples.
SUMMARY
This is the height, in pixels, of the minimum bounding rectangle.
RETURNS
An integer that is the height of the minimum bounding rectangle for this blob.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> print blobs[-1].minRectHeight()
SUMMARY
This is the width of the minimum bounding rectangle for the blob.
RETURNS
An integer that is the width of the minimum bounding rectangle for this blob.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> print blobs[-1].minRectWidth()
SUMMARY
This is the x coordinate of the centroid for the minimum bounding rectangle
RETURNS
An integer that is the x position of the centrod of the minimum bounding rectangle.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> print blobs[-1].minRectX()
SUMMARY
This is the y coordinate of the centroid for the minimum bounding rectangle
RETURNS
An integer that is the y position of the centrod of the minimum bounding rectangle.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> print blobs[-1].minRectY()
SUMMARY
This function returns the perimeter as an integer number of pixel lengths.
RETURNS
Integer
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> print blobs[-1].perimeter()
SUMMARY
Return the radius, the avg distance of each contour point from the centroid
SUMMARY
This compares the hull mask to the bounding rectangle. Returns the area of the blob’s hull as a fraction of the bounding rectangle.
RETURNS
The number of pixels in the blobs hull mask over the number of pixels in its bounding box.
SUMMARY
Rectify the blob image and the contour such that the major axis is aligned to either horizontal=0 or vertical=1. This is to say, we take the blob, find the longest axis, and rotate the blob such that the axis is either vertical or horizontal.
PARAMETERS
RETURNS
This method works in place, i.e. it rotates the blob’s internal data structures. This method is experimetnal. Use at your own risk.
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blobs[-2].mImg.show()
>>> blobs[-2].rectifyToMajorAxis(1)
>>> blobs[-2].mImg.show()
SUMMARY
Rotate the blob given an angle in degrees. If you use this method most of the blob elements will be rotated in place , however, this will “break” drawing back to the original image. To draw the blob create a new layer and draw to that layer. Positive rotations are counter clockwise.
PARAMETERS
RETURNS
EXAMPLE
>>> img = Image("lenna")
>>> blobs = img.findBlobs()
>>> blobs[-2].mImg.show()
>>> blobs[-2].rotate(90)
>>> blobs[-2].mImg.show()
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.
This method performs a threshold operation on the input image and then extracts and returns the blobs. img - The input image (color or b&w) threshval - The threshold value for the binarize operation. If threshval = -1 adaptive thresholding is used minsize - The minimum blob size in pixels. maxsize - The maximum blob size in pixels. 0=uses the default value. threshblocksize - The adaptive threhold block size. threshconstant - The minimum to subtract off the adaptive threshold
This method performs blob extraction given a binary source image that is used to get the blob images, and a color source image. binaryImg- The binary image with the blobs. colorImg - The color image. minSize - The minimum size of the blobs in pixels. maxSize - The maximum blob size in pixels.
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
SUMMARY
The Barcode Feature wrappers the object returned by findBarcode(), a python-zxing object.
SEE ALSO
ImageClass.findBarcodes()
SUMMARY
Returns the area defined by the quandrangle formed by the boundary points
RETURNS
An integer area value.
EXAMPLE
>>> img = Image("mycode.jpg")
>>> bc = img.findBarcode()
>>> print bc[-1].area()
SUMMARY
Draws the bounding area of the barcode, given by points. Note that for QR codes, these points are the reference boxes, and so may “stray” into the actual code.
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
SUMMARY
Returns the longest side of the quandrangle formed by the boundary points.
RETURNS
A floating point length value.
EXAMPLE
>>> img = Image("mycode.jpg")
>>> bc = img.findBarcode()
>>> print bc[-1].length()
Bases: SimpleCV.Features.Features.Feature
SUMMARY
This class is used for Calibration, it uses a chessboard to calibrate from pixels to real world measurements.
SUMMARY
Returns the mean of the distance between corner points in the chessboard Given that the chessboard is of a known size, this can be used as a proxy for distance from the camera
RETURNS
Returns the mean distance between the corners.
EXAMPLE
>>> img = Image("corners.jpg")
>>> feats = img.findChessboardCorners()
>>> print feats[-1].area()
SUMMARY
Draws the chessboard corners. We take a color param, but ignore it.
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
Bases: SimpleCV.Features.Features.Feature
SUMMARY
Class for a general circle feature with a center at (x,y) and a radius r
Area covered by the feature – for a pixel, 1
SUMMARY
Returns a numpy array of the area of each feature in pixels.
RETURNS
A numpy array of all the positions in the featureset.
EXAMPLE
>>> img = Image("lenna")
>>> feats = img.findBlobs()
>>> xs = feats.coordinates()
>>> print xs
SUMMARY
This function returns the largest bounding box for an image.
PARAMETERS
RETURNS
The masked circle image.
SUMMARY
Returns the diameter of the circle in pixels.
SUMMARY
Given a point (default to center of the image), return the euclidean distance of x,y from this point.
PARAMETERS
RETURNS
The distance as a floating point value in pixels.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findCircle()
>>> blobs[-1].distanceFrom(blobs[-2].coordinates())
SUMMARY
With no dimension information, color the x,y point for the feature.
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
SUMMARY
Returns the height of the feature – for compliance just r*2
SUMMARY
Returns the average color within the circle.
RETURNS
Returns an RGB triplet that corresponds to the mean color of the feature.
EXAMPLE
>>> img = Image("lenna")
>>> c = img.findCircle()
>>> c[-1].meanColor()
SUMMARY
Returns the perimeter of the circle feature in pixels.
SUMMARY
Returns the radius of the circle in pixels.
SUMMARY
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:
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
EXAMPLE
>>> img = Image("logo")
>>> feat = img.findCircle()
>>> feat[0].show()
SUMMARY
Returns the width of the feature – for compliance just r*2
Bases: SimpleCV.Features.Features.Feature
SUMMARY
The Corner feature is a point returned by the FindCorners function Corners are used in machine vision as a very computationally efficient way to find unique features in an image. These corners can be used in conjunction with many other algorithms.
SEE ALSO
findCorners()
SUMMARY
Draw a small circle around the corner. Color tuple is single parameter, default is Red.
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
Bases: SimpleCV.Features.Features.Feature
SUMMARY
The HaarFeature is a rectangle returned by the FindHaarFeature() function.
SUMMARY
Returns the area of the feature in pixels.
RETURNS
The area of the feature in pixels.
EXAMPLE
>>> img = Image("lenna")
>>> face = HaarCascade("face.xml")
>>> faces = img.findHaarFeatures(face)
>>> print faces[-1].area()
SUMMARY
Draw the bounding rectangle, default color green.
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
SUMMARY
Find the mean color of the boundary rectangle.
RETURNS
Returns an RGB triplet that corresponds to the mean color of the feature.
EXAMPLE
>>> img = Image("lenna")
>>> face = HaarCascade("face.xml")
>>> faces = img.findHaarFeatures(face)
>>> print faces[-1].meanColor()
Bases: SimpleCV.Features.Features.Feature
SUMMARY
The class is place holder for SURF/SIFT/ORB/STAR keypoints.
SUMMARY
Return the angle (theta) in degrees of the feature. The default is 0 (horizontal).
RETURNS
An angle value in degrees.
Return the euclidean color distance of the color tuple at x,y from a given color (default black)
SUMMARY
This function returns the largest bounding box for an image.
PARAMETERS
RETURNS
The masked circle image.
SUMMARY
Returns the raw keypoint descriptor.
SUMMARY
Returns the diameter of the circle in pixels.
SUMMARY
Given a point (default to center of the image), return the euclidean distance of x,y from this point
SUMMARY
Draw a circle around the feature. Color tuple is single parameter, default is Green.
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
SUMMARY
Returns the type of keypoint as a string (e.g. SURF/MSER/ETC)
SUMMARY
Returns the raw keypoint object.
SUMMARY
Returns the height of the feature – for compliance just r*2
SUMMARY
Return the average color within the feature’s radius
RETURNS
Returns an RGB triplet that corresponds to the mean color of the feature.
EXAMPLE
>>> img = Image("lenna")
>>> kp = img.findKeypoints()
>>> c = kp[0].meanColor()
SUMMARY
Returns the raw keypoint’s octave (if it has one).
SUMMARY
Returns the perimeter of the circle feature in pixels.
SUMMARY
Returns the quality metric for the keypoint object.
SUMMARY
Returns the radius of the circle in pixels.
SUMMARY
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()
SUMMARY
Returns the width of the feature – for compliance just r*2
Bases: SimpleCV.Features.Features.Feature
This class encapsulates a keypoint match between images of an object. It is used to record a template of one image as it appears in another image
Returns a cropped image of the feature match. This cropped version is the axes aligned box masked to just include the image data of the minimum bounding rectangle.
The default drawing operation is to draw the min bounding rectangle in an image.
SUMMARY
Draw a small circle around the corner. Color tuple is single parameter, default is Red.
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
This method draws the axes alligned square box of the template match. This box holds the minimum bounding rectangle that describes the object. If the minimum bounding rectangle is axes aligned then the two bounding rectangles will match.
Returns the _homography matrix used to calulate the minimum bounding rectangle.
Returns the minimum bounding rectangle of the feature as a list of (x,y) tuples.
return the average color within the circle SUMMARY
Return a numpy array of the average color of the area covered by each Feature.
RETURNS
Returns an array of RGB triplets the correspond to the mean color of the feature.
EXAMPLE
>>> img = Image("lenna")
>>> kp = img.findKeypoints()
>>> c = kp.meanColor()
Bases: SimpleCV.Features.Features.Feature
SUMMARY
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 (x,y) coordinate tuples.
>>> l.points
Returns a tuple of the two points
SUMMARY
This is the angle of the line, from the leftmost point to the rightmost point Returns angle (theta) in radians, with 0 = horizontal, -pi/2 = vertical positive slope, pi/2 = vertical negative slope
RETURNS
An angle value in degrees.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> ls = img.findLines
>>> for l in ls:
>>> if l.angle() == 0:
>>> print "I AM HORIZONTAL."
SUMMARY
This function crops the source image to the location of the feature and returns a new SimpleCV image.
RETURNS
A SimpleCV image that is cropped to the feature position and size.
EXAMPLE
>>> img = Image("../sampleimages/EdgeTest2.png")
>>> l = img.findLines()
>>> myLine = l[0].crop()
Draw the line, default color is blue
SUMMARY
Draw a small circle around the corner. Color tuple is single parameter, default is Red.
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
SUMMARY
This method returns the length of the line.
RETURNS
A floating point length value.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> lines = img.findLines
>>> for l in lines:
>>> if l.length() > 100:
>>> print "OH MY! - WHAT A BIG LINE YOU HAVE!"
>>> print "---I bet you say that to all the lines."
SUMMARY
Returns the mean color of pixels under the line. Note that when the line falls “between” pixels, each pixels color contributes to the weighted average.
RETURNS
Returns an RGB triplet corresponding to the mean color of the feature.
EXAMPLE
>>> img = Image("lenna")
>>> l = img.findLines()
>>> c = l[0].meanColor()
Bases: SimpleCV.Features.Features.Feature
SUMMARY
The motion feature is used to encapsulate optical flow vectors. The feature holds the length and direction of the vector.
This function returns the image in the sample window around the flow vector.
Returns Image
SUMMARY Draw the optical flow vector going from the sample point along the length of the motion vector.
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
Returns the magnitude of the optical flow vector.
Return the color tuple from x,y SUMMARY
Return a numpy array of the average color of the area covered by each Feature.
RETURNS
Returns an array of RGB triplets the correspond to the mean color of the feature.
EXAMPLE
>>> img = Image("lenna")
>>> kp = img.findKeypoints()
>>> c = kp.meanColor()
SUMMARY
This helper method normalizes the vector give an input magnitude. This is helpful for keeping the flow vector inside the sample window.
Returns the unit vector direction of the flow vector as an (x,y) tuple.
Returns the raw direction vector as an (x,y) tuple.
Return the window size that we sampled over.
Bases: SimpleCV.Features.Features.Feature
SUMMARY
This class is used for template (pattern) matching in images. The template matching cannot handle scale or rotation.
Given another template feature, make this feature the size of the two features combined.
SUMMARY
Draw the bounding rectangle, default color green.
PARAMETERS
RETURNS
Nothing - this is an inplace operation that modifies the source images drawing layer.
This method keeps the feature’s center the same but sets a new width and height
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
Extract the line orientation and and length histogram.
Return the names of all of the length and angle fields.
This method returns the total number of fields in the feature vector.
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.
Given an image extract the feature vector. The output should be a list object of all of the features. These features can be of any interal type (string, float, integer) but must contain no sub lists.
This method gives the names of each field in the feature vector in the order in which they are returned. For example, ‘xpos’ or ‘width’
This method returns the total number of fields in the feature vector.
load segmentation settings to file.
Save segmentation settings to file.
Bases: object
SUMMARY
The Feature object is an abstract class which real features descend from. Each feature object has:
SUMMARY
Return true if the feature is above the object, where object can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a Boolean, True if the feature is above the object, False otherwise.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[0]
>>> if( blobs[-1].above(b) ):
>>> print "above the biggest blob"
SUMMARY
Return the angle (theta) in degrees of the feature. The default is 0 (horizontal).
Warning
This is not a valid operation for all features.
RETURNS
An angle value in degrees.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> for b in blobs:
>>> if b.angle() == 0:
>>> print "I AM HORIZONTAL."
TODO
Double check that values are being returned consistently.
SUMMARY
Returns the area (number of pixels) covered by the feature.
RETURNS
An integer area of the feature.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> for b in blobs:
>>> if b.area() > 200:
>>> print b.area()
SUMMARY
Return the aspect ratio of the feature, which for our purposes is max(width,height)/min(width,height).
RETURNS
A single floating point value of the aspect ration.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> b[0].aspectRatio()
SUMMARY
Return true if the feature is below the object, where object can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a Boolean, True if the feature is below the object, False otherwise.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[0]
>>> if( blobs[-1].below(b) ):
>>> print "above the biggest blob"
SUMMARY
This method returns the bottom left corner of the bounding box of the blob as an (x,y) tuple.
RESULT
Returns a tupple of the bottom left corner.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs[-1].bottomLeftCorner()
SUMMARY
This method returns the bottom right corner of the bounding box of the blob as an (x,y) tuple.
RESULT
Returns a tupple of the bottom right corner.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs[-1].bottomRightCorner()
SUMMARY
This function calculates the corners of the feature and returns them as a list of (x,y) tuples.
RETURNS
A list of (x,y) corner tuples. The order is top left, bottom left, bottom right, top right. EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs[-1].boundingBox()
TO DO
Make the order of points go from the top left glockwise.
SUMMARY
Return the euclidean color distance of the color tuple at x,y from a given color (default black).
PARAMETERS
RETURNS
A floating point color distance value.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> for b in blobs:
>>> print b.colorDistance(color.WHITE):
SUMMARY
Return true if the feature contains the object, where object can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a Boolean, True if the feature contains the object, False otherwise.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[0]
>>> if( blobs[-1].contains(b) ):
>>> print "this blob is contained in the biggest blob"
NOTE
This currently performs a bounding box test, not a full polygon test for speed.
SUMMARY
Returns the x,y position of the feature. This is usually the center coordinate.
RETURNS
Returns an (x,y) tuple of the position of the feature.
EXAMPLE
>>> img = Image("aerospace.png")
>>> blobs = img.findBlobs()
>>> for b in blobs:
>>> print b.coordinates()
SUMMARY
This function crops the source image to the location of the feature and returns a new SimpleCV image.
RETURNS
A SimpleCV image that is cropped to the feature position and size.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> big = blobs[-1].crop()
>>> big.show()
SUMMARY
Given a point (default to center of the image), return the euclidean distance of x,y from this point.
PARAMETERS
RETURNS
The distance as a floating point value in pixels.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> blobs[-1].distanceFrom(blobs[-2].coordinates())
SUMMARY
This method returns the distance, in pixels, from the nearest image edge.
RETURNS
The integer distance to the nearest edge.
EXAMPLE
>>> img = Image("../sampleimages/EdgeTest1.png")
>>> b = img.findBlobs()
>>> b[0].distanceToNearestEdge()
SUMMARY
Return true if the feature does not contain the other object, where other can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a Boolean, True if the feature does not contain the object, False otherwise.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[0]
>>> if( blobs[-1].doesNotContain(b) ):
>>> print "above the biggest blob"
Returns true if all of features points are inside this point.
SUMMARY
Return true if the feature does not overlap the object other, where other can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a Boolean, True if the feature does not Overlap the object, False otherwise.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[0]
>>> if( blobs[-1].doesNotOverlap(b) ):
>>> print "does not over overlap biggest blob"
SUMMARY
This method will draw the feature on the source image.
PARAMETERS
RETURNS
Nothing.
EXAMPLE
>>> img = Image("RedDog2.jpg")
>>> blobs = img.findBlobs()
>>> blobs[-1].draw()
>>> img.show()
SUMMARY
This function returns the maximum and minimum x and y values for the feature and returns them as a tuple.
RETURNS
A tuple of the extents of the feature. The order is (MaxX,MaxY,MinX,MinY).
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs[-1].extents()
SUMMARY
Returns the height of the feature.
RETURNS
An integer value of the feature’s height.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> for b in blobs:
>>> if b.width() > b.height():
>>> print "wider than tall"
>>> b.draw()
>>> img.show()
SUMMARY
Return true if the feature is contained withing the object other, where other can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a Boolean, True if the feature is above the object, False otherwise.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[0]
>>> if( blobs[-1].isContainedWithin(b) ):
>>> print "inside the blob"
SUMMARY
Return true if the feature is not contained within the shape, where shape can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a Boolean, True if the feature is not contained within the shape, False otherwise.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[0]
>>> if( blobs[-1].isNotContainedWithin(b) ):
>>> print "Not inside the biggest blob"
SUMMARY
Return true if the feature is to the left of the object, where object can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a Boolean, True if the feature is to the left of the object, False otherwise.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[0]
>>> if( blobs[-1].left(b) ):
>>> print "left of the biggest blob"
SUMMARY
This method returns the longest dimension of the feature (i.e max(width,height)).
RETURNS
A floating point length value.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> for b in blobs:
>>> if b.length() > 200:
>>> print "OH MY! - WHAT A BIG FEATURE YOU HAVE!"
>>> print "---I bet you say that to all the features."
TODO
Should this be sqrt(x*x+y*y)?
SUMMARY
This method return the minimum x value of the bounding box of the the feature.
RETURNS
An integer value of the maxium x value of the feature.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs[-1].maxX()
SUMMARY
This method return the maximum y value of the bounding box of the the feature.
RETURNS
An integer value of the maximum y value of the feature.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs[-1].maxY()
SUMMARY
Return the average color within the feature as a tuple.
RETURNS
An RGB color tuple.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> for b in blobs:
>>> if (b.meanColor() == color.WHITE):
>>> print "Found a white thing"
SUMMARY
This method return the minimum x value of the bounding box of the the feature.
RETURNS
An integer value of the minimum x value of the feature.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs[-1].minX()
SUMMARY
This method return the minimum y value of the bounding box of the the feature.
RETURNS
An integer value of the minimum y value of the feature.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs[-1].minY()
SUMMARY
This method returns True if the feature is greate than tolerance pixels away from the nearest edge.
PARAMETERS
RETURNS
True if the feature is not on the edge of the image, False otherwise.
EXAMPLE
>>> img = Image("../sampleimages/EdgeTest1.png")
>>> b = img.findBlobs()
>>> if(b[0].notOnImageEdge()):
>>> print "I am safe and sound."
SUMMARY
This method returns True if the feature is less than tolerance pixels away from the nearest edge.
PARAMETERS
RETURNS
True if the feature is on the edge, False otherwise.
EXAMPLE
>>> img = Image("../sampleimages/EdgeTest1.png")
>>> b = img.findBlobs()
>>> if(b[0].onImageEdge()):
>>> print "HELP! I AM ABOUT TO FALL OFF THE IMAGE"
SUMMARY
Return true if the feature overlaps the object, where object can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a Boolean, True if the feature overlaps object, False otherwise.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[0]
>>> if( blobs[-1].overlaps(b) ):
>>> print "This blob overlaps the biggest blob"
Returns true if this blob contains at least one point, part of a collection of points, or any part of a blob.
NOTE
This currently performs a bounding box test, not a full polygon test for speed.
SUMMARY
Return true if the feature is to the right object, where object can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a Boolean, True if the feature is to the right object, False otherwise.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[0]
>>> if( blobs[-1].right(b) ):
>>> print "right of the the blob"
SUMMARY
This function will automatically draw the features on the image and show it.
RETURNS
Nothing.
EXAMPLE
>>> img = Image("logo")
>>> feat = img.findBlobs()
>>> feat[-1].show() #window pops up.
SUMMARY
This method returns the top left corner of the bounding box of the blob as an (x,y) tuple.
RESULT
Returns a tupple of the top left corner.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs[-1].topLeftCorner()
SUMMARY
This method returns the top right corner of the bounding box of the blob as an (x,y) tuple.
RESULT
Returns a tupple of the top right corner.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs[-1].topRightCorner()
SUMMARY
Returns the height of the feature.
RETURNS
An integer value for the feature’s width.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> for b in blobs:
>>> if b.width() > b.height():
>>> print "wider than tall"
>>> b.draw()
>>> img.show()
Bases: list
SUMMARY
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()
SUMMARY
Return only the features that are above a region. Where region can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a featureset of features that are above the region.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[-1]
>>> lines = img.findLines()
>>> outside = lines.above(b)
NOTE
This currently performs a bounding box test, not a full polygon test for speed.
SUMMARY
Return a numpy array of the angles (theta) of each feature. Note that theta is given in degrees, with 0 being horizontal.
RETURNS
An array of angle values corresponding to the features.
EXAMPLE
>>> img = Image("lenna")
>>> l = img.findLines()
>>> angs = l.angle()
>>> print angs
SUMMARY
Returns a numpy array of the area of each feature in pixels.
RETURNS
A numpy array of all the positions in the featureset.
EXAMPLE
>>> img = Image("lenna")
>>> feats = img.findBlobs()
>>> xs = feats.area()
>>> print xs
SUMMARY
Return the aspect ratio of all the features in the feature set, For our purposes aspect ration is max(width,height)/min(width,height).
RETURNS
A numpy array of the aspect ratio of the features in the featureset.
EXAMPLE
>>> img = Image("OWS.jpg")
>>> blobs = img.findBlobs(128)
>>> print blobs.aspectRatio()
SUMMARY
Return only the features below the region. where region can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a featureset of features that are below the region.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[-1]
>>> lines = img.findLines()
>>> inside = lines.below(b)
NOTE
This currently performs a bounding box test, not a full polygon test for speed.
SUMMARY
This method returns the bottom left corner of each feature’s bounding box.
RETURNS
A numpy array of x,y position values.
EXAMPLE
>>> img = Image("./sampleimages/EdgeTest1.png")
>>> blobs = img.findBlobs()
>>> bl = img.bottomLeftCorners()
>>> print bl[0]
SUMMARY
This method returns the bottom right corner of each feature’s bounding box.
RETURNS
A numpy array of x,y position values.
EXAMPLE
>>> img = Image("./sampleimages/EdgeTest1.png")
>>> blobs = img.findBlobs()
>>> br = img.bottomRightCorners()
>>> print br[0]
SUMMARY
Return a numpy array of the distance each features average color is from a given color tuple (default black, so colorDistance() returns intensity)
PARAMETERS
RETURNS
The distance of the average color for the feature from given color as a numpy array.
EXAMPLE
>>> img = Image("lenna")
>>> circs = img.findCircle()
>>> d = circs.colorDistance(color=Color.BLUE)
>>> print d
SUMMARY
Returns a 2d numpy array of the x,y coordinates of each feature. This is particularly useful if you want to use Scipy’s Spatial Distance module
RETURNS
A numpy array of all the positions in the featureset.
EXAMPLE
>>> img = Image("lenna")
>>> feats = img.findBlobs()
>>> xs = feats.coordinates()
>>> print xs
SUMMARY
Returns a nparray with the cropped features as SimpleCV image.
RETURNS
A SimpleCV image cropped to each image.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs(128)
>>> for b in blobs:
>>> newImg = b.crop()
>>> newImg.show()
>>> time.sleep(1)
SUMMARY
Returns a numpy array of the distance each Feature is from a given coordinate. Default is the center of the image.
PARAMETERS
RETURNS
A numpy array of distance values.
EXAMPLE
>>> img = Image("lenna")
>>> feats = img.findBlobs()
>>> d = feats.distanceFrom()
>>> d[0] #show the 0th blobs distance to the center.
TO DO
Make this accept other features to measure from.
SUMMARY
Returns the square-form of pairwise distances for the featureset. The resulting N x N array can be used to quickly look up distances between features.
RETURNS
A NxN np matrix of distance values.
EXAMPLE
>>> img = Image("lenna")
>>> feats = img.findBlobs()
>>> d = feats.distancePairs()
>>> print d
SUMMARY
Call the draw() method on each feature in the FeatureSet.
PARAMETERS
RETURNS
Nada. Nothing. Zilch.
EXAMPLE
>>> img = Image("lenna")
>>> feats = img.findBlobs()
>>> feats.draw(color=Color.PUCE, width=3)
>>> img.show()
SUMMARY
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.
PARAMETERS
RETURNS
The revised feature set.
EXAMPLE
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
Returns a nparray which is the height of all the objects in the FeatureSet
RETURNS
A numpy array of width values.
EXAMPLE
>>> img = Image("NotLenna")
>>> l = img.findLines()
>>> l.height()
SUMMARY
Return only the features inside the region. where region can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a featureset of features that are inside the region.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[-1]
>>> lines = img.findLines()
>>> inside = lines.inside(b)
NOTE
This currently performs a bounding box test, not a full polygon test for speed.
SUMMARY
Return only the features left of the region. where region can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a featureset of features that are left of the region.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[-1]
>>> lines = img.findLines()
>>> left = lines.left(b)
NOTE
This currently performs a bounding box test, not a full polygon test for speed.
SUMMARY
Return a numpy array of the length (longest dimension) of each feature.
RETURNS
A numpy array of the length, in pixels, of eatch feature object.
EXAMPLE
>>> img = Image("Lenna")
>>> l = img.findLines()
>>> lengt = l.length()
>>> lengt[0] # length of the 0th element.
SUMMARY
Return a numpy array of the average color of the area covered by each Feature.
RETURNS
Returns an array of RGB triplets the correspond to the mean color of the feature.
EXAMPLE
>>> img = Image("lenna")
>>> kp = img.findKeypoints()
>>> c = kp.meanColor()
SUMMARY
The method returns a feature set of features that are not on or “near” the edge of the image. This is really helpful for removing features that are edge effects.
PARAMETERS
RETURNS
Returns a featureset of features that are not on the edge of the image.
EXAMPLE
>>> img = Image("./sampleimages/EdgeTest1.png")
>>> blobs = img.findBlobs()
>>> es = blobs.notOnImageEdge()
>>> es.draw(color=Color.RED)
>>> img.show()
SUMMARY
The method returns a feature set of features that are on or “near” the edge of the image. This is really helpful for removing features that are edge effects.
PARAMETERS
RETURNS
Returns a featureset of features that are on the edge of the image.
EXAMPLE
>>> img = Image("./sampleimages/EdgeTest1.png")
>>> blobs = img.findBlobs()
>>> es = blobs.onImageEdge()
>>> es.draw(color=Color.RED)
>>> img.show()
SUMMARY
Return only the features outside the region. where region can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a featureset of features that are outside the region.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[-1]
>>> lines = img.findLines()
>>> outside = lines.outside(b)
NOTE
This currently performs a bounding box test, not a full polygon test for speed.
SUMMARY
Return only the features that overlap or the region. Where region can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a featureset of features that overlap the region.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[-1]
>>> lines = img.findLines()
>>> outside = lines.overlaps(b)
NOTE
This currently performs a bounding box test, not a full polygon test for speed.
SUMMARY
Return only the features right of the region. where region can be a bounding box, bounding circle, a list of tuples in a closed polygon, or any other featutres.
PARAMETERS
RETURNS
Returns a featureset of features that are right of the region.
EXAMPLE
>>> img = Image("Lenna")
>>> blobs = img.findBlobs()
>>> b = blobs[-1]
>>> lines = img.findLines()
>>> right = lines.right(b)
NOTE
This currently performs a bounding box test, not a full polygon test for speed.
EXAMPLE
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:
PARAMETERS
RETURNS
Nada. Nothing. Zilch.
EXAMPLE >>> img = Image(“logo”) >>> feat = img.findBlobs() >>> if feat: feat.draw() >>> img.show()
Return a sorted FeatureSet with the features closest to a given angle first. Note that theta is given in radians, with 0 being horizontal.
RETURNS
An array of angle values corresponding to the features.
EXAMPLE
>>> img = Image("lenna")
>>> l = img.findLines()
>>> l = l.sortAngle()
>>> print angs
SUMMARY
Returns a new FeatureSet, with the largest area features first.
RETURNS
A featureset sorted based on area.
EXAMPLE
>>> img = Image("lenna")
>>> feats = img.findBlobs()
>>> feats = feats.sortArea()
>>> print feats[-1] # biggest blob
>>> print feats[0] # smallest blob
Return a sorted FeatureSet with features closest to a given color first. Default is black, so sortColorDistance() will return darkest to brightest
SUMMARY
Returns a sorted FeatureSet with the features closest to a given coordinate first. Default is from the center of the image.
PARAMETERS
RETURNS
A numpy array of distance values.
EXAMPLE
>>> img = Image("lenna")
>>> feats = img.findBlobs()
>>> d = feats.sortDistance()
>>> d[-1].show() #show the 0th blobs distance to the center.
SUMMARY
Return a sorted FeatureSet with the longest features first.
RETURNS
A sorted FeatureSet.
EXAMPLE
>>> img = Image("Lenna")
>>> l = img.findLines().sortLength()
>>> lengt[-1] # length of the 0th element.
SUMMARY
This method returns the top left corner of each feature’s bounding box.
RETURNS
A numpy array of x,y position values.
EXAMPLE
>>> img = Image("./sampleimages/EdgeTest1.png")
>>> blobs = img.findBlobs()
>>> tl = img.bottomLeftCorners()
>>> print tl[0]
SUMMARY
This method returns the top right corner of each feature’s bounding box.
RETURNS
A numpy array of x,y position values.
EXAMPLE
>>> img = Image("./sampleimages/EdgeTest1.png")
>>> blobs = img.findBlobs()
>>> tr = img.topRightCorners()
>>> print tr[0]
SUMMARY
Returns a nparray which is the width of all the objects in the FeatureSet.
RETURNS
A numpy array of width values.
EXAMPLE
>>> img = Image("NotLenna")
>>> l = img.findLines()
>>> l.width()
SUMMARY
Returns a numpy array of the x (horizontal) coordinate of each feature.
RETURNS
A numpy array.
EXAMPLE
>>> img = Image("lenna")
>>> feats = img.findBlobs()
>>> xs = feats.x()
>>> print xs
SUMMARY
Returns a numpy array of the y (vertical) coordinate of each feature.
RETURNS
A numpy array.
EXAMPLE
>>> img = Image("lenna")
>>> feats = img.findBlobs()
>>> xs = feats.y()
>>> print xs
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.
This method takes in an integral image and applies the haar-cascade to the image, and returns the result.
Set the name of this feature, the name must be unique.
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.
Write the Haar cascade to a human readable file. file is an open file pointer.
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
This extractor takes in an image, creates the integral image, applies the Haar cascades, and returns the result as a feature vector.
This method gives the names of each field in the feature vector in the order in which they are returned. For example, ‘xpos’ or ‘width’
This method returns the total number of fields in the feature vector.
fname = file name nfeats = number of features to load from file -1 -> All features
Save wavelets to file
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.
This feature extractor takes in a color image and returns a normalized color histogram of the pixel counts of each hue.
This method gives the names of each field in the feature vector in the order in which they are returned. For example, ‘xpos’ or ‘width’
This method returns the total number of fields in the feature vector.
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.
This method takes in a image and returns some basic morphology characteristics about the largest blob in the image. The if a color image is provided the threshold operation is applied.
This method gives the names of each field in the feature vector in the order in which they are returned. For example, ‘xpos’ or ‘width’
This method returns the total number of fields in the feature vector.
The threshold operation is a function of the form binaryimg = threshold(img)
Example:
>>> def binarize_wrap(img):
>>> return img.binarize()