필터 지우기
필터 지우기

rotation matrix and regionprops

조회 수: 1 (최근 30일)
michael scheinfeild
michael scheinfeild 2014년 10월 1일
댓글: Image Analyst 2014년 10월 1일
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
michael scheinfeild
michael scheinfeild 2014년 10월 1일
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

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

답변 (1개)

Matt J
Matt J 2014년 10월 1일
편집: Matt J 2014년 10월 1일
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
Matt J
Matt J 2014년 10월 1일
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

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

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by