rotation matrix and regionprops

1 Ansicht (letzte 30 Tage)
michael scheinfeild
michael scheinfeild am 1 Okt. 2014
Kommentiert: Image Analyst am 1 Okt. 2014
hello i have some binary image i found the orientation and rotated the image
stats1 = regionprops(bw,'Orientation','Area');
bwRot=imrotate(bw,-stats1.Orientation);
after finding some interesting pixels i want to find their locations in the original image i create the matrix and try to rotate back but recive negative coordinates any help ,,
stats2 = regionprops(bwRot,'BoundingBox');
bx = stats2.BoundingBox;
xy = [ bx(1:2) ;
bx(1)+bx(3) ,bx(2);
bx(1)+bx(3) ,bx(2)+bx(4);
bx(1) ,bx(2)+bx(4);];
ct = cosd(stats1.Orientation);
st = sind(stats1.Orientation);
% rotation matrix
MatrxRotInv = [ct -st 0 ;
st ct 0;
0 0 1];
xyz = MatrxRotInv* [xy ones(4,1)]' ;
here the xy is negative why ?
  1 Kommentar
michael scheinfeild
michael scheinfeild am 1 Okt. 2014
also somthing strange i have image 640*480 newimage=imrotate(image,60) oldimage=imrotate(newimage,-60)
the oldimage size is not the same as image

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 1 Okt. 2014
Bearbeitet: Matt J am 1 Okt. 2014
You need to call imrotate with the 'crop' option to preserve the size of the input image.
As for the negative xy, it is possible for a rotation to bring points in/out of the image field of view. That's the whole reason why imrotate has the 'crop' option to begin with.
Be mindful as well that imrotate's origin of rotation is at the center of the image. However, the BoundingBox coordinates are relative to an origin at the upper left corner of the image.
  2 Kommentare
Matt J
Matt J am 1 Okt. 2014
michael scheinfeild Commented:
ok great !!! now after i found the bound box of the rotated shape how i can warp it back to normal rectange

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Geometric Transformation and Image Registration 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