Extraction D.m Code
From SoftwarePractice.org
% Read in the barcode image
II= imread('example13.jpg');
% change the image in to gray scale
I = rgb2gray(II);
figure(1), imshow(I), title('original image');
% find the threshold value usong edge function
[junk threshold] = edge(I, 'sobel');
fudgeFactor = .5;
BWs = edge(I,'sobel', threshold * fudgeFactor );
figure(2), imshow(BWs), title('binary gradient mask');
se90 = strel('line', 3, 90);
se0 = strel('line', 3, 0);
BWsdil = imdilate(BWs, [se90 se0]);
figure(3), imshow(BWsdil), title('dilated gradient mask');
BWdfill = imfill(BWs, 'holes');
figure(4), imshow(BWdfill);
title('binary image with filled holes');
% BW=im2bw(II);
% NHOOD = getnhood(BW);
% MN =[6,20];
seD = strel('rectangle',20,90); %MN
BWfinal = imerode(BWs,seD); %dfill,seD);
% BWfinal = imerode(BWfinal,seD);
figure(5), imshow(BWfinal), title('segmented image');
BWoutline = bwperim(BWfinal);
Segout = I;
Segout(BWoutline) = 180;
figure(6), imshow(Segout), title('outlined original image');
Back to Barcode Image Recognition
