
How to use houghlines to detect the barcode lines
3 views (last 30 days)
Show older comments
How can I detect the lines using houghline or other hough function in Matlab??

0 Comments
Accepted Answer
Chandra Kurniawan
on 13 Jan 2012
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 Comments
More Answers (0)
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!