1

如何使用条形码旋转图像以确定角度的位置并根据使其水平旋转。我用过Hough Transform,但我只能稍微向右旋转。

原始图像 旋转图像

rgb = imread('barcode10.jpg');
% Resize Image
rgb = imresize(rgb,0.33);
figure(),imshow(rgb);
% Convert from RGB to Gray
Igray = double(rgb2gray(rgb));
BW2 = edge(Igray,'canny');
figure(),imshow(BW2);
% Perform the Hough transform
[H, theta, rho] = hough(BW2);
 % Find the peak pt in the Hough transform
peak = houghpeaks(H);
 % Find the angle of the bars
barAngle = theta(peak(2));
J = imrotate(rgb,barAngle,'bilinear','crop');
figure(),imshow(J);
4

1 回答 1

1

您需要首先检测线条。对于线检测,您可以使用Hough 变换

于 2012-02-01T06:20:24.403 回答