Detect all the rectangles in image

조회 수: 28 (최근 30일)
simon xu
simon xu 2019년 2월 18일
댓글: islam elsayed 2020년 6월 11일
Hey all,
in the following image, all the rectangles are a little bit deformed due to power leakage effect. I want to detect all the rectangles and obtain the positions of the rectangles.
Is there a way to detect all rectangles?
Thank you

채택된 답변

Image Analyst
Image Analyst 2019년 2월 18일
It's trivial. Just use regionprops(). See my Image Segmentation Tutorial
  댓글 수: 9
Image Analyst
Image Analyst 2019년 2월 20일
How about you just compute the centroid, even with the tails, then take a vertical and horizontal line through the centroid and use find() to find the top and bottom lines and left and right columns of the rectangle?
simon xu
simon xu 2019년 2월 22일
How to binarize the grayscale image in the attached grayscale.mat file?
My goal is binarizing the grayscale image to get the rectangles and get rid of noise.
Thank you very much!

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

추가 답변 (1개)

KSSV
KSSV 2019년 2월 18일
I = imread('myImage.jpeg') ;
[y,x] = find(I>50) ;
imshow(I)
hold on
idx = kmeans([x y],4) ;
for i = 1:4
plot(x(idx==i),y(idx==i),'.')
% GEt L and B of rectangles
x0 = min(x(idx==i)) ; x1 = max(x(idx==i)) ;
y0 = min(y(idx==i)) ; y1 = max(y(idx==i)) ;
%
L = x1-x0 ;
B = y1-y0 ;
coor = [x0 y0 ; x0 y1 ; x1 y1 ; x1 y0] ;
patch(coor(:,1),coor(:,2),rand(1,3))
end
  댓글 수: 3
islam elsayed
islam elsayed 2020년 6월 11일
can you please explain in brief
islam elsayed
islam elsayed 2020년 6월 11일
@ KSSV

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

Community Treasure Hunt

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

Start Hunting!

Translated by