필터 지우기
필터 지우기

How to rotate image by using orientation regionprops?

조회 수: 3 (최근 30일)
Najwa Samlan
Najwa Samlan 2019년 10월 13일
댓글: Image Analyst 2019년 10월 14일
Hi. May I know how to rotate signature image by using orientation regionprops and then I want to display it at axis ? Below is my code
image1= getimage(handles.axes1)
bw1=imresize(image1,[128 256])
%binarization
bw1=im2double(bw1);
bw1 = im2bw(bw1,0.90);
%thinning
BW3=bwmorph(~bw1,'thin',0.9)
stats=regionprops(BW3,'Orientation','Centroid')
ori=[stats.Orientation]
c=stats.Centroid
x=c(1)+10*cosd(ori)
y=c(2)-10*sind(ori)
line([c(1) x],[c(2) y])
%display result at axes2
axes(handles.axes2)
imshow(BW3)

답변 (1개)

Image Analyst
Image Analyst 2019년 10월 13일
Try this
meanAngle = mean(ori)
BW3 = imrotate(BW3, -meanAngle);
  댓글 수: 2
Najwa Samlan
Najwa Samlan 2019년 10월 14일
I already try using your suggestion but the outcomes are not like what I want. The image do not rotate at the centre of x and y.
Image Analyst
Image Analyst 2019년 10월 14일
It rotates the image about the center of the image. If you don't want that, then maybe you can use imtranslate() before imrotate(), or else use the translation and rotation in your own matrix. See Wikipedia

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

Community Treasure Hunt

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

Start Hunting!

Translated by