How do I cut individual letters in the image bar code?

1 次查看(过去 30 天)
I have a code 39 barcode image.
Because each character is encoded by a Code 39 total of 9 elements. In which five black bars and 4 spaces, 3 of 9 elements with large width (2 large black bars and a big blank) 6 remaining elements have small widths (narrow (except 4 characters $, /, +% have three large white lines). I want to extract characters from the original bar code of the individual characters.
My images was taken on the binary image, 0 is black bars, 1 is white bars
I use the following command to cut the first letter
for j=1:n,
if (I(:,j)==0)&(I(:,j+1)==1)
s=s+1;
if s==5
C0 =I(:,1:j+2);
C0a=imresize(C0,[49 50]);
imwrite(C0a,'Tapanh\1.bmp');
s=0;
t=j+2;
break;
end
end
end
I want to use the loop to cut each letter next to the end. Please help me. This is my sample image and images need to be cut http://s1213.photobucket.com/albums/cc477/bluesrose/barcode/ please help me

回答(1 个)

Sean de Wolski
Sean de Wolski 2011-5-18
Use bwconncomp to group objects and then use regionprops with the 'image' option. Each image in the output from regionprops will be a an image of that object (letters & bars).

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by