How to compare bounding box coordinates?
12 次查看(过去 30 天)
显示 更早的评论
I have a number of bounding boxes for one greyimage, with one box for each connected component in the image. I need to figure out whichever boxes do not overlap with the rest and remove those pixels from the image.
For that, I want to be able to compare if there are overlaps between the bounding boxes, by comparing the corner coordinates or by using any function that can figure out any bit of overlap with other bounding boxes. After that, I need to set all the pixels in the boxes that do not overlap with any other to be black.
I need help with comparing and keeping track of the boxes and finally making the changes to the original image, before cropping into connected components.
Thank you very much in advance for your help! Any bit of help is very much appreciated! (:
0 个评论
回答(3 个)
Image Analyst
2012-11-2
Tell me what the next step is, because I don't see why this strange thing would be necessary. I have never done that and I analyze regions all the time. Tell me what you really want to do and I'll tell you how to do it and most likely erasing blobs with non-overlapping bounding boxes won't be necessary. Upload your image to assist in your description.
0 个评论
Matt J
2012-11-2
Suppose that V1 contains the vertices of box 1 and V2 contains the vertices of box 2. If the following lines return an empty "result", then the boxes do not overlap. Otherwise, they do.
[A1,b1]=vert2lcon(V1);
[A2,b2]=vert2lcon(V2);
result=lcon2vert([A1;A2],[b1;b2]);
7 个评论
Image Analyst
2012-11-4
How do you have the bounding box for the A? If you do, then you must have labeled it. But then there are other small regions inside the A, and those would also have labels and bounding boxes. And of course there is the large triangle in the A which would be its own region. Plus it looks like you may have breaks in the edges, so that the A may really be 2 or 3 or 4 regions, not just one, and would thus have bounding boxes that don't enclose the whole A. But let's just assume you didn't have any of those problems. Let's assume you had a nice A that had contiguous, non-broken outlines and you did an imfill on it so that you had a solid region with just one bounding box. Again, it's labeled so all you need to do is to extract that one label from the image using ismember(). That would get rid of any regions with a different label number that intruded into the bounding box of the A. So I'm glad you explained the situation because now we can see that what you thought you wanted to do is actually not necessary at all. You can do it easily and simply with ismember() and not have to worry at all with binary images or inspecting corner coordinates.
By the way, I don't really think finding edges to identify characters is the way to go. I think a background flattening followed by thresholding would be the way to go, but I'm not really familiar with OCR methods and if edge finding is a required step in some successful pubished method that you have seen, then maybe it's alright, though it seems fraught with additional problems that thresholding would not have (internal outlines, broken outlines, etc.).
Stalin Sabu Thomas
2018-10-20
ratio = bboxOverlapRatio(bbox1, bbox2)
This can actually give you a matrix which shows how much overlap exists between a pair of bboxes. Take a look at their documentation https://in.mathworks.com/help/vision/ref/bboxoverlapratio.html
I wasn't able to understand your objective completely but I am sure this is the answer.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!