
How to use houghlines to detect the barcode lines
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How can I detect the lines using houghline or other hough function in Matlab??

0 commentaires
Réponse acceptée
Chandra Kurniawan
le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!