필터 지우기
필터 지우기

how can change the angle of image ?

조회 수: 4 (최근 30일)
M.aM
M.aM 2012년 7월 27일
Hi everyone I have image I want change the angle of this image to be horizontal how can I do it? Thank you

답변 (2개)

Thomas
Thomas 2012년 7월 27일
something like this? Based on the method shown here: http://stackoverflow.com/questions/5770818/how-to-align-image-matlab
I = imread('http://up.arab-x.com/Apr12/Yen90992.jpg');
%# egde detection
BW = edge(rgb2gray(I), 'canny');
%# hough transform
[H T R] = hough(BW);
P = houghpeaks(H, 4, 'threshold',ceil(0.75*max(H(:))));
lines = houghlines(BW, T, R, P);
out = imrotate(I,lines(1).theta);
subplot(121)
imshow(I)
subplot(122)
imshow(out)

Image Analyst
Image Analyst 2012년 7월 27일
Perhaps imrotate() or imtransform()?
  댓글 수: 2
M.aM
M.aM 2012년 7월 27일
Yep I used this but what if I want rote the image with out known the angle Thanks Image Analyst :)
Ryan
Ryan 2012년 7월 27일
편집: Ryan 2012년 7월 27일
I would tackle it with this strategy:
  1. Find the top-most black pixel (in this case your upper left corner).
  2. Find the right-most black pixel (in this case your upper right corner).
  3. Use the change in width and height, along with trig to find the angle of rotation (it's like a triangle)
This strategy can be adapted to handle rotation the other way as well, but will not work past an 89 degree rotation in either direction.

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

Community Treasure Hunt

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

Start Hunting!

Translated by