Ask Your Question

How do I find lines which overlap blobs?

asked 2013-03-31 13:06:43 -0500

zorlack gravatar image

updated 2013-03-31 14:15:46 -0500

I have an image which I've binarized and done findBlobs and findLines.

When I render the blobs, it looks like this:


When I render the lines, it looks like this:


I'm interested in finding out which lines overlap my blobs, but I can't seem to figure out how to do this:

imgBin = img.binarize(binarizeThreshold).invert()
blobs = imgBin.findBlobs(maxsize=maxBlobArea)
lines = imgBin.findLines()
horizontalLines = lines.filter(abs(lines.angle()) < numpy.pi / 8)
for line in horizontalLines:
    print "Line " + str(lineCounter)
    for blob in blobs:
        if line.overlaps(blob):
            print "overlap"
            blob.draw(color=Color.Yellow, width=-1)

Not only does this method not seem to work (it never prints "overlap"), but it seems pretty inefficient.

Am I going about this wrong?

Does line.overlap() work with blobs?

Thanks so much!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-04-01 18:01:55 -0500

kscottz gravatar image

updated 2013-04-01 18:02:23 -0500

I noticed a bug with the overlap method the other day. The short answer is that we really need to do some refactoring so that we catch all of the potential cases of features overlapping and handle them appropriately. Part of doing this right is the efficiency aspect of the calculation, for a lot of instances you don't need the full blob contour computation, and a simple bounding box will suffice. I've filed a ticket to deal with this issue, but I don't have the time to fix it right now.

If you don't need super high precision I would look into using the blob's bounding box, and the line's end points and use something like this algorithm.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-03-31 13:06:43 -0500

Seen: 468 times

Last updated: Apr 01 '13