How to use houghlines to detect the barcode lines
1 回表示 (過去 30 日間)
古いコメントを表示
How can I detect the lines using houghline or other hough function in Matlab??
0 件のコメント
採用された回答
Chandra Kurniawan
2012 年 1 月 13 日
Hi,
First, sorry for changing your tif image into jpg format.
Here, I have the code to perform line detection.
I = imread('15d27ap.jpg');
Igray = rgb2gray(I);
Ibw = ~im2bw(Igray,graythresh(Igray));
Iskel = bwmorph(Ibw,'thin',inf);
%%%%radon tranform
[R xp] = radon(Iskel,0:1:360);
[II JJ] = find(R >= (max(max(R)) * 0.75));
imshow(Ibw); hold on;
for k = 1 : size(II,1)
R_i = (JJ(k) - 1) * 1;
xp_i = xp(II(k));
x_origin = size(Iskel,2) / 2 + (xp_i) * cos(R_i * pi / 180);
y_origin = size(Iskel,1) / 2 - (xp_i) * sin(R_i * pi / 180);
y1 = (y_origin - (1 - x_origin) * tan(((R_i) - 90) * pi / 180));
ye = (y_origin - (size(Iskel,2) - x_origin) * tan(((R_i) - 90) * pi / 180));
line([1 size(Iskel,2)], [y1 ye],'color','g');
end
The result :
I think my code just detect the lines.
In other word, we only know the starting and end point of each lines.
I hope this helps you.
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!