how to find the corners of an irregular binary shape

조회 수: 4 (최근 30일)
Dhandapani.S
Dhandapani.S 2015년 1월 6일
댓글: Image Analyst 2017년 11월 29일
my work is irregular shape (image) matching. i have to extract the points( topleftmost, top right most, the same ay botom. i have to draw a line from top left to bottom right. again a line from top right to bottom left. i have to find the angle between two lines.

채택된 답변

Image Analyst
Image Analyst 2015년 1월 6일
Usually when people ask for image processing advice, they attach an image. I'd guess that you can just find all the rows and columns and take the min and max.
[rows, columns] = find(binaryImage);
topRow = min(rows);
bottomRow = max(rows);
leftColumn = min(columns);
rightColumn = max(columns);
% Draw horizontal lines at top and bottom.
line([leftColumn, rightColumn], [topLine, topLine], 'Color', 'y', 'LineWidth', 3);
line([leftColumn, rightColumn], [bottomRow, bottomRow], 'Color', 'y', 'LineWidth', 3);
Another way is to get the vertical and horizontal profiles and use find() to find the first and last non-zero elements. Not sure which is faster - you can try them both.
  댓글 수: 7
Marlon Damaceno
Marlon Damaceno 2017년 11월 29일
in the above example two diagonal lines were drawn in the image, how do you insert a vertical and a horizontal one passing through the center of the image?
Image Analyst
Image Analyst 2017년 11월 29일
You can write into the image like
grayImage(:, 32) = 255; % Draw white line at column 32
or just use plot() to plot into the overlay.

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by