automation of bottling using

Upload: qasim-abbas-alvi

Post on 08-Aug-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/22/2019 Automation of Bottling Using

    1/42

    i

    AUTOMATION OF BOTTLING USING

    IMAGE PROCESSING

    The purpose of this project is to focus on the automation of quality control environment of

    a manufacturing process. The end product is an electrical and mechanical solution which

    would help realize stringent quality control measures where authentication and manage-

    ment of quality is achieved through imaging techniques. The product is basically aimed at

    providing a two course action; identification of the defected item and its disposal in a

    proper manner

  • 8/22/2019 Automation of Bottling Using

    2/42

    ii

    Acknowledgments

    We bow our heads in most humble thanks to Almighty Allah, the most gracious, the mostmerciful for granting us the wisdom and strength to complete this work.

    It is our great pleasure to express our most sincere and deep gratitude to our respected

    supervisor, Sir Muhammad Habib for his unabated guidance, constant help and encou-

    ragement throughout the course of this project.

    We also wish to express our gratitude and admiration to all the faculty members of air Uni-

    versity for their highly useful suggestions and co-operation.

    We shall be failing in our duty if we do not extend our thanks to our friends and colleagues

    for their help and encouragement whenever needed.

    Last but not the least we would like to thank our families for their moral support, love and

    understanding that enabled us to complete this work.

  • 8/22/2019 Automation of Bottling Using

    3/42

    iii

    Table of Contents

    Acknowledgments ................................................................................................................... ii

    Chapter 1: INTRODUCTION ................................................................................................. 1

    1.1. Automation.............................................................................................................. 1

    1.1.1. Advantages and disadvantages of automation....................................................... 2

    1.2 Bottling.......................................................................................................................... 3

    Chapter 2: DESIGN PROCEDURE AND .............................................................................. 5

    DETAILS ................................................................................................................................ 5

    2.1 Hardware ....................................................................................................................... 5

    2.1.1 Mechanical hardware ............................................................................................. 5

    2.1.1.1 Conveyor belt ...................................................................................................... 5

    2.1.1.2 Robotic arm ......................................................................................................... 6

    2.1.2 Electrical hardware................................................................................................. 7

    2.1.2.1 Infrared Sensor.................................................................................................... 7

    2.1.2.2 Dc power supply: ................................................................................................ 9

    2.1.2.3 Motor drives ...................................................................................................... 12

    Unidirectional drive:............................................................................................................. 12

    Bidirectional drive ................................................................................................................ 14

    Chapter 3: IMAGE PROCESSING IN MATLAB ............................................................... 17

    3. 1 Image acquisition ....................................................................................................... 17

    3.2 Separation of RGB components:................................................................................. 17

    3.3 Size of image:.............................................................................................................. 18

    3.4 Image Information....................................................................................................... 18

    3.5 Image Conversion ....................................................................................................... 19

    3.5.1 RGB to Gray Scale............................................................................................... 193.5.2 Gray Scale to Binary Image ................................................................................. 19

    3.6 Color Segmentation..................................................................................................... 21

    3.7 Morphological Operations .......................................................................................... 22

    3.7.1 Structuring Elements ............................................................................................ 22

    3.7.2 Closing and opening of image.............................................................................. 24

    3.9 Edge Detection ............................................................................................................ 26

    3.10 Algorithm .................................................................................................................. 28

  • 8/22/2019 Automation of Bottling Using

    4/42

    iv

    Chapter 4: RESULTS AND DISCUSSION.......................................................................... 29

    4.1 Data Set ....................................................................................................................... 29

    4.2 Limitations .................................................................................................................. 30

    CHAPTER 5 : CONCLUSION & FUTURE ENHANCEMENT ......................................... 31

    5.1 Conclusion .................................................................................................................. 31

    5.2 Future Enhancements .................................................................................................. 31

    List of Figures

    Figure 2.1 Conveyor Belt

    Figure 2.2 Robotic Arm

    Figure 2.3 Infrared Circuit

    Figure 2.4 5V DC Supply

    Figure 2.5 12V DC Supply

    Figure 2.6 15V DC Supply

    Figure 2.7 Unidirectional Motor Derive

    Figure 2.8 Bidirectional Motor derive

    Figure 3.1 RGB components

    Figure 3.2 Conversion of Gray Scale Image

    Figure 3.3 RGB to Binary

    Figure 3.4.1 Color Segmentation of led and label

    Figure 3.4.2 Color Segmentation of Solution

    Figure 3.5 Closing and Opening

    Figure 3.6 Edge Detection

  • 8/22/2019 Automation of Bottling Using

    5/42

    1

    Chapter 1: INTRODUCTION

    In life, there is always a room for betterment. Everything that has been made

    by human keeps getting improved and this is a never ending process. There can be

    many examples regarding it, like cars, planes, etc.

    During the last few decades the term quality has become one of the most

    stressed words in the field of production. Companies today are under constant pres-

    sure to become more efficient in their manufacturing processes, to obtain higher

    yields, have faster throughput, and increasing productivity while keeping wastage

    and costs down. In addition to efficiency, accuracy is imperative as companies race

    to develop and maintain procedural standards to meet ISO 9000 compliance and po-

    sition for themselves for corporate survival in the twenty-first century.

    Every manufacturer today wants to continually improve the quality of the prod-

    ucts he produces. Few of the many important factors that affect quality are contami-

    nation; deviation of the process from its validated state, end product impurity etc.Contamination can be caused by air, water and especially human intervention.

    Manufacturing a product is a procedure. Quality control is a procedure to moni-

    tor a procedure with the goal of making it more efficient. Today the need is to ex-

    plore ways to make the quality control procedure itself more efficient by automating

    the quality control process.

    1.1. Automation

    To get started with this project, one first needs to understand the word automation.

    According to Wikipedia; automation is:

    the use ofcontrol systems(such asnumerical control,programmable logic con-

    trol, and otherindustrial control systems), in concert with other applications of

    information technology(such ascomputer-aided technologies), to controlindus-

    http://en.wikipedia.org/wiki/Control_systemhttp://en.wikipedia.org/wiki/Control_systemhttp://en.wikipedia.org/wiki/Control_systemhttp://en.wikipedia.org/wiki/Numerical_controlhttp://en.wikipedia.org/wiki/Numerical_controlhttp://en.wikipedia.org/wiki/Numerical_controlhttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Industrial_control_systemshttp://en.wikipedia.org/wiki/Industrial_control_systemshttp://en.wikipedia.org/wiki/Information_technologyhttp://en.wikipedia.org/wiki/Information_technologyhttp://en.wikipedia.org/wiki/Computer-aided_technologieshttp://en.wikipedia.org/wiki/Computer-aided_technologieshttp://en.wikipedia.org/wiki/Computer-aided_technologieshttp://en.wikipedia.org/wiki/Industryhttp://en.wikipedia.org/wiki/Industryhttp://en.wikipedia.org/wiki/Industryhttp://en.wikipedia.org/wiki/Computer-aided_technologieshttp://en.wikipedia.org/wiki/Information_technologyhttp://en.wikipedia.org/wiki/Industrial_control_systemshttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Numerical_controlhttp://en.wikipedia.org/wiki/Control_system
  • 8/22/2019 Automation of Bottling Using

    6/42

    2

    trialmachineryandprocesses, reducing the need for human intervention.[1] In

    the scope ofindustrialization, automation is a step beyondmechanization. Whe-

    reas mechanization provided human operators with machinery to assist them

    with the physical requirements of work. Automation greatly reduces the need for

    human sensory and mental requirements as well. Processes and systems can also

    be automated.[2]

    Currently, for manufacturing companies, the purpose of automation has shifted from

    increasing productivity and reducing costs, to broader issues, such as increasing

    quality and flexibility in the manufacturing process.

    1.1.1. Advantages and disadvantages of automation

    Advantages of automation include the following:

    Avoids bulk wastages Overall waste reduction Increased hygiene due to lesser human intervention Increased productivity Replacing human operators in tedious tasks Replacing humans in tasks that need to be performed in dangerous environments Making task that are beyond the human capabilities manageable Speedier accomplishment of tasks Saved cost of training human operators Reduction of labor costs

    On the other hand automation has few disadvantages:

    Technology limits. Nowadays technology is not able to atomize all the desired tasks.[2]

    Initial costs are relative high. The automation of a new product requires a hugeinitial investment in comparison with the unit cost of the product.[2]

    http://en.wikipedia.org/wiki/Machineryhttp://en.wikipedia.org/wiki/Machineryhttp://en.wikipedia.org/wiki/Industrial_processhttp://en.wikipedia.org/wiki/Industrial_processhttp://en.wikipedia.org/wiki/Industrializationhttp://en.wikipedia.org/wiki/Industrializationhttp://en.wikipedia.org/wiki/Industrializationhttp://en.wikipedia.org/wiki/Mechanizationhttp://en.wikipedia.org/wiki/Mechanizationhttp://en.wikipedia.org/wiki/Mechanizationhttp://en.wikipedia.org/w/index.php?title=Human_operator&action=edit&redlink=1http://en.wikipedia.org/w/index.php?title=Human_operator&action=edit&redlink=1http://en.wikipedia.org/wiki/Mechanizationhttp://en.wikipedia.org/wiki/Industrializationhttp://en.wikipedia.org/wiki/Industrial_processhttp://en.wikipedia.org/wiki/Machinery
  • 8/22/2019 Automation of Bottling Using

    7/42

    3

    1.2 BottlingBottling as the name suggest, refers to the process in which bottles are filled

    labeled and packed in the cartons, boxes or crates etc. The term bottling is very well

    known in all the bottles related industries and the bottling process is one of the most

    significant issues in all such industries.

    All the major drinks production companies and factories like coke, Pepsi,

    nestle etc. give great importance to this process for better quality, production and

    business. To achieve these objectives most of the companies up till now have been

    affording man labor at very high costs, but with the advancement of the science and

    the technology all the major industries have been longing to replace this high cost

    man labor with a fast, economical and efficient machine work.

    Automation of bottling is the best solution to meet all the requirements of

    bottling industries in todays advance world. Since the last decade automated ma-

    chines and robots have served such industries a lot to achieve their goals.

    1.3 Project overview

    This project was designed keeping this need for automation in mind. The end

    product of this project is an electrical and mechanical solution which would help

    realize stringent quality control measures where authentication and management of

    quality is achieved through imaging techniques.

    The product is basically aimed at providing a two course action; identifica-tion of the defected item and its disposal in a proper manner.

    Although such a system can be deployed in any industry but this system is de-

    signed specifically for the beverage and bottling industry. The following aspects of

    the bottles need to be checked in any bottling environment:

    Level of the product inside the bottle Correct placement of label

  • 8/22/2019 Automation of Bottling Using

    8/42

    4

    Placement of the lid

    The solution would not only identify the defected good by checking the above as-

    pects but also remove it from the production line.

  • 8/22/2019 Automation of Bottling Using

    9/42

    5

    Chapter 2: DESIGN PROCEDURE AND

    DETAILS

    2.1 HardwareHardware has been divided into two major parts mechanical hardware and

    the electrical hardware.

    2.1.1 Mechanical hardwareABUIP contains two major mechanical hardware conveyor belt and robotic

    arm. Conveyor belt works as the production line of an industry and the robotic arm

    removes the defected items from the production line.

    2.1.1.1 Conveyor belt

    A Conveyor belt is a mechanical hardware that can carry objects from one

    position to another. The Conveyor belts may be of different dimensions and may

    have a variable speed depending upon the requirements of the project it is being

    used for. A conveyor belt may contain two or even more pulleys, which are normal-

    ly driven by the single driver pulley. All the pulleys other than that of driver pulley

    are called idler pulleys.

    The conveyor belt contains two pulleys, a driver pulley driven by a 24V sim-

    ple DC motor and an idler pulley. The length of the belt is 90 cm and width is 15

    cm. the DC motor is connected with the driver pulley by the means of two gears.

    When the motor is energized the driver pulley intern drives the idler pulley and the

    belt, carrying the bottles. The motion of the motor is unidirectional as only one sided

    movement of the belt is required at the production line site. The conveyor belt mea-

    surements and the motor power are enough to carry about six bottles at a time. Fig-

    ure 2.1 shows the real conveyor belt being used by ABUIP.

  • 8/22/2019 Automation of Bottling Using

    10/42

    6

    Figure 2.1 conveyor belt

    2.1.1.2 Robotic arm

    Robotic arm is a device generally used in industries for different processes

    .in design it is similar as a human arm with similar three motions the yaw motion

    (shoulder) pitch (elbow) and the clipper (hand) and hence named as robotic arm. All

    the arm motions are controlled by motors of different specifications depending upon

    the design and the requirements. Basic use of a robotic arm is to pick and place ob-

    jects.

    The robotic arm used in our project is of the simplest form having only one

    motion i.e. the yaw motion. The purpose here is to eliminate the defected bottles

    from the production line. Whenever the image processing tools finds any defected

    item which is not meeting any of the standards then the robotic arm is held responsi-

    ble to drop the bottle of the production line. Our robotic arm is having 90 degree

    yaw motion which enough to meet our requirements. Two limit switches are placed

    at both the extremes limits of the motion which provides signal when any of the

    physical limits is reached. Figure 2.2 is the real picture of the robotic arm being used

    in the project.

  • 8/22/2019 Automation of Bottling Using

    11/42

    7

    Figure 2.2 Robotic Arm

    2.1.2 Electrical hardware

    2.1.2.1 Infrared Sensor

    Infrared sensors pair consist of a transmitter and a receiver, which operates

    with in the infrared band. Within the line of sight the transmitter generates infrared

    radiations and the receiver is responsible for detection of the signals. Infrared sen-

    sors may be used for the detection of any obstacles or objects that come across the

    line of sight of the transmitter and the receiver. The object across the line of sight

    blocks the radiation path and the transition at the receiver detects a path blockage.

  • 8/22/2019 Automation of Bottling Using

    12/42

    8

    The transmitter and the receiver are placed across the width of the conveyor

    belt. The output at the receiver end of the sensor remains constant as long as the line

    of sight connection is being established. Whenever the bottle comes in between the

    line of sight (i.e. the frame of the camera) the transition in the voltage at the receiver

    indicates the microcontroller that the bottle is in the frame. Microcontroller after re-

    ceiving the signal from the sensor stops the motion of the belt and signals the cam-

    era for taking an image.

    Circuitry:

    Figure 2.3 Infrared Circuit

    Figure 2.3 shows the circuit the infrared sensors used in the project. The two

    legs are placed across the width of the conveyor belt. The one with the transistor is

  • 8/22/2019 Automation of Bottling Using

    13/42

    9

    the transmitter and the other is the receiver. When the signal is applied at the base of

    the transistor Q1(2N22) it gets on and the current begins to flow from the source to

    the sink making the led(D1) to transmit infrared radiations, the transmitted radia-

    tions are continuously received by the receiver diode(D2). As long as the radiations

    are being received by the receiver the voltage at the output point remains constant.

    Whenever the path is interrupted by any obstacle the receiver detects the blockage

    and transition occurs at the output point. This transition is sensed by the microcon-

    troller, and it is confirmed that the bottle is exactly in the frame of the camera.

    2.1.2.2 Dc power supply:

    All the electronic equipment for example motors and their driver circuits are

    to be operated with low DC voltages, for the reason we have designed our own DC

    power supplies exactly matching our requirements.

    The three different voltage requirements for ABUIP were 5V DC, 12V DC

    and 15V DC to bias microcontroller interface circuit, motor derives limit switches,

    motors etc. so to make the ABUIP self-sufficient all the voltage supplies of the de-

    sired values were self-established.

    The figures below shows the schematic diagrams of the supplies being used by

    the ABUIP.

    (a)5Volts DC SupplyA transformer takes 220V Ac as an input and provides 12V AC on the output.

    Then the diodes rectify the AC signal coming from the transformer. Then the regula-

    tor 7805 takes the rectified DC signal at the input and provides 5V regulated voltage

    at the output.

    To eliminate the high frequency components at the output and to make it smooth

    a non-polar capacitor is attached across the output.

  • 8/22/2019 Automation of Bottling Using

    14/42

    10

    Figure 2.4 5V DC Supply

    (b)12Vol ts DC SupplyA 220V to 24V transformer is used at the input which provides up till 4amperes

    of current. Then the diodes rectify the AC signal coming from the transformer. Then

    the regulator 7812 takes the rectified DC signal at the input and provides 12V regu-

    lated voltage at the output. Similarly the negative rectified cycle is regulated by the

    negative regulator 7912 which provides the -12V at the output. To eliminate the high

    frequency components at the output and to make it smooth a non-polar capacitor is

    attached across the output. When the motors require more current the regulators hold

    the output regulated at the output terminals, the additional current is provided by the

    N-type power BJT (TIP2955) and P-type power BJT (TIP3055) at the corresponding

    outputs.

  • 8/22/2019 Automation of Bottling Using

    15/42

    11

    Figure 2.5 12V DC Supply

    (c)15Volts DC Supply:A 220V to 24V transformer is used at the input which provides up till 4amperes

    of current. Then the diodes rectify the AC signal coming from the transformer. Then

    the regulator 7815 takes the rectified DC signal at the input and provides 15V regu-

    lated voltage at the output. To eliminate the high frequency components at the out-

    put and to make it smooth a non-polar capacitor is attached across the output. When

    the motors and the circuits require more current the regulators hold the output regu-

    lated at the output terminals, the additional current is provided by the N-type power

    BJT (TIP2955) at the output.

  • 8/22/2019 Automation of Bottling Using

    16/42

    12

    Figure 2.6 +15V DC Supply

    2.1.2.3 Motor drives

    To control the motion and the speed of the motors via microcontroller drives

    were established. These drives are operated by the micro controller using PWM, and

    the duty cycle of the pulse or the pulse width is responsible for controlling the speed

    of the motors.

    Unidirectional drive:

    Motion of the motor driving the conveyor belt is supposed to be unidirec-

    tional, so for that reason a unidirectional motor derive was designed. This derives

    takes an input signals from the microcontroller (pulse waveform) and decides for the

    motor to on and off. When a pulse is applied at the input, during the high logic or

    5volts time period the power MOSFET gets on and allows the motor to rotate at the

    voltage provided across its terminals. And during logic 0 cycles it stops the motor

    for rotation. In this way the width of each cycle decides the off and the on time of

    the motor. And finally this continuous pulse signal controls the speed of the motor.

  • 8/22/2019 Automation of Bottling Using

    17/42

    13

    When the bottle comes in between the camera frame the microcontroller

    stops the motion of the conveyor belt after getting the signal from the sensor. And

    this stopping of the belt is made possible by setting the duty cycle at input of derive.

    Circuitry:

    Figure 2.7 Unidirectional Motor Drive

    The above given figure shows the circuit for the unidirectional motor derives

    which will control the speed of the conveyor belt. Input of the motor derive is the

    microcontroller pulse. Input waveform and the corresponding output waveforms at

    the various points mentioned in the figure are as follows.

    Figure 2.7.1 Input waveform at point I

  • 8/22/2019 Automation of Bottling Using

    18/42

    14

    Figure 2.7.2 Waveform at point A

    Figure 2.7.3 Waveform at point O

    When a signal is applied at point I (fig.2.7.1), an inverted wave form ap-

    pears at the output of the opt coupler (4n35) i.e. at point A (fig.2.7.2). During log-

    ic 1 at point I the transistor Q1 is on and the transistor of the IC in off hence

    ground or 0volts appear at point A. when point A is at zero volts transistor Q2

    gets off and the VCC directly appears at gate of the MOS-fet and it gets

    on(fig.2.7.3), providing the motor with the maximum voltage difference between the

    two terminals. Same process goes on for the logic 1 or 5volts at input point.

    Bidirectional drive

    Motors fixed in the robotic arm that controls the yaw, pitch and the clipper

    motion are all supposed to be bidirectional, in order to remove the bottle from the

    production line. Bidirectional motor derives were also designed to achieve the objec-

    tive. The bidirectional motor derives consist of a H-bridge circuit made using two P-

    MOSFETs (IRF 9540) and two N-MOSFETs (IRF540). The transition of the voltage

  • 8/22/2019 Automation of Bottling Using

    19/42

    15

    at the center of the two legs controls the direction of the motion and the width or the

    duty cycle of the pulse like in unidirectional case controls the speed of the motor.

    Circuitry:

    Figure 2.8 Bidirectional Motor Drive

    Figure2.8 shows the circuit for the H-bridge derives for controlling the speed

    and the direction of all the bidirectional motors. Motor is fixed between the two

    points marked as point A and B in the figure. Now its simple to control the di-

    rection of the motor just by changing the polarity between the two points. If point

    A is at higher voltage then B then the motor will move in one direction and if

    the point B is at higher voltage then the motor will move in the other direction.

    and for doing that transistors Q1 and Q4 are set on simultaneously and Q2 and Q3

    are set on at a time keeping the other two off for the opposite direction motion.

  • 8/22/2019 Automation of Bottling Using

    20/42

    16

    Transistors Q1 and Q2 are P-MOS (IRF9540) where as Q3 and Q4 are N-

    MOS (IRF540).

    N-MOS gets on when it gets logic 1 at its gate and P-MOS gets on when it

    gets logic 0 at the base. To set the two transistors Q1 (P-MOS) and Q4 (N-MOS) on

    at the same time Q1 is provided with logic 0 at the gate and Q4 is provided with log-

    ic 1 at the gate. Same signaling is applied at the gates of the other two transistors for

    the opposite motion and the other two at the other time inverters are used.

    To achieve the desired signaling pattern at the gates same procedure is

    adopted as mentioned in the last section of unidirectional motor derive.

  • 8/22/2019 Automation of Bottling Using

    21/42

    17

    Chapter 3: IMAGE PROCESSING IN MAT-

    LABFollowing commands and methods given below are used in image processing

    code.

    3. 1 Image acquisitionIn MatLab (see Appendix A for the code) this task was accomplished with

    the help of a simple command: getsnapshot

    Syntax:

    y = getsnapshot(vid) (see Appendix A)

    3.2 Separation of RGB components:It is important to separate the RGB components of the image. This task was

    done with the help of commands given below.

    Syntax:

    R=y(:,:,1)(see Appendix A)

    G=y(:,:,2) (see Appendix A)

    B=y(:,:,3) (see Appendix A)

    Figure 3.1.1 Input Image Figure 3.1.2 R Component

  • 8/22/2019 Automation of Bottling Using

    22/42

    18

    Figure

    3.1.3 G Component Figure 3.1.4 B Component

    Figure 3.1.1 shows the input RGB image of the bottle by using the com-

    mands given above we can separate the R component G component and B compo-

    nent of the image. Figure 3.1.2, figure 3.1.3 and figure 3.1.4 shows the R, G and B

    component of the image.

    3.3 Size of image:Function size gives the row and column dimensions of an image

    >>size(y)

    ans=

    1024 1024

    This function is practically useful in programming when used in the follow-

    ing form to determine automatically the size of an image

    >> [M, N] = size(y);

    This syntax return the number of rows(M) and columns(N) in the image.

    3.4 Image InformationThe whos function displays additional information about an array.

    >> whos y

    Name Size Bytes Class

    y 480x640x3 921600 uint8

  • 8/22/2019 Automation of Bottling Using

    23/42

    19

    The uint8 entry shows refers to one of several MATLAB data classes dis-

    cussed earlier in data types.

    3.5 Image Conversion

    3.5.1 RGB to Gray Scale

    Syntax:

    Gray-image = rgb2gray( rgb-image )

    Convert an RGB image to a gray scale image. The input RGB image can be

    of class uint8, uint16 or double. The output image is of the same class as the input .

    Figure 3.2.1 Input RGB Image Figure 3.2.2 Output Gray Scale Image

    Figure 3.2.1 shows the input RGB image by using the command rgb2gray we

    can easily convert it into gray scale image.

    3.5.2 Gray Scale to Binary Image

    Syntax:

    y=im2bw(f,T)

    Convert a gray scale image to binary image. Valid input data are uint8,

    unit16 and double. This command produces intensity image, f, by thresholding. The

    out binary image g has values of 0 for all pixels in the input image with intensity

  • 8/22/2019 Automation of Bottling Using

    24/42

    20

    values less than threshold T, and 1 for all other pixels. The value specified for T has

    to be in the range [0,1], regardless of the class of the input. The output binary image

    is automatically declared as a logical array by im2bw. If we write g=im2bw(f) it use

    a default value of 0.5.

    Figure 3.3.1 Threshold value 90 Figure 3.3.2 Threshold Value 110

    Figure 3.3.3 Threshold Value 170

    Figure 3.3.1 shows the binary image of the figure 3.2.1 with threshold value

    of 90, figure 3.3.2 shows the binary image with threshold value of 90 and figure

    3.3.3 shows the binary image with threshold value of 170.

  • 8/22/2019 Automation of Bottling Using

    25/42

    21

    3.6 Color SegmentationColor segmentation is the process in which we separate different colors .As

    we set the white background and white color of conveyor belt so there is only a bot-tle in a frame, with black solution in it and red lid and red label. When we segment

    the red color from the frame we get the lid and the label. When we segment the

    black color we get the solution.

    We did this by thresholding the R, G and B component of the image. For the

    segmentation of red color we used threshold values given below.

    R(i,j)>=80 && G(i,j)

  • 8/22/2019 Automation of Bottling Using

    26/42

    22

    Figure 3.4.2 Color Segmentation of Solution

    Figure 3.4.1 shows the color segmentation of lid and label of the bottle. And

    figure 3.4.2 shows the color segmentation of solution of the product inside the bot-

    tle.

    3.7 Morphological Operations

    Morphology relates to the structure or form of objects. Morphological filter-

    ing simplifies a segmented image to facilitate the search for objects of interest. This

    is done by smoothing out object outlines, filling small holes, eliminating small pro-

    jections, and using other similar techniques

    The two principal morphological operations are dilation and ero-

    sion. Dilation allows objects to expand, thus potentially filling in small holes and

    connecting disjoint objects. Erosion shrinks objects by etching away (eroding) their

    boundaries. These operations can be customized for an application by the proper se-

    lection of the structuring element, which determines exactly how the objects will be

    dilated or eroded.

    3.7.1 Structuring Elements

    An essential part of the dilation and erosion operations is the structuring

    element used to probe the input image. Two-dimensional, orflat, structuring ele-

    ments consist of a matrix of 0's and 1's, typically much smaller than the image being

  • 8/22/2019 Automation of Bottling Using

    27/42

    23

    processed. The center pixel of the structuring element, called the origin, identifies

    the pixel of interest--the pixel being processed. The pixels in the structuring element

    containing 1's define the neighborhoodof the structuring element. These pixels are

    also considered in the dilation or erosion processing. Three dimensional, ornonflat,

    structuring elements use 0's and 1's to define the extent of the structuring element in

    thex- andy-plane and add height values to define the third dimension.

    se = strel('diamond',3)

    se =

    0 0 0 1 0 0 0

    0 0 1 1 1 0 0

    0 1 1 1 1 1 0

    1 1 1 1 1 1 1

    0 1 1 1 1 1 0

    0 0 1 1 1 0 0

    0 0 0 1 0 0 0

    Structuring element used in the code is

    se = strel('rectangle',[4 9])

    it is a 49 matrix of 1s

    se = strel('rectangle',[4 9])

    se =

    Neighborhood:

    1 1 1 1 1 1 1 1 1

    1 1 1 1 1 1 1 1 1

    1 1 1 1 1 1 1 1 1

  • 8/22/2019 Automation of Bottling Using

    28/42

    24

    1 1 1 1 1 1 1 1 1

    3.7.2 Closing and opening of image

    By using the closing first and opening second the result of image segmenta-

    tion was perfect. Closing suppresses dark detail smaller than the structuringelement

    and opening suppresses bright detail smaller than the structuring element. They are

    used for image smoothing and noise removal.

    Figure 3.5.1 Segmentation without Morphological Operation

    Figure 3.5.2 Closing and Opening

    3.8 Labeling

    Bwlabel command is used to label the connected portions. We get the seg-

    mented portions by labeling different connected regions i.e 1,2,3 or 4 pixel values

    for different connected regions.

  • 8/22/2019 Automation of Bottling Using

    29/42

    25

    Syntax:

    [L,num]= bwlabel(f,conn)

    Where f is an input binary image and conn specifies the desired connectivity

    it can be either 4 or 8. Out L is called the label matrix, and num (optional) gives the

    total number of connected portions found. Example given below shows the label

    matrix L corresponds to matrix F, computed using bwlabel(f,4). The pixel in each

    different connected component is assigned a unique integer, from 1 to the total num-

    ber of connected components. In other words, the pixel labeled 1 belongs to first

    connected portion; the pixel label 2 belongs to the second connected component and

    so on.

    F=

    1 1 1 0 0 0 0 0

    1 1 1 0 1 1 0 0

    1 1 1 0 1 1 0 0

    1 1 1 0 0 0 1 0

    1 1 1 0 0 0 1 0

    1 1 1 0 0 0 1 0

    1 1 1 0 0 1 0 0

    1 1 1 0 0 0 0 0

    L =

    1 1 1 0 0 0 0 0

    1 1 1 0 2 2 0 0

  • 8/22/2019 Automation of Bottling Using

    30/42

    26

    1 1 1 0 2 2 0 0

    1 1 1 0 0 0 4 0

    1 1 1 0 0 0 4 0

    1 1 1 0 0 0 4 0

    1 1 1 0 0 3 0 0

    1 1 1 0 0 0 0 0

    Function find is useful when working with label matrices. For example, the

    following call to find returns the row and column indices for all the pixels belonging

    to the third object.

    [r,c]=find(L==3)

    r = 7

    c = 6

    3.9 Edge DetectionIntensity discontinuities in a digital image; point lines and edges, the most

    common way to look them is to run a mask through the image. It was done by mul-

    tiplying each pixel in the neighborhood by a corresponding coefficient and summing

    the results to obtain the response at each point (x,y). if the neighborhood is of size

    mn, mn coefficients are required. The coefficients are arranged as a matrix called a

    filter, mask or window [5].

    The process consists simply of moving center of filter mask from point to

    point in an image. At each point (x,y) the response of the filter at that point is the

    sum of product of the filter coefficients and the corresponding neighborhood pixels

    in the area spanned by the filter mask.

    Edge detection is the first derivative of the image. A fundamental property of

    the gradient vector is that it points in the direction of the maximum rate of change

    occur.

    With the preceding discussion, the basic idea behind edge detection to find plac-

    es in an image where the intensity changes rapidly, use one of two general criteria.

  • 8/22/2019 Automation of Bottling Using

    31/42

    27

    1. Find places where the first derivate of the intensity is greater in magnitude than aspecified threshold.[5]

    2. Find places where the second derivate of the intensity has a zero crossing.[5]We used sobel edge detection to find the edges of bottle. The sobel edge detector

    uses the mask shown given below Gx and Gy.

    Gx =

    -1 -2 -1

    0 0 0

    1 2 1

    Gy =

    -1 0 1

    -2 0 2

    -1 0 1

    Complete code is given in appendix

  • 8/22/2019 Automation of Bottling Using

    32/42

    28

    b22= m11a11 + m12a12 + m13a13 + m21a21 + m22a22 + m23a23 +

    m31a31 + m32a32 + m33a33

    Figure 3.6.1 Edge Detection Process

    Figure 3.6.2 edge detection result

    3.10 AlgorithmThe basic idea is to find the corner points of lid, label and the level of the

    product. For correctness of the bottle lid we used to find the pixel ratio of the corner

    points of the lid from the base of the bottle, ratio of the corner points of the label

    from the base point and the corner points of level from the base point. The ratio is

    always remains the same it didnt depend upon the placement of the bottle as the

    camera is fixed. We fixed threshold values for the placement of lid, label and level

    of the product. If the one of the ratio exceed or decrease from the threshold value the

    bottle will declared incorrect and discarded otherwise it declared as correct bottle.

  • 8/22/2019 Automation of Bottling Using

    33/42

    29

    Chapter 4: RESULTS AND DISCUSSION

    4.1 Data SetIn the beginning a data set was established containing about fifty images,

    with different light and shadows effects keeping the distance and position of the

    camera fixed. The data set contains the following images.

  • 8/22/2019 Automation of Bottling Using

    34/42

    30

    4.2 Limitations

    To make the project simple and for easy implementation a few limitations were

    observed. Some of the major limitaions are as follows.

    The algorithm was desighned only for single brand (coke) Camera position was set fixed Distance of the camera and conveyor belt was also fixed

    Light effect issues were resolved by placing the light above the camera

  • 8/22/2019 Automation of Bottling Using

    35/42

    31

    CHAPTER 5 : CONCLUSION & FUTURE

    ENHANCEMENT

    5.1 Conclusion

    Companies today are a target of cut throat competition. If a company wants

    to stay in business, it has to provide better and more efficient products/services in

    lesser time than their competitors. The opposite of this would mean death for the

    business. So essentially in business today, its all about quality and time.

    The conventional methods of quality checking are no more acceptable in terms of

    consistency as well as time. A revolution was needed and the ultimate solution is

    automation.

    Automation creates an extremely proficient process designed to maintain the

    manufacturers quality control standards. Furthermore; the effect of introducing au-

    tomation results in reduced injuries for the production personnel, less handling

    which improves hygiene, improved Quality Assurance as every piece is now

    checked at consistent packing speeds, all leading to major labor and product saving

    gains.

    In summary, automating quality control processes improves productivity and

    ensures accurate and precise product manufacturing. It is a simple and inexpensive

    solution to improve the products and the companys reputation.

    5.2 Future EnhancementsThis project dealt only with the outer look of the product for which imaging

    techniques were used. One of the enhancements that can make this project more ad-

    vantageous can be the introduction of other checks along with the available checks.

    For example; if we look at the bottling industry, better

  • 8/22/2019 Automation of Bottling Using

    36/42

    32

    imaging techniques may be used to check the presence of any suspended

    particles in the product or sensors can be incorporated through which other factors

    of the products can be checked.

    If this project is applied to the food industry e.g. biscuits etc., then the

    weight and humidity sensors along with camera can be deployed for a broader

    scope.

  • 8/22/2019 Automation of Bottling Using

    37/42

    33

    REFRENCES

    [1] Definitions from Dictionary.com". dictionary.reference.com.

    http://dictionary.reference.com/browse/Automation.

    [2] Wikipedia, the free encyclopaedia.

    [3]http://www.mathworks.com/products/image/

    [4] MATLAB (image processing toolbox)

    [5] Digital Image Processing By Rafael C. Gonzalez, Richard Eugene Woods

    http://dictionary.reference.com/browse/Automationhttp://dictionary.reference.com/browse/Automationhttp://www.mathworks.com/products/image/http://www.mathworks.com/products/image/http://www.mathworks.com/products/image/http://www.mathworks.com/products/image/http://dictionary.reference.com/browse/Automation
  • 8/22/2019 Automation of Bottling Using

    38/42

    34

    APPENDIX A

    Code for Image Processing

    vid=videoinput('winvideo',3,'RGB24_352x288'); %camera initialization

    obj=getselectedsource(vid); %camera properties

    obj.FocusMode='manual'; %set auto focus

    s=serial('com14'); %serial port initialization

    fopen(s) %open serial port

    fori=1:1:2000 %wait for the bottle

    f=fscanf(s) %serial reception

    if(f=='S')

    y=getsnapshot(vid); %get image

    imview(y)

    R=y(:,:,1); %RGB components of image

    G=y(:,:,2);

    B=y(:,:,3);

    [a,b,c]=size(y);

    fori=2:1:a-1

    forj=2:1:b-1

  • 8/22/2019 Automation of Bottling Using

    39/42

    35

    ifR(i,j)>=80 && G(i,j)

  • 8/22/2019 Automation of Bottling Using

    40/42

    36

    e=max(c);

    plab=[a b ; a e ; d b ; d e ]

    imview(imnew)

    %level detection

    R=y(:,:,1);

    G=y(:,:,2);

    B=y(:,:,3);

    [a,b,c]=size(y);

    fori=2:1:a-1

    forj=2:1:b-1

    ifR(i,j)

  • 8/22/2019 Automation of Bottling Using

    41/42

    37

    b=min(c);

    a3=max(r);

    e=max(c);

    [r,c]=find(L==1);

    ao=min(r);

    b=min(c);

    a6=max(r);

    e=max(c);

    [r,c]=find(L==3);

    ai=min(r);

    b=min(c);

    a4=max(r);

    e=max(c);

    [r,c]=find(L==4);

    au=min(r);

    b=min(c);

    a5=max(r);

    e=max(c);

    a2=max([a3 a4 a5 a6]);

    as=min([ap ao ai au]);

    if(a2/a1>=4.1 && a2/a1=1.6 && a2/al=1.9 &&

    a2/as

  • 8/22/2019 Automation of Bottling Using

    42/42

    38

    fwrite(s,'N')

    p=[0]

    end

    else

    end

    end