find overlapping rectangles algorithm in matlab
Show older comments

Hi
Is there an algorithm which can help in finding overlapping rectangles.
I use connected components for segmentation and hecne get a number of overlapping and independent rectangles. My aim is to remove the overlapping rectangles by checking the coordinates . If my current rectangle falls within the coordinate of outer rectangle then it will consider the outer rectangle and if my rectangle is bigger then it is considered.
i want to retain all bigger rectangles around a word and eliminate smaller rectangles.
is there a code for finding overlapping rectangles?
groupRect = [lv tv new_width new_height];
groupRects(groupRectsCt,:)=groupRect;
groupRectsCt=groupRectsCt+1;
end
id = id+1;
end
% display the segmented image
figure, imshow(SearchedImg);
for i=1:groupRectsCt-1
rectangle('Position', groupRects(i,:), 'EdgeColor', 'r');
end
%%%find and remove overlaping regions
for i=1:groupRectsCt-1
if(currentRect(1,1)>=cRect(1,1) & currentRect(1,1)+currentRect(1,3)<=cRect(1,1)+cRect(1,3))
flag =1; break;
end
if(currentRect(1,1)<=cRect(1,1) & currentRect(1,1)+currentRect(1,3)>=cRect(1,1)+cRect(1,3))
candiRect(j,:) = currentRect; flag =1; break;
end
if(flag) continue; end
candiRect(candiCt,:) = currentRect;
end
4 Comments
Image Analyst
on 13 Jul 2015
My advice is to attach an image or diagram so we can visualize what you're talking about.
A binary or labeled image cannot have overlapping regions. If regions in a binary image overlap, then they are considered the same region, not different ones. If regions in a labeled image overlap, then the "top" one overlaps/covers the "underneath" one and so not all of the underneath one will be used in measurements. So I really don't know what you're talking about without a diagram or image to help explain it.
Image Analyst
on 13 Jul 2015
Why do you need to find them? Something (I don't know what) created the rectangles, so you just need to go back to the function that made them in the first place to "find" them.
Answers (0)
Categories
Find more on Image Segmentation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!