Documente Academic
Documente Profesional
Documente Cultură
CERTIFICATE
It is certified that the project work reported by Ms. Aditi Chawla, Ms. Akshee Jain and Ms.
Parul Madaan was carried out under my guidance towards partial fulfillment of the
requirements for the award of B.Tech degree in Innovation with Mathematics and IT.
ACKNOWLEDGEMENT
The successful completion of a project work requires efforts of several intellectual minds. It has been a
great learning experience for which we would like to thank our mentor Ms. Nirmal Yadav. We are
grateful to her for her support and guidance.
We would also like to thank our family and friends for their undying support.
Aditi Chawla
Akshee Jain
Parul Madaan
Contents
CERTIFICATE .................................................................................................................................................. 1
ACKNOWLEDGEMENT .................................................................................................................................. 2
Chapter-1 Introduction ................................................................................................................................. 4
1.1 Introduction ............................................................................................................................................ 4
1.2 Literature Survey .................................................................................................................................... 4
Chapter -2 Methodology............................................................................................................................... 6
2.1 Proposed Work ....................................................................................................................................... 6
2.2 Pre-Requisites ......................................................................................................................................... 6
2.3 Process Flow ........................................................................................................................................... 7
2.4 Otsus Method ........................................................................................................................................ 8
Chapter-3 Implementation .......................................................................................................................... 9
3.1 Steps Involved ......................................................................................................................................... 9
Stage 1: Thresholding the Image .............................................................................................................. 9
Stage 2: Removal of Noise ........................................................................................................................ 9
Stage 3: Encircling tablets perfectly circular in shape............................................................................... 9
Conclusion ................................................................................................................................................... 12
References .................................................................................................................................................. 13
Appendix ..................................................................................................................................................... 14
Chapter-1
Introduction
1.1 Introduction
Medicines have helped to make our lives easier. Drug industry is a developing industry in terms of
production as well as consumption. Medication has become very important in everyones life as we are
affected by so many diseases. But sometimes, these medicines might get defected during the
production process such as one or more tablets in the strip might be broken or there might be a missing
tablet in a strip. These defective tablets cannot be sold in the market and thus account for an additional
cost to the manufacturer. These irregularities in the tablet strip can be detected using image processing,
and can help in improving the quality management system.
Digital image processing techniques and algorithms are very efficient in detection of error in a given
strip of medicines. Image processing includes many techniques like pattern recognition, feature
extraction, template matching and edge detection to process digital images. They help in faster
manipulation of digital images. Manual inspection is automated using image processing techniques and
this automation helps in quality assurance of the manufactured good.
Chapter -2
Methodology
Proposed Work
Statistical Method has been used to find the defect in the circular shaped tablets. As we know,
circular tablets have a particular area and if there is a defect in the tablet due to its shape or size, it
would deviate from its standard roundness metric. The defected tablet then can be found by
comparing its roundness with that of a standard tablet.
2.2 Pre-Requisites
Process Flow
RGB Image
PreProcessing
Boundary
detection
Noise
Removal
Compute
Roundness
metric
Display
Result
For the purpose of detection of tablets in the image, it is important to partition the image into
foreground and background. To do so, the technique of image thresholding has been used. Image
thresholding is a simple, technique which segments the image so as to isolate objects by converting
grayscale images into binary images. Image thresholding is most effective in images with high levels of
contrast.
Common image thresholding algorithms include histogram and multi-level thresholding. In this project,
we have used Otsus Method for thresholding which uses histogram algorithm.
http://in.mathworks.com/discovery/image-thresholding.html
This approach assumes that the image is divided in two main classes: The background and
the foreground. It exhaustively searches for the threshold that minimizes the intra-class variance (the
variance within the class), defined as a weighted sum of variances of the two classes.
It follows the following algorithm:
1. Compute histogram and probabilities of each intensity level
2. Set up initial (0) and (0), where (0) is the class probability and (0) is the mean.
2
2
5. Compute two maxima (and two corresponding thresholds). 1
() is the greater max and 2
() is
the greater or equal maximum
6. Desired threshold =
1 +2
2
Chapter-3
Implementation
3.1 Steps Involved
Stage 1: Thresholding the Image
1. Read the original image
2. Convert the RBG image into Grayscale
3. Threshold the grayscale uses 2Otsu's method, which chooses the threshold to minimize the
intra-class variance of the black and white pixels. This will help us in tracing the boundaries of
the tablets.
9. This metric mentioned in the above equation is equal to one only for a circle and it is less than
one for any other shape. On the basis of this, circular shaped objects are separated from other
Otsu, N., "A Threshold Selection Method from Gray-Level Histograms," IEEE Transactions on Systems, Man, and
Cybernetics, Vol. 9, No. 1, 1979, pp. 62-66.
objects. Since the tablets in the images need not be perfectly circular, the threshold is not equal
to one. Instead, it has been kept to be as 0.90. The following three cases were obtained:
Case1: Non-defective tablet strips
When the tablets are round in shape and there are no missing tablets. Here, since the metric is
greater than 0.90 for all the tablets, the number of tablets detected by the matlab code is 10.
10
11
Conclusion
Quality Management is a very critical component of operations of any company especially
manufacturing units. Quality check of medicines is of cardinal importance as Human life depends on
these drugs. This project demonstrates how image processing can be used to detect missing or broken
tablets in the pharmaceutical industry. Using image analysis, it has been shown that the number of
tablets can be identified which can be used to benchmark the strip against the standard ones.
A similar procedure can be applied to detect anomalies in capsules or any other shaped tablet.
12
References
1. tefanOprea, IoanLi, Mariana Jurianu, Daniel AlexandruVian, Ion BogdanCioc, Digital Image Processing
Applied in Drugs Industry for Detection of Broken Aspirin Tablets Electronics, Communications and
Computers Department, University of Pitesti Str.Targul din Vale Nr. 1 Pitesti, Romania,2008
2. Huvaida Manzoora Dr.Yogeshwer Singh Randhawa, Edge Detection in Digital Image Using Statistical
Method
3. Ramya.S, Suchitra.J and Nadesh R.K, Detection of Broken Pharmaceutical Drugs using Enhanced Feature
Extraction Technique, School of Information Technology and Engineering, VIT University, Vellore, Tamilnadu:
India
4. Dawei Qi, Yuanxiang Li and Lei Yu The Application of Mathematical Morphological Optimization Algorithm in
Edge Detection of Defected Wood Image , Proceedings of the IEEE International Conference on Automation
and Logistics Qingdao, China September 2008.
5. Hardeep Kaur and Er.Nidhi Garg, Inspection of Defective Pharmaceutical Capsules using Harris Algorithm
6. http://in.mathworks.com/help/images/examples/correcting-nonuniformillumination.html#zmw57dd0e1191
13
Appendix
MATLAB Code:
clear all;
clc;
%STEP 1: READ IMAGE
a = imread('tablet.jpg');
imshow(a);
%THRESHOLD THE IMAGE
%Convert the image to black and white in order to prepare for
I = rgb2gray(a);
threshold = graythresh(I);
bw = im2bw(I,threshold);
imshow(bw)
%REMOVE THE NOISE
% remove all object containing fewer than 30 pixels
bw = bwareaopen(bw,30);
% fill a gap
se = strel('disk',2);
bw = imclose(bw,se);
% the area enclosed by each of the boundaries
bw = imfill(bw,'holes');
imshow(bw)
%Step 4: Find the Boundaries
[B,L] = bwboundaries(bw,'noholes');
% Display the label matrix and draw each boundary
imshow(label2rgb(L, @jet, [.5 .5 .5]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
end
stats = regionprops(L,'Area','Centroid');
% loop over the boundaries
for k = 1:length(B)
% obtain (X,Y) boundary coordinates corresponding to label 'k'
boundary = B{k};
% compute a simple estimate of the object's perimeter
delta_sq = diff(boundary).^2;
perimeter = sum(sqrt(sum(delta_sq,2)));
% obtain the area calculation corresponding to label 'k'
area = stats(k).Area;
end
stats = regionprops(L,'Area','Centroid');
14
threshold = 0.90;
count=0;
% loop over the boundaries
for k = 1:length(B)
% obtain (X,Y) boundary coordinates corresponding to label 'k'
boundary = B{k};
% compute a simple estimate of the object's perimeter
delta_sq = diff(boundary).^2;
perimeter = sum(sqrt(sum(delta_sq,2)));
% obtain the area calculation corresponding to label 'k'
area = stats(k).Area;
% compute the roundness metric
metric = 4*pi*area/perimeter^2;
% display the results
metric_string = sprintf('%2.2f',metric);
% mark objects above the threshold with a black circle
if (metric > threshold)
count=count+1;
centroid = stats(k).Centroid;
plot(centroid(1),centroid(2),'ko');
end
text(boundary(1,2)+5,boundary(1,1),metric_string,'Color','k',...
'FontSize',14,'FontWeight','bold');
end
fprintf('Number of tablets');
count
title(['Metrics closer to 1 indicate that ',...
'the object is approximately round']);
15