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
#cv.cvSmooth(out, out, cv.CV_MEDIAN, 7, 7, 0) cv.cvSmooth(image, blurImage, cv.CV_BLUR, 3, 3, 0) #cv.cvSmooth(out, out, cv.CV_GAUSSIAN, 7, 7, 0) #out = blurImage # Superimpose the edges onto the blured image cv.cvNot(edges, edges) cv.cvCopy(blurImage, out, edges) # We're done with the blurred image now #cv.cvReleaseImage(blurImage) #print points[:0] cut = lines[1] margin = marginCalculator.getPixels(image, cut, 0.024) component_dictionary = featureDetector.ribbonFloodFill(image, edges, out, cut, margin, lo, up) #featureDetector.floodFillLine(image, out, points, cut, lo, up, {}) #flags = cv.CV_FLOODFILL_FIXED_RANGE #flags = 4 color = lib.getRandomColor() comp = cv.CvConnectedComp() #cv.cvFloodFill(out, cv.cvPoint(x,y), color, cv.CV_RGB(lo,lo,lo), cv.CV_RGB(up,up,up),comp ,flags)#, None); #lib.plot(out, cv.cvPoint(x,y), 3, lib.COL_RED) cv.cvLine(out, cut.p1, cut.p2, lib.COL_RED) lib.drawMargin(out, cut, margin) #startpoint = lines[0].getPoints()[0] #points.append(lines[0].getPoints()[1]) #for point in points: # out = floofill.floofill(out, lowerThres, upperThres, startpoint, point, 1)