How to compare bounding box coordinates?
조회 수: 7 (최근 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
참고 항목
카테고리
Help Center 및 File Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!