我需要知道如何在Matlab中对齐图像以进行进一步处理。
例如,我有下面的车牌图片,我想识别所有数字。
我的程序只适用于直的图片,因此我需要对图像进行对齐,然后进行光学识别系统。
该方法应尽可能通用,适用于所有类型的车牌和各种角度。
编辑:我尝试使用Hough变换,但没有成功。 有人能帮我做这个吗?
非常感谢任何帮助。
我需要知道如何在Matlab中对齐图像以进行进一步处理。
例如,我有下面的车牌图片,我想识别所有数字。
我的程序只适用于直的图片,因此我需要对图像进行对齐,然后进行光学识别系统。
该方法应尽可能通用,适用于所有类型的车牌和各种角度。
编辑:我尝试使用Hough变换,但没有成功。 有人能帮我做这个吗?
非常感谢任何帮助。
%# read and crop image
I = imread('http://i.stack.imgur.com/CJHaA.png');
I = I(:,1:end-3,:); %# remove small white band on the side
%# 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);
%# shearing transforma
slopes = vertcat(lines.point2) - vertcat(lines.point1);
slopes = slopes(:,2) ./ slopes(:,1);
TFORM = maketform('affine', [1 -slopes(1) 0 ; 0 1 0 ; 0 0 1]);
II = imtransform(I, TFORM);
%# show edges
figure, imshow(BW)
%# show accumlation matrix and peaks
figure, imshow(imadjust(mat2gray(H)), [], 'XData',T, 'YData',R, 'InitialMagnification','fit')
xlabel('\theta (degrees)'), ylabel('\rho'), colormap(hot), colorbar
hold on, plot(T(P(:,2)), R(P(:,1)), 'gs', 'LineWidth',2), hold off
axis on, axis normal
%# show image with lines overlayed, and the aligned/rotated image
figure
subplot(121), imshow(I), hold on
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1), xy(:,2), 'g.-', 'LineWidth',2);
end, hold off
subplot(122), imshow(II)
如果您正在使用某种文本识别的机器学习工具箱,请尝试从所有车牌中学习 - 不仅仅是对齐的车牌。如果您进行了转换,则识别结果应该同样好,因为转换不会增强图像中关于真实号码的新信息。