How to know a square object's orientation?
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello, I have to scan several images of rectangles and rotate 45º only the ones that already have a 45º rotation. I tried to find the orientation using regionprops with Orientation, but it doesn't work, for the rectangles that were diagonaly placed I found all diferent types of values like 3.5 or -4.7 to -68. Anyone know how to discover the orientation of rectangles?
댓글 수: 0
채택된 답변
Image Analyst
2020년 4월 18일
Try getting the perimeter using bwboundaries() then using fitPolynomialRansac() (in the Computer Vision Toolbox) to get the equation of one of the sides.
boundaries = bwboundaries(binaryImage);
Then use regionprops() to find the centroid and bounding box
props = regionprops(binaryImage, 'BoundingBox', 'Centroid');
and crop it out and rotate it and paste it back in. I'm attaching copy and pasting image demos.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!