Sei sulla pagina 1di 7

Barcode Reader System Using Image Processing

Matlab
Iwan Panjaitan
Zepanya Banjarnahor Willy Simangunsong
Department of Electrical Engineering
Department of Electrical Engineering Department of Electrical Engineering
Del Institute of Technology
Del Institute of Technology Del Institute of Technology
Laguboti, Sumatera Utara, Indonesia
Laguboti, Sumatera Utara, Indonesia Laguboti, Sumatera Utara, Indonesia
Abstract—This paper acquires code 39 barcode image from only the products themselves, but also outgoing
user, reads the barcode and outputs the result. The method to shipments and even equipment.
perform this operation is with image processing, in order to get
an enhanced image or to extract some information from it. It is 5. Inventory control improves. Because barcodes
a type of signal processing in which input is an image and make it possible to track inventory so precisely,
output may be image or characteristics/features associated inventory levels can be reduced. This translates into
with that image. This work proposes a method for the detection a lower overheard. The location of equipment can
and identification of code 39 barcode that will help in also be tracked, reducing the time spent searching
industrial field. This paper presents an approach based on for it, and the money spent replacing equipment that
simple but efficient morphological operation. This approach is is presumed lost.
simplified to segmented all the letters and numbers used in the
barcode by apply threshold method. After converting image in 6. Barcodes provide better data. Since one barcode can
to greyscale mode, apply threshold method to generate a be used for inventory and pricing information, it is
binary sequence so numbers and characters can be present in possible to quickly obtain data on both.
output, all information from the barcode can be used to Furthermore, barcodes can be customized to contain
industry field. other relevant information as needed. They provide
fast, reliable data for a wide variety of applications.
Keywords—code 39, threshold, binary
7. Data obtained through barcodes is available rapidly.
Since the information is scanned directly into the
I. INTRODUCTION central computer, it is ready almost instantaneously.
A barcode (also bar code) is an optical, machine- This quick turnaround ensures that time will not be
readable representation of data; the data usually describes wasted on data entry or retrieval.
something about the object that carries the barcode.
8. Barcodes promote better decision making. Because
Traditional barcodes systematically represent data by varying
data is obtained rapidly and accurately, it is possible
the widths and spacing of parallel lines, and may be referred
to make more informed decisions. Better decision
to as linear or one-dimensional (1D). Later, two-dimensional
making ultimately saves both time and money.
(2D) variants were developed, using rectangles,
dots, hexagons and other geometric patterns, called matrix In this modern world some of barcode usage we can found
codes or 2D barcodes, although they do not use bars as such. on:
Initially, barcodes were only scanned by special optical
scanners called barcode readers. Later application - Admission tickets in movie theaters, events, and
software became available for devices that could read travel
images, such as smartphones with cameras. Design program - Advertising
by using MATLAB and other suitable software on barcode
reading. The Image Processing Toolbox extends the basic - Tracking food intake or products
capabilities of MATLAB by providing a number of
specialized I/O, display, and processing functions for images
and image processing. On this paper type of barcode that we use is 39 code
barcode (One-dimensional). The Code 39 specification
Barcodes are often overlooked as a method for cutting defines 43 characters, consisting of uppercase letters (A
costs and saving time. A valuable and viable choice for through Z), numeric digits (0 through 9) and a number of
businesses looking to improve efficiency and reduce special characters (-, ., $, /, +, %, and space). An additional
overhead, barcodes are both cost-effective and reliable. character (denoted '*') is used for both start and stop
1. Barcodes eliminate the possibility of human error. delimiters. Each character is composed of nine elements: five
The occurrence of errors for manually entered data bars and four spaces. Three of the nine elements in each
is significantly higher than that of barcodes. A character are wide (binary value 1), and six elements are
barcode scan is fast and reliable, and takes infinitely narrow (binary value 0). The width ratio between narrow and
less time than entering data by hand. wide is not critical, and may be chosen between 1:2 and 1:3.

2. Using a barcode system reduces employee training


time. It takes only minutes to master the hand-held
scanner for reading barcodes. Furthermore,
employees do not have to gain familiarity with an
entire inventory or pricing procedure. This also
makes employee training less expensive, since they
do not have to be paid for extra training time, and
another employee does not have to be compensated
for training them.
3. Barcodes are inexpensive to design and print.
Generally they cost mere pennies, regardless of
their purpose, or where they will be affixed. They
can be customized economically, in a variety of
finishes and materials.
4. Barcodes are extremely versatile. They can be used
for any kind of necessary data collection. This could
include pricing or inventory information.
Additionally, because barcodes can be attached to
just about any surface, they can be used to track not
a. Barcode Input from User
Barcode = imread('NIM.jpg');
The image of the barcode whose information is to be
identified we choose from the folder into matlab. First we
display the original image.
imshow(Barcode); %Menampilkan gambar
variabel Barcode

b. Convert Image to Grayscale


In this step the original image convert to greyscale mode.
The purpose is to reduce the noise in the picture and give
higher contrast so that information in the picture can be read
easily. Because in this experiment we are use high quality
barcode so it looks like doesn’t have any different from the
original image.

Figure 1. Code 39 Barcode Rules

Their original design included two wide bars and one wide
space in each character, resulting in 40 possible characters.
Setting aside one of these characters as a start and stop
pattern left 39 characters, which was the origin of the name
Code 39. Four punctuation characters were later added, using
no wide bars and three wide spaces, expanding the character
set to 43 characters. Those are the reason why we choose 39
code barcode type to be implemented in this project. This step is just to anticipated if users input the low
quality’s barcode.
c. Generate Binary Sequence
Level = graythresh(Barcode)
ThresholdBarcode=im2bw(Barcode,0.65);

II. THE GENERAL BARCODE READER SYSTEM


Apply threshold method to generate a binarized sequence we
need to decode barcode information to a binarized sequence
to be able to read the information inside barcode. To find the
right level of black or white intensity in the threshold image.
The level range is [0,1], so graytresh find an intermediate
value of the image where the blacks and whites can be
differentiated at best in the image.
d. Find the Size M-N Matrix
We will find out the number of rows and columns of the
barcode's threshold image.
BarcodeSize = size(ThresholdBarcode);
% Find the # of rows and columns
Barcode Input Convert Image RowNum = BarcodeSize(1); %y
from User to grayscale ColumnNum = BarcodeSize(2); %x

Block Diagram of Barcode Reader

Find the size Generate Binary


M-N matrix Sequence
Separating the binary Defining The
barcode into small Characters
arrays
The purpose of this step is to save the matriks of the barcode,
so we can define it with human language.
e. Separating the Binary Barcode into Small Array
for i = 1:ColumnNum - 1
if ThresholdBarcode(:,i) ~=
ThresholdBarcode(:,i+1)
eval(sprintf('A%d =
[ThresholdBarcode(1,k+1:i)]',z ));
k = i; % increment k
z = z + 1; % increment z
end
end
MatrixLength2 = 0; for i = 2: z-1
MatrixLength =
length(eval(sprintf('A%d',i))); %
MatrixLength2 = [ MatrixLength2
MatrixLength]; end
AverageLength =
mean(MatrixLength2); NewMatrix2 =
[];for i = 2:z-1
if sum((eval(sprintf('A
%d',i)))) == 0 &&
length(eval(sprintf('A%d',i))) <=
AverageLength
NewMatrix = 'b';
elseif sum((eval(sprintf('A
%d',i)))) == 0 &&
length(eval(sprintf('A%d',i))) >
AverageLength
NewMatrix = 'B';
elseif sum((eval(sprintf('A
%d',i)))) ~= 0 &&
length(eval(sprintf('A%d',i))) <=
AverageLength
NewMatrix = 'w';
elseif sum((eval(sprintf('A
%d',i)))) ~= 0 &&
length(eval(sprintf('A%d',i))) >
AverageLength This section will take 10 characters from NewMatrix2 and
NewMatrix = 'W'; will check it in the if statement below to find out what
End character they match in the human language. Note that 10
NewMatrix2 = [NewMatrix2 characters together define one real character.
NewMatrix];
On this part, length(NewMatrix2(1:10)%NIM
End
We have to fit the number of character with the matrix
This loop will check for pixel color in each column in the
length. For this barcode, we input 10 characters that is
first row. When it finds a pixel color change, it will store the
the pixels in the same color into one array. It will keep *14S16054*. So we have to set the length of matrix become
separate them until all black and white lines was seperated 10.
from each other.
Which: b= for thin black
f. Defining the Characters
B= for Thick Black
w= for thin white
W= for Thick White
We define it based on code 39 barcode rules, from the fig.1
For instance, A=’BwbwbWbwB’ (Thick Black,
thin white, thin black, thin white, thin
black, Thick White, thin black, thin
white, Thick Black)
It is suitable from this picture,
The Result:

III. RESULT OF EXPERIMENT The Proof:

1. NIM barcode

We have some weakness of this project which is important


to be improve then. Such as, this algortithm can’t detect the
The Result: edge of the image so we have to input a good and
proportional image (crop it with better size). And this
algorithm can’t decode any size of characters in barcode
automatically. We have to set it manual the length of
information on the barcode.

IV. CONCLUSION
In this paper, details of the implementation multiple
The proof:
detection of barcodes by encoding and decoding data based
on Matlab as well as simulation results are provided. We
have presented an algorithm for decoding (localization and
reading) barcodes through a webcam, using image-
processing techniques such as filtering, cropping, and
contrast enhancement and edge detection. This localization
technique is fast and accurate even for cluttered images.
Barcodes having a flat surface and a width to height ratio
between 2 to 3 are successfully decoded. We have
implemented this algorithm in MATLAB R2014b. We have
scanned multiple products by executing this algorithm in a
loop, and a final bill of products is created in an excel sheet.

REFERENCES

[1] N. Otsu, “A Threshold Selection Method from Gray-Level


Histograms,” IEEE Trans. Systems, Man, and Cybernetics, vol. 9, no.
1, pp. 62-66, Jan. 1979.
[2] “Barcode.” Wikipedia, The Free Encyclopedia. Wikimedia
2. PSD Barcode Foundation, Inc. 8. Dec. 2011. Web. 9. Dec.2011.
[3] Pavlidis, Theo, Jerome Swartz, and Ynjiun P. Wang. “Fundamentals
of bar code information theory.”Computer 23.4 (1990): 74-86. Print.
[4] P.bodnar ”barcode detection with an uniform a distance of
transformation IASTD international conference on computer
graphics and imaging FEB 2013.
[5] R. Nicole, “BARCODE RECOGNITION SYSTEM USING IMAGE
PROCESSING,” Universiti Teknikal Malaysia Melaka, April 2009.

Potrebbero piacerti anche