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!