How to know a square object's orientation?

3 ビュー (過去 30 日間)
Ingrid Lopes
Ingrid Lopes 2020 年 4 月 18 日
コメント済み: Ingrid Lopes 2020 年 4 月 18 日
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?

採用された回答

Image Analyst
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.
  1 件のコメント
Ingrid Lopes
Ingrid Lopes 2020 年 4 月 18 日
Hi thanks for the answer. I got it a while ago.
I used two filter, one to find lines at a 45º and the other for lines at -45º. with those i found the boundaries from the rectangles that were rotated and with an if I rotated the objets that the mask from the two filters had nnz higher than 50. It worked thank god xD
But thanks for answering me anyway =)

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by