def analyzeCut(scaleImage, edgeImage, cut): """Extract the interesting features respecting the cut""" # Set up constraints constraints = regionSelector.Constraints(cv.cvGetSize(scaleImage), cut, margin, superMargin, 0.002, 0.25) # Create temporary images blurImage = cv.cvCreateImage(cv.cvGetSize(scaleImage), 8, 3) workImage = cv.cvCreateImage(cv.cvGetSize(scaleImage), 8, 3) # Create a blurred copy of the original cv.cvSmooth(scaleImage, blurImage, cv.CV_BLUR, 3, 3, 0) # Superimpose the edges onto the blured image cv.cvNot(edgeImage, edgeImage) cv.cvCopy(blurImage, workImage, edgeImage) # Get the edges back to white cv.cvNot(edgeImage, edgeImage) # We're done with the blurred image now cv.cvReleaseImage(blurImage) # Retrive the regions touching the cut component_dictionary = featureDetector.ribbonFloodFill(scaleImage, edgeImage, workImage, cut, margin, lo, up) # Clean up cv.cvReleaseImage(workImage) # Prune components newComponents = regionSelector.pruneRegions(component_dictionary, constraints) # Return the dictionary of accepted components #transformer.translateBoundingBoxes(newComponents, 1) return newComponents
out = highgui.cvLoadImage (filename) comp_dict = {} featureDetector.floodFillLine(image, out, points, cut, lo, up, comp_dict) # Set margin margin = 15 # Draw margin lib.drawMargin(out, cut, margin) # Set up constraints constraints = regionSelector.Constraints(cv.cvGetSize(image), cut, margin, 0.002, 0.25) # Prune components newComponents = regionSelector.pruneRegions(comp_dict, constraints) # Draw boxes of selected components #lib.drawBoundingBoxes(out, newComponents) # Get grids grid = grid.gridIt(out, newComponents, 5) for point in grid: lib.plot(image, point, 1) #lib.drawLines(out) winname = "Find regions" ======= out = edgeDetector.findEdges(image, threshold1, threshold2) print "Finding the golden means in the picture"