Ask Your Question
1

How to filter a shape from a binary image

asked 2012-11-28 13:06:46 -0600

icedecker gravatar image

updated 2012-11-28 15:38:13 -0600

Hi, I would like to try the following task. I have a binary image like as:

image description

And the desired output would be the following:

image description

I have tried using Hough circle detection, but it is not accurate, because of the shape. It is possible to use a custom morphological operation? I tried with ellipse and rectangular kernel shape, but without success. Any ideas?

Thanks!

edit retag flag offensive close merge delete

4 answers

Sort by » oldest newest most voted
1

answered 2012-11-29 02:37:04 -0600

AMP gravatar image

I think squares.cpp(or squares.py) in samples folder can help you.

you can change some parts of the code and detect any simple objects (like square,circle,triangle...)

edit flag offensive delete link more

Comments

I've tried to use and change the code, but it not work. I need to think in good constraints to detect the shape. Anyway, thanks for the suggestion.

icedecker gravatar imageicedecker ( 2012-11-29 03:48:56 -0600 )edit
sturkmen gravatar imagesturkmen ( 2016-05-20 22:58:49 -0600 )edit
1

answered 2012-11-29 02:28:38 -0600

elmiguelao gravatar image

You could try matching a shape you know against the global image (link to opencv documentation on matchShapes). It works solidly and fast and will work with scaling but not with rotations or perspective transformations.

This q&a can give you pointers to more sophisticated comparisons.

edit flag offensive delete link more

Comments

Thanks, I will try it.

icedecker gravatar imageicedecker ( 2012-11-29 03:45:57 -0600 )edit

Well, the matchShapes only works with images of the same size, it could be complicated. I will try the stuff in the q&a you provided.

icedecker gravatar imageicedecker ( 2012-11-29 04:33:20 -0600 )edit
0

answered 2012-11-29 07:25:31 -0600

Geppertm gravatar image

Think it works, need some finetunning! image description

edit flag offensive delete link more

Comments

Nice suggestion, I will test it and report later. Thanks!

icedecker gravatar imageicedecker ( 2012-11-29 09:09:28 -0600 )edit

Any reports?

Geppertm gravatar imageGeppertm ( 2012-12-03 02:19:29 -0600 )edit

Well, I'm still tweaking it. But at the moment, it is not working. Anyway, thanks for your suggestion!

icedecker gravatar imageicedecker ( 2012-12-06 12:37:29 -0600 )edit
0

answered 2012-11-29 05:00:04 -0600

Geppertm gravatar image

My suggestion is to use BRISK and FREAK. I use this for Objectdetection an it works fine. In the OpenCV FREAK Example the use the Surfdetector but this doesn´t give me good Matches. But you should try it with the binary images. Hope this helps.

std::vector<keypoint> keypointsA, keypointsB;

Mat descriptorsA, descriptorsB;

std::vector<dmatch> matches;

BRISK detector(30,9,1.0F);

FREAK extractor;

BFMatcher matcher(NORM_HAMMING,false);

detector.detect( imgA, keypointsA );

extractor.compute( imgA, keypointsA, descriptorsA );

detector.detect( imgB, keypointsB );

extractor.compute( imgB, keypointsB, descriptorsB );

matcher.knnMatch(descriptorsA, descriptorsB, matches, 2);

drawMatches(imgAs, keypointsA, imgB, keypointsB, good_matches, imgMatch);

edit flag offensive delete link more

Comments

1

For this task I would not recommend this approach at all. Local features work well with structured/textured objects only.

SR gravatar imageSR ( 2012-11-29 05:22:08 -0600 )edit

The binary image I provided is a very simple example, because I will work with shape a bit complex. Usually this is not a good way to use in binary images, but I will try anyway.

icedecker gravatar imageicedecker ( 2012-11-29 09:11:17 -0600 )edit

@Geppertm: I see your point. But from the original question I would not have been guessed that this is a setting where local feature would be appropriate. Btw, you should merge your two answers to make clear that they are linked.

SR gravatar imageSR ( 2012-12-03 21:30:29 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-11-28 13:06:46 -0600

Seen: 2,129 times

Last updated: Nov 29 '12