Find Area of Intersecting rectangles

What would be the easiest and most efficient way to compute the intersecting area of vertical and horizontal intersecting rectangles.I have attached a image to explain the issue. Horizontal rectangles are in red Vertical rewctangles are in green Overlap area is marked in violet. Just to mention the horizontal and vertical rectangles can be of different size

댓글 수: 1

Image Analyst
Image Analyst 2015년 2월 23일
Exactly what data are you starting with? An RGB image just like this? Or a list of row and column numbers that define where the stripes are?

댓글을 달려면 로그인하십시오.

답변 (1개)

Joseph Cheng
Joseph Cheng 2015년 2월 23일

1 개 추천

This sounds like a simple math problem. Since you know the width of the vertical (lets call it widthV) and the width of the horizontal (widthH) then one of the intersection's area would be widthV*widthH. then if you know the number of vertical and horizontal rectangles (numV and numH) then the total number of intersections is numV*numH. so the total "purple" or intersection area is numV*numH*(widthV*widthH);

댓글 수: 3

Joseph Cheng
Joseph Cheng 2015년 2월 23일
편집: Joseph Cheng 2015년 2월 23일
if the horizontal and vertical rectangles can be varying sizes then this still can be applied just as the sum of the subset of known widths and lengths. Now the difficulties are if not all rectangles intersect (ie are shorter and go only partially down the image).
vivek
vivek 2015년 2월 23일
Just to mention the horizontal and vertical rectangles can be of different size.So finding area of intersection of one and multiplying by number of intersections will not work
Joseph Cheng
Joseph Cheng 2015년 2월 23일
How are the rectangles generated? are you reading in an image file, are you generating them? if it is an image then read in the first line and first column. Put a threshold (in either color or amplitude) and find X pixels above threshold in the vertical and Y pixels above threshold in the horizontal. then the total intersection is X*Y.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Color and Styling에 대해 자세히 알아보기

질문:

2015년 2월 23일

댓글:

2015년 2월 23일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by