Filter löschen
Filter löschen

rotate an image segment without background

2 Ansichten (letzte 30 Tage)
Busy Bee
Busy Bee am 10 Feb. 2018
Bearbeitet: Matt J am 11 Feb. 2018
I have a BW image. I just want to rotate the polygon in the image. (The polygon rotates about its centroid.) But when I do, the background also rotates and more black pixels are added by default also the size of the polygon is changing. I want all the background as white. Any help is appreciated.
  1 Kommentar
Image Analyst
Image Analyst am 10 Feb. 2018
Do you already HAVE the centroid? If so, give it to us so we can give you the code. Otherwise imrotate() will just rotate around the center of the image, not around the center of the shape. If you don't have it, then use regionprops() to ask for it, and if you can't do that, let us know and we'll show you. And remember (x,y) equals (column, row), not (row, column).

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 10 Feb. 2018
Bearbeitet: Matt J am 11 Feb. 2018
Instead of performing the rotation on BW, apply it to ~BW. Then take the complement of that result,
result = ~rotationFunction(~BW, angle);

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by