- 209
- 0
- 约3.11千字
- 约 5页
- 2019-06-28 发布于江西
- 举报
2014年1月4日
图像倾斜校正_基于MATLAB
目的:
实现对图像的倾斜校正。
方法一:
利用霍夫变换,代码如下:
clear,clc,close all;
I=imread(1.jpg);
bw=rgb2gray(I);
bw=im2bw(I,graythresh(bw));
bw=double(bw);
BW=edge(bw,canny);
imshow(BW);title(canny 边界图像);
[H,T,R]=hough(BW);
figure,imshow(H,[],XData,T,YData,R,InitialMagnification,fit);
xlabel(\theta),ylabel(\rho);
axis on, axis normal,hold on;
P=houghpeaks(H,4,threshold,ceil(0.3*max(H(:))));
x=T(P(:,2)); y = R(P(:,1));
plot(x,y,s,color,white);
lines=houghlines(BW,T,R,P,FillGap,50,MinLength,7);
figure,imshow(BW),title(直线标识图像);
max_len = 0;
hold on;
for k=1:length(lines)
xy=[lines(k).point1;
原创力文档

文档评论(0)