【问题标题】:How to rotate the image so that the barcode horizontal?? - MATLAB如何旋转图像使条码水平? - MATLAB
【发布时间】:2023-03-31 14:38:01
【问题描述】:

如何使用条形码旋转图像以确定角度的位置并根据使其水平旋转。我使用了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);

【问题讨论】:

    标签: image matlab rotation hough-transform


    【解决方案1】:

    您需要先检测线条。对于线路检测,您可以使用Hough transform

    【讨论】:

    • 那段代码怎么写??我花了几个星期阅读它并尝试了代码,但它不起作用!
    • 您需要更具体。你试过什么?它怎么不起作用?
    • @Kim 你不会得到这样的有用答案。您至少应该尝试一下或告诉我们您的问题到底在哪里。此外,我想,互联网上已经有很多解决方案。所以请至少使用谷歌或搜索matlab文件交换:)
    • 我试过Detecting Lines Using the Hough Transform,但它只能检测到某些特定的行而不是全部,然后我尝试修改代码以检测这些行,结果不是我想要的,我也不知道如何让程序知道那是条码。
    • 您需要熟悉一些图像处理和识别基础知识并提出具体问题或使用一些预制库来读取条形码。第一步可能是搜索条形码(黑白,高对比度),然后检测角度和解码。这是很多工作。未经我自己测试,您链接的图像分辨率太低且模糊,因此即使使用适当的商业软件也很难读取该条形码。
    猜你喜欢
    • 1970-01-01
    • 2013-12-11
    • 1970-01-01
    • 2018-12-22
    • 2017-12-26
    • 1970-01-01
    • 1970-01-01
    • 2018-01-20
    • 2017-03-07
    相关资源
    最近更新 更多