function lines = houghlines(f,theta,rho,rr,cc,fillgap,minlength)
%HOUGHLINES Extract line segments based on the Hough transform.
% LINES = HOUGHLINES(F, THETA, RHO, RR, CC, FILLGAP, MINLENGTH)
% extracts line segments in the image F associated with particular
% bins in a Hough transform. THETA and RHO are vectors returned by
% function HOUGH. Vectors RR and CC specify the rows and columns
% of the Hough transform bins to use in searching for line
% segments. If HOUGHLINES finds two line segments associated with
% the same Hough transform bin that are separated by less than
% FILLGAP pixels, HOUGHLINES merges them into a single line
% segment. FILLGAP defaults to 20 if omitted. Merged line
% segments less than MINLENGTH pixels long are discarded.
% MINLENGTH defaults to 40 if omitted.
%
% LINES is a structure array whose length equals the number of
% merged line segments found. Each element of the structure array
% has these fields:
%
% point1 End-point of the line segment; two-element vector
% point2 End-point of the line segment; two-element vector
% length Distance between point1 and point2
% theta Angle (in degrees) of the Hough transform bin
% rho Rho-axis position of the Hough transform bin
% Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins
% Digital Image Processing Using MATLAB, Prentice-Hall, 2004
% $Revision: 1.4 $ $Date: 2003/10/26 22:34:10 $
if nargin < 6
fillgap = 20;
end
if nargin < 7
minlength = 40;
end
numlines = 0; lines = struct;
for k = 1:length(rr)
rbin = rr(k); cbin = cc(k);
% Get all pixels associated with Hough transform cell.
[r, c] = houghpixels(f, theta, rho, rbin, cbin);
if isempty(r)
continue
end
% Rotate the pixel locations about (1,1) so that they lie
% approximately along a vertical line.
omega = (90 - theta(cbin)) * pi / 180;
T = [cos(omega) sin(omega); -sin(omega) cos(omega)];
xy = [r - 1 c - 1] * T;
x = sort(xy(:,1));
% Find the gaps larger than the threshold.
diff_x = [diff(x); Inf];
idx = [0; find(diff_x > fillgap)];
for p = 1:length(idx) - 1
x1 = x(idx(p) + 1); x2 = x(idx(p + 1));
linelength = x2 - x1;
if linelength >= minlength
point1 = [x1 rho(rbin)]; point2 = [x2 rho(rbin)];
% Rotate the end-point locations back to the original
% angle.
Tinv = inv(T);
point1 = point1 * Tinv; point2 = point2 * Tinv;
numlines = numlines + 1;
lines(numlines).point1 = point1 + 1;
lines(numlines).point2 = point2 + 1;
lines(numlines).length = linelength;
lines(numlines).theta = theta(cbin);
lines(numlines).rho = rho(rbin);
end
end
end
此程序实现用Hough变换和数学形态学变换对二值车牌图像进行水平倾斜校正
需积分: 50 108 浏览量
2018-11-13
11:52:26
上传
评论 2
收藏 6KB RAR 举报
yizhou1995
- 粉丝: 9
- 资源: 2
最新资源
- 基于ARIMAX的多变量预测模型python源码+数据集释.zip
- 华为od-华为od练习题之矩阵乘法-题库题解.zip
- 1___UNI__C395E23__20230608193024.apk.1
- 电子通信设计资料抗干扰红外发射接收一体DXP资料及其相关资料
- 华为od-华为od练习题之成绩排序-题库题解.zip
- Python实现SSA-LSTM麻雀搜索算法优化长短期记忆神经网络时间序列预测(完整源码和数据)
- 基于python的足球运动员数据分析源码+数据集.zip
- 华为od-华为od练习题之24点游戏-题库题解.zip
- 电子通信设计资料矩阵键盘DXP资料及其相关资料
- classic-benchmarks-x86.tar.gz
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈