final report - sreenivas mamidi - 2009a3ps101p

Upload: abinayageetha

Post on 04-Jun-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    1/42

    A REPORT

    ON

    Development and implementation of image processing algorithm for

    quantification of microscopic images of Bhasmas

    BY

    Sreenivas Mamidi 2009A3PS101P B.E (Hons.)E.E.E

    AT

    CSIR-CEERI, Chennai

    A PRACTICE SCHOOLII STATION OF

    BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, PILANI

    PILANI

    (JUNE, 2013)

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    2/42

    A REPORT

    ON

    Development and implementation of image processing algorithm for

    quantification of microscopic images of Bhasmas

    BY

    Sreenivas Mamidi 2009A3PS101P B.E (Hons.)E.E.E

    Prepared in partial fulfillment of the

    Practice School-II Course(BITS C412)

    AT

    CSIR-CEERI, Chennai

    A PRACTICE SCHOOLII STATION OF

    BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, PILANI

    PILANI

    (JUNE, 2013)

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    3/42

    BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE

    PILANI (RAJASTHAN)

    Practice School Division

    Station: CSIR-CEERI Centre:Chennai

    Duration:51/4months

    DateOfStart: 07-01-2013

    Date Of Submission: 14-06-2013

    Title of the Project: Development and implementation of image processing algorithm for

    quantification of microscopic images of Bhasmas.

    ID No./Name/

    Discipline of the student Sreenivas Mamidi / 2009A3PS101P

    Name and Designation

    Of the expert : DR. A.Gopal, Scientist & Mr. A.S.S.Sarma, Scientist

    Name Of the PS Faculty: Mr. V.R.RAJAN

    Keywords: Image Processing, Matlab, Starch Grain, Fibers, Canny filter, Dilation, Erosion

    Project Areas: Identification and quantization using Image Processing.

    Abstract:

    The project is about identifying the various components in the images of the sample powders. For this weuse the concept of image segmentation The project started with getting acquainted to the matlab image

    processing toolbox. Using the functions, we detect the cells we need and then segregate them from the

    original image. The various cell we need to segment are starch grains, fibers, stone cells etc. We need to

    also know some of the biological features for distinguishing between the various characteristics. I have

    succeeded in extracting and quantifying some of the features. The codes for segmenting them are shown

    in the end of the report. The snapshots of the output are also shown.

    Signature of Student Signature Of PS Faculty

    Date Date

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    4/42

    BIRLA INSTITUE OF TECHNOLOGY & SCIENCE

    PILANI (RAJASTHAN)

    PRACTICE SCHOOL DIVISION

    Response Option Sheet

    Station: CSIR-CEERI Centre:CHENNAI

    ID No. & Name: SREENIVAS MAMIDI /2009A3PS101P

    Title Of the Project: Development and implementation of image processing algorithm for

    quantification of microscopic images of Bhasmas.

    Usefulness of the project to the on-campus courses of study in various disciplines. Project should be

    scrutinized keeping in view the following response options. Write Course No. And Course Name against

    the option under which the project comes.

    Refer Bulletin for Course No, and Course Name.

    Signature Of Student Signature Of Faculty

    Code No. Response Options Course No. & Name

    1. A new course can be designed out of this project NO

    2. The project can help modification of the course content

    Of some of the existing courses.

    NO

    3. The project can be used directly in some of the existing

    Compulsory Discipline courses (CDC) /Disciplines

    Compulsory Discipline courses (DCOC) / Emerging

    Area (EA) etc. Courses

    NO

    4. The project can be used in preparatory courses like

    Analysis and Application Oriented Courses (AAOC)/

    Engineering Science (ES)/ Technical Art (TA) and

    Core Courses.

    NO

    5. This project cannot come under any of the above-

    mentioned options as it relates to the professional work

    of the host organization.

    YES

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    5/42

    ACKNOWLEDGEMENTS

    I express my sincere gratitude to Dr. B. N. Jain, Vice Chancellor of Birla Institute of Technology

    and Science, Pilani, for the provision of the required infrastructure. I am grateful to Dr. Niranjan Swain

    Dean of Practice School Division, BITS-Pilani, for providing me with this wonderful opportunity of doing

    an internship at CSIR-CEERI, Chennai.

    I am deeply indebted to Mr. V.R.Rajan, Faculty in charge of our Practice School II at Chenna

    station, BITS-Pilani, for his constant support, encouragement and guidance in writing this report.I am also

    indebted to my Practice School Instructor, Ms. R. Bharathi, Lecturer, Birla Institute of Technology and

    Science, Pilani for her constant support and encouragement. I wish to express my gratitude to

    Dr.A.S.V.Sharma, scientist-in-charge, Central Electronics Engineering Research Institute, Chennai for giving

    me an opportunity to work in CEERI.

    I wish to express my appreciation to the enormous help given by my mentors, Dr.A.Gopal, & Mr

    A.S.S Sarma and also to my friends who spared a great amount of their valuable time in going through the

    manuscript and providing suggestions and error-free proofreading.

    I am very much thankful to all the consultants for their constant support in the explanation of concepts

    and clearing of doubts during the course of project work.

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    6/42

    TABLE OF CONTENTS

    Acknowledgments 05

    1. Background and Profile of Organization 072. Aim/Scope of the PS-II Project 083. Introduction

    3.1 History of Medicinal Plants 08

    3.2 Components of Powdered Leaf 09

    3.3 Image Processing 12

    3.4 MATLAB Image Processing toolbox 16

    4. Methodology

    4.1 Canny edge detector 17

    4.2 Morphology Fundamentals: Dilation and Erosion 19

    4.2.1 Dilation 24

    4.2.2 Erosion 26

    5. Results and Discussion

    5.1 Starch Grain 31

    5.2 Fibers 36

    6. Conclusion 41

    7. References 42

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    7/42

    Background and Profile of Organization

    History

    CSIR-Central Electronics Engineering Research Institute, popularly known as CSIR-CEERI, is a

    constituent establishment of the Council of Scientific and Industrial Research (CSIR), New Delhi. The

    foundation stone of the institute was laid on 21st September , 1953 by the then Prime Minister Pt. Jawahar

    Lal Nehru. The actual R&D work started towards the end of 1958. The Institute (CSIR-CEERI) has since

    blossomed into a center of excellence for development of technology and for advanced research in

    electronics. Over the years the institute has developed a number of products and processes and has

    established facilities to meet the emerging needs of electronics industry.

    Aim & Purpose

    To carry out R&D in electronic devices and systems To assist industry in technology absorption, up gradation and diversification To provide R&D services to industry and users in design, fabrication and testing To provide technical services for specific needs towards product development, precision and

    quality

    Areas of Research

    Advanced Sensor Technologies

    Process Control Instrumentation & Automation Machine Vision Technologies

    Achievements

    Space qualification of hybrid microcircuits. Design of serial data controller chip. Development of high voltage deflection transistor for TV applications. Development of space-qualified metalized alumina substrates and Ku band down converter. Development of hybrid PIN/FET for long haul optical communication system. Development of laboratory model of 2x35 kVA DC drive for mining loco. Development of laboratory prototype of Electric Vehicle.

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    8/42

    Aim/Scope of the PS-II Project

    The project is about identifying the various components like starch grain, stone cells, fibres

    etc. from the magnified images of the powdered plants using image segmentation. Image

    segmentation is done by using image processing toolbox available in MATLAB.

    Introduction

    History of Medicinal Plants

    In India, herbal medicine dates back several thousand years to the Rig-Veda. Many of the

    herbal remedies used by the Greeks and Romans were an effective treatment that has become

    incorporated into modern medicine. Plants have been part of our lives since the beginning of time

    We get numerous products from plants, most of them not only good and beneficial but also crucia

    to our existence. The use of plants to heal or combat illness is probably as old as humankind. Ou

    of these simple beginnings came the pharmaceutical industry. Yet today, the view of plants is very

    different from how it all started.

    A long time ago, plants were viewed and appreciated with the utmost reverence. Most

    people today greatly ignore the existence of plants and seriously downplay their importance. Mos

    cannot fathom growing their own plants such as for food, let alone appreciating them, or using

    them for personal healing.

    The pharmaceutical industry refuses to give them credit for pretty much anything, as it istoday almost 100% synthetic in nature, while the governing agencies continuously make it a battle

    to certify anything herbal or plant based. Yet these same corporations have no problem promoting

    synthetic and chemical medicines that are continuously proving dangerous in various ways. In

    order for something to be profitable today it needs a patent, and nature in its unmodified form

    cannot be patented. Thus today we extracted what we wanted out of plants, synthesized it and

    patented the final products as pharmaceuticals, or modified entire plants, such as for the production

    of food to make them profitable for some and not others.

    However, the tides are changing. A quiet, yet significant revolution is under way. More

    and more people are remembering their roots. More and more people are returning to natureto

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    9/42

    Mother Earth. More and more people want the benefits that plants can offer us, whether for

    medicine or healing, in their natural state.

    The earliest foundations of Ayurveda were built on a synthesis of traditional herb practices

    combined with new therapies.

    Plants useful in Medicine:

    Aloe Vera: Skin ailments and wounds Bitter gourd: for controlling blood pressure Bitter leaf: Intestinal ailments Dandelion: Liver, Kidney and Spleen problems Eucalyptus: cough, cold and painkillers Garlic: antibiotic, cardiovascular diseases Ginger: Nausea Guava: gastrointestinal ailments Lavender: antiseptic Neem: Malaria, Rheumatism and skin infections Papaya: for treating wounds Tulasi and Turmeric: Digestion, Antibiotics

    Components of Powdered Leaf

    Crystals

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    10/42

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    11/42

    Starch Grains

    Stone Cells

    Trichomes

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    12/42

    Image Processing

    The field of digital image processing refers to processing digital images by means of a digita

    computer. Digital image is composed of a finite number of elements, each of which has a particular

    location and of a region containing the text, preprocessing that image, extracting (segmenting) the

    individual characters, value. These elements are called picture elements, image elements, pels, and pixels

    Pixel is the term used most widely to denote the elements of a digital image. Converting an image into

    digital format can be done with a digital camera, a scanner, or by converting a moving image on a video

    tape into digital format.

    The processes of acquiring an image describing the characters in a form suitable for computer

    processing, and recognizing those individual characters are in the scope of what we call digital image

    processing. Digital image processing encompasses processes whose inputs and outputs are images and, in

    addition, encompasses processes that extract attributes from images, up to and including the recognition

    of individual objects. Digital image Processing can be divided into three types of processes:

    Low level Processes Medium level processes High level Processes

    Low level Processes:These involve primitive processes such as image processing to reduce the noise.

    Contrast enhancement and image sharpening. Low level Processes are characterized by the fact that both

    inputs and outputs are images.

    Medium level processes:These involve task such as segmentation (portioning of image into regions or

    objects) and classification of these objects. Mid-level processes are characterized by the fact that inputs

    generally are images, but outputs are the attributes of these images.

    High level Processes:These involve making sense of an ensemble of recognized objects, as in imageanalyzes and at the far end performing the functions relates to human vision.

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    13/42

    Fundamental Steps of Image Processing

    All the methodologies that can be applied to images for different purposes and possibly with

    objectives are as follows:

    Image acquisition Image enhancement Image restoration colour Image processing Wavelets and multi solution processing Compression Morphological processing Segmentation Representation & description Object recognition

    Image acquisition: This stage involves preprocessing, such as scaling. This can be as simple as being

    given a digital image.

    Image enhancement:The idea is to bring out detail that is obscured, or simply to highlight certain features

    of interest in an image. It is abused on human subjective preferences regarding what constitutes a good

    enhancement result.

    Image restoration:This deals with improving the appearance of an image. However, unlike enhancementwhich is subjective, image restoration is objective, in the sense that restoration techniques tend to be based

    on mathematical or probabilistic models of image degradation.

    Color Image processing:Color is used as the basis for extracting features of interest in an image. It has

    been gaining in importance because of the significant increase in the use of digital images over the internet

    Wavelets:These are the foundation for representing images in various degrees of resolution.

    Compression: It deals with techniques for reducing the storage required to save an image, or the bandwidth

    required to transmit it. Although storage technology has improved significantly over the past decade, the

    same cannot be said for transmission capacity.

    Morphological processing: It deals with tools for extracting image components that are useful in the

    representation and description of shape.

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    14/42

    Compression:It deals with techniques for reducing the storage required to save an image, or the bandwidth

    required to transmit it. Although storage technology has improved significantly over the past decade, the

    same cannot be said for transmission capacity.

    Morphological processing: It deals with tools for extracting image components that are useful in the

    representation and description of shape.

    Segmentation: The procedures partition an image into its constituent parts or objects. In general,

    autonomous segmentation is one of the most difficult tasks in digital image processing. A rugged

    segmentation procedure brings the process a long way toward successful solution of imaging problems

    that require objects to be identified individually. On the other hand, weak or erratic segmentation

    algorithms almost always guarantee eventual failure. In general, the more accurate the segmentation, the

    more likely recognition is to succeed.

    Representation and description:This almost always follow the output of a segmentation stage, which

    usually is raw pixel data, constituting either the boundary of a region(i.e. The set of pixels separating one

    image region from another) or all the points in the region itself. Description, also called feature selection

    deals with extracting attributes that result in some quantitative information of interest or are basic for

    differentiating one class of objects from another.

    Recognition:This is process that assigns a label (e.g., leaf1) to an object based on its descriptors.

    The image processing toolbox is a collection of functions that extend the capability of the MATLAB

    numeric computing environment. The toolbox supports a wide range of image processing operations

    including

    Spatial image transformation Morphological operations Neighbourhood and operations Linear filtering and filter design Transforms Image analysis and enhancement Image registration Deblurring Region of interest operations

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    15/42

    Image Formats

    The following are some of the image formats:

    BMP - Bitmap Image File JPEG - Joint Picture Expert Group PNG - Portable Network Graphics TIFFTagged Image File Format

    Most images you find on the Internet are JPEG-images which are the name for one of the most widely

    used compression standards for images. In computing, JPEG is a commonly used method of lossy

    compression for digital photography (image). The degree of compression can be adjusted, allowing a

    selectable tradeoff between storage size and image quality. JPEG typically achieves 10:1 compression

    with little perceptible loss in image quality. If you have stored an image you can usually see from the

    suffix what format it is stored in. For example, an image named myimage.jpg is stored in the JPEG format

    We can load an image of this format into MATLAB.

    Advantages of Image Processing

    One of the biggest advantages of digital imaging is the ability of the operator to post-process the

    image. Post-processing of the image allows the operator to manipulate the pixel shades to correct image

    density and contrast, as well as perform other processing functions that could result in improved diagnosis

    The processing of images is faster and more cost-effective. One needs less time for processing, as well as

    less film and other photographing equipment. Copying a digital image is easy, and the quality of the image

    stays good unless it is compressed. Digital imaging allows the electronic transmission of images to third-

    party providers, referring dentists, consultants, and insurance carriers via a modem.

    Digital imaging is also environmentally friendly since it does not require chemical processing. It

    is well known that used film processing chemicals contaminate the water supply system with harmful

    metals such as the silver found in used fixer solution. With the advent of electronic record systems, images

    can be stored in the computer memory and easily retrieved on the same computer screen and can be saved

    indefinitely or be printed on paper or film if necessary. All digital imaging systems can be networked intopractice management software programs facilitating integration of data. With networks, the images can

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    16/42

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    17/42

    interest (ROIs). With toolbox algorithms you can restore degraded images, detect and measure features,

    analyze shapes and textures, and adjust color balance.

    Key Features

    Image enhancement, filtering, and deblurring Image analysis, including segmentation, morphology, feature extraction, and measurement Spatial transformations and intensity-based image registration methods Image transforms, including FFT, DCT, Radon, and fan-beam projection Workflows for processing, displaying, and navigating arbitrarily large images Interactive tools, including ROI selections, histograms, and distance measurements DICOM file import and export

    Methodology

    Canny edge detector

    Canny's aim was to discover the optimal edge detection algorithm. In this situation, an "optimal" edge

    detector means:

    good detectionthe algorithm should mark as many real edges in the image as possible. good localizationedges marked should be as close as possible to the edge in the real image.

    minimal responsea given edge in the image should only be marked once, and where possibleimage noise should not create false edges.

    To satisfy these requirements Canny used the calculus of variationsa technique which finds the function

    which optimizes a given functional. The optimal function in Canny's detector is described by the sum of

    four exponential terms, but it can be approximated by the first derivative of a Gaussian.

    Noise reduction

    The image after a 5x5 Gaussian mask has been passed across each pixel.

    Because the Canny edge detector is susceptible to noise present in raw unprocessed image data, it uses a

    filter based on a Gaussian (bell curve), where the raw image is convolved with a Gaussian filter. The result

    is a slightly blurred version of the original which is not affected by a single noisy pixel to any significan

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    18/42

    degree. Here is an example of a 5x5 Gaussian filter, used to create the image to the right, with \sigma =

    1.4. (The asterisk denotes a convolution operation.)

    Finding the intensity gradient of the image

    A binary edge map, derived from the Sobel operator, with a threshold of 80. The edges are colouredto indicate the edge direction: yellow for 0 degrees, green for 45 degrees, blue for 90 degrees and red for

    135 degrees.

    An edge in an image may point in a variety of directions, so the Canny algorithm uses four filters

    to detect horizontal, vertical and diagonal edges in the blurred image. The edge detection operator

    (Roberts, Prewitt, Sobel for example) returns a value for the first derivative in the horizontal direction

    (Gx) and the vertical direction (Gy). From this the edge gradient and direction can be determined:

    The edge direction angle is rounded to one of four angles representing vertical, horizontal and the two

    diagonals (0, 45, 90 and 135 degrees for example).

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    19/42

    Tracing edges through the image and hysteresis thresholding

    Large intensity gradients are more likely to correspond to edges than small intensity gradients. It

    is in most cases impossible to specify a threshold at which a given intensity gradient switches from

    corresponding to an edge into not doing so. Therefore Canny uses thresholding with hysteresis.

    Thresholding with hysteresis requires two thresholdshigh and low. Making the assumption that

    important edges should be along continuous curves in the image allows us to follow a faint section of a

    given line and to discard a few noisy pixels that do not constitute a line but have produced large gradients

    Therefore we begin by applying a high threshold. This marks out the edges we can be fairly sure are

    genuine. Starting from these, using the directional information derived earlier, edges can be traced through

    the image. While tracing an edge, we apply the lower threshold, allowing us to trace faint sections of edges

    as long as we find a starting point.

    Morphology Fundamentals: Dilation and Erosion

    To see how morphological processing can solve an image processing problem, view the ImageProcessing Toolbox watershed segmentation example.

    Understanding Dilation and Erosion

    Morphologyis a broad set of image processing operations that process images based on shapes.Morphological operations apply a structuring element to an input image, creating an output image of thesame size. In a morphological operation, the value of each pixel in the output image is based on acomparison of the corresponding pixel in the input image with its neighbors. By choosing the size andshape of the neighborhood, you can construct a morphological operation that is sensitive to specific

    shapes in the input image.

    The most basic morphological operations are dilation and erosion. Dilation adds pixels to theboundaries of objects in an image, while erosion removes pixels on object boundaries. The number ofpixels added or removed from the objects in an image depends on the size and shape of thestructuringelementused to process the image.

    In the morphological dilation and erosion operations, the state of any given pixel in the outputimage is determined by applying a rule to the corresponding pixel and its neighbors in the input image.The rule used to process the pixels defines the operation as a dilation or an erosion. This table lists therules for both dilation and erosion.

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    20/42

    Rules for Dilation and Erosion

    Operation Rule

    Dilation The value of the output pixel is the maximumvalue of all the pixels in the input pixel'sneighborhood. In a binary image, if any of the pixels is set to the value 1, the output pixel

    is set to 1.

    Erosion The value of the output pixel is the minimumvalue of all the pixels in the input pixel'sneighborhood. In a binary image, if any of the pixels is set to 0, the output pixel is set to 0.

    The following figure illustrates the dilation of a binary image. Note how the structuring element definesthe neighborhood of the pixel of interest, which is circled. (SeeUnderstanding Structuring Elementsformore information.) The dilation function applies the appropriate rule to the pixels in the neighborhoodand assigns a value to the corresponding pixel in the output image. In the figure, the morphologicaldilation function sets the value of the output pixel to 1 because one of the elements in the neighborhooddefined by the structuring element is on.

    Morphological Dilation of a Binary Image

    The following figure illustrates this processing for a grayscale image. The figure shows the processingof a particular pixel in the input image. Note how the function applies the rule to the input pixel'sneighborhood and uses the highest value of all the pixels in the neighborhood as the value of thecorresponding pixel in the output image.

    Morphological Dilation of a Grayscale Image

    http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22581http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22581http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22581http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22581
  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    21/42

    Processing Pixels at Image Borders (Padding Behavior)

    Morphological functions position the origin of the structuring element, its center element, over the pixelof interest in the input image. For pixels at the edge of an image, parts of the neighborhood defined bythe structuring element can extend past the border of the image.

    To process border pixels, the morphological functions assign a value to these undefined pixels, as if thefunctions had padded the image with additional rows and columns. The value of these padding pixelsvaries for dilation and erosion operations. The following table describes the padding rules for dilationand erosion for both binary and grayscale images.

    Rules for Padding Images

    Operation Rule

    Dilation Pixels beyond the image border are assigned the minimum value afforded by the datatype.

    For binary images, these pixels are assumed to be set to 0. For grayscale images, theminimum value for uint8 images is 0.

    Erosion Pixels beyond the image border are assigned the maximumvalue afforded by the datatype.

    For binary images, these pixels are assumed to be set to 1. For grayscale images, themaximum value for uint8 images is 255.

    Note By using the minimum value for dilation operations and the maximum value for erosionoperations, the toolbox avoids border effects, where regions near the borders of the output

    image do not appear to be homogeneous with the rest of the image. For example, if erosionpadded with a minimum value, eroding an image would result in a black border around theedge of the output image.

    Understanding Structuring Elements

    An essential part of the dilation and erosion operations is the structuring element used to probe the inputimage. A structuring element is a matrix consisting of only 0's and 1's that can have any arbitrary shapeand size. The pixels with values of 1 define the neighborhood.

    Two-dimensional, orflat, structuring elements are typically much smaller than the image being

    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 dilation or erosion processing.

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    22/42

    Three-dimensional, or nonflat, structuring elements use 0's and 1's to define the extent of the structuringelement in thex- andy-planes and add height values to define the third dimension.

    The Origin of a Structuring Element

    The morphological functions use this code to get the coordinates of the origin of structuring elements of

    any size and dimension.

    origin = floor((size(nhood)+1)/2)

    (In this code nhood is the neighborhood defining the structuring element. Because structuring elementsare MATLABobjects, you cannot use the size of the STREL object itself in this calculation. You mustuse the STREL getnhood method to retrieve the neighborhood of the structuring element from the

    STREL object. For information about other STREL object methods, see thestrelfunction referencepage.)

    For example, the following illustrates a diamond-shaped structuring element.

    Origin of a Diamond-Shaped Structuring Element

    Creating a Structuring Element

    The toolbox dilation and erosion functions accept structuring element objects, called STRELs. You usethe strel function to create STRELs of any arbitrary size and shape. The strel function also includesbuilt-in support for many common shapes, such as lines, diamonds, disks, periodic lines, and balls.

    Note You typically choose a structuring element the same size and shape as the objects youwant to process in the input image. For example, to find lines in an image, create a linearstructuring element.

    For example, this code creates a flat, diamond-shaped structuring element.

    se = strel('diamond',3)

    se =

    http://www.mathworks.in/help/images/ref/strel.htmlhttp://www.mathworks.in/help/images/ref/strel.htmlhttp://www.mathworks.in/help/images/ref/strel.htmlhttp://www.mathworks.in/help/images/ref/strel.html
  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    23/42

    Flat STREL object containing 25 neighbors.

    Decomposition: 3 STREL objects containing a total of 13 neighbors

    Neighborhood:

    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 Decomposition

    To enhance performance, the strel function might break structuring elements into smaller pieces, atechnique known asstructuring element decomposition.

    For example, dilation by an 11-by-11 square structuring element can be accomplished by dilating firstwith a 1-by-11 structuring element, and then with an 11-by-1 structuring element. This results in a

    theoretical speed improvement of a factor of 5.5, although in practice the actual speed improvement issomewhat less.

    Structuring element decompositions used for the 'disk' and 'ball' shapes are approximations; all otherdecompositions are exact. Decomposition is not used with an arbitrary structuring element unless it is aflat structuring element whose neighborhood matrix is all 1's.

    To view the sequence of structuring elements used in a decomposition, use the STREL getsequencemethod. The getsequence function returns an array of the structuring elements that form thedecomposition. For example, here are the structuring elements created in the decomposition of adiamond-shaped structuring element.

    sel = strel('diamond',4)

    sel =

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    24/42

    Flat STREL object containing 41 neighbors.

    Decomposition: 3 STREL objects containing a total of 13 neighbors

    Neighborhood:

    0 0 0 0 1 0 0 0 0

    0 0 0 1 1 1 0 0 0

    0 0 1 1 1 1 1 0 0

    0 1 1 1 1 1 1 1 0

    1 1 1 1 1 1 1 1 1

    0 1 1 1 1 1 1 1 0

    0 0 1 1 1 1 1 0 0

    0 0 0 1 1 1 0 0 0

    0 0 0 0 1 0 0 0 0

    Dilating an Image

    To dilate an image, use the imdilate function. The imdilate function accepts two primary arguments:

    The input image to be processed (grayscale, binary, or packed binary image) A structuring element object, returned by the strel function, or a binary matrix defining the

    neighborhood of a structuring element

    imdilate also accepts two optional arguments: SHAPE and PACKOPT. The SHAPE argument affects

    the size of the output image. The PACKOPT argument identifies the input image as packed binary.(Packing is a method of compressing binary images that can speed up the processing of the image. Seethebwpackreference page for information.)

    This example dilates a simple binary image containing one rectangular object.

    BW = zeros(9,10);

    http://www.mathworks.in/help/images/ref/bwpack.htmlhttp://www.mathworks.in/help/images/ref/bwpack.htmlhttp://www.mathworks.in/help/images/ref/bwpack.htmlhttp://www.mathworks.in/help/images/ref/bwpack.html
  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    25/42

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    26/42

    BW2 = imdilate(BW,SE)

    Eroding an Image

    To erode an image, use the imerode function. The imerode function accepts two primary arguments:

    The input image to be processed (grayscale, binary, or packed binary image) A structuring element object, returned by the strel function, or a binary matrix defining the

    neighborhood of a structuring element

    imerode also accepts three optional arguments: SHAPE, PACKOPT, and M.

    The SHAPE argument affects the size of the output image. The PACKOPT argument identifies the inputimage as packed binary. If the image is packed binary, M identifies the number of rows in the originalimage. (Packing is a method of compressing binary images that can speed up the processing of theimage. See thebwpackreference page for more information.)

    The following example erodes the binary image circbw.tif:

    1. Read the image into the MATLAB workspace.BW1 = imread('circbw.tif');

    2. Create a structuring element. The following code creates a diagonal structuring element object.(For more information about using the strel function, seeUnderstanding Structuring Elements.)

    3. SE = strel('arbitrary',eye(5));4. SE=5.6. Flat STREL object containing 5 neighbors.7.8. Neighborhood:9. 1 0 0 0 010. 0 1 0 0 011. 0 0 1 0 012. 0 0 0 1 0

    http://www.mathworks.in/help/images/ref/bwpack.htmlhttp://www.mathworks.in/help/images/ref/bwpack.htmlhttp://www.mathworks.in/help/images/ref/bwpack.htmlhttp://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22581http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22581http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22581http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22581http://www.mathworks.in/help/images/ref/bwpack.html
  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    27/42

    0 0 0 0 1

    13.Call the imerode function, passing the image BW and the structuring element SE as arguments.BW2 = imerode(BW1,SE);

    Notice the diagonal streaks on the right side of the output image. These are due to the shape of thestructuring element.

    imshow(BW1)

    figure, imshow(BW2)

    Combining Dilation and Erosion

    Dilation and erosion are often used in combination to implement image processing operations.For example, the definition of a morphological opening of an image is an erosion followed by a dilation,using the same structuring element for both operations. The related operation, morphological closingofan image, is the reverse: it consists of dilation followed by an erosion with the same structuring element.

    The following section uses imdilate and imerode to illustrate how to implement a morphologicalopening. Note, however, that the toolbox already includes the imopen function, which performs thisprocessing. The toolbox includes functions that perform many common morphological operations. See

    Dilation- and Erosion-Based Functionsfor a complete list.

    http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-14379http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-14379http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-14379
  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    28/42

    Morphological Opening

    You can use morphological opening to remove small objects from an image while preserving theshape and size of larger objects in the image. For example, you can use the imopen function to removeall the circuit lines from the original circuit image, circbw.tif, creating an output image that containsonly the rectangular shapes of the microchips.

    To morphologically open the image, perform these steps:

    1. Read the image into the MATLAB workspace.BW1 = imread('circbw.tif');

    2. Create a structuring element.SE = strel('rectangle',[40 30]);

    The structuring element should be large enough to remove the lines when you erode the image, but notlarge enough to remove the rectangles. It should consist of all 1's, so it removes everything but largecontiguous patches of foreground pixels.

    3. Erode the image with the structuring element.4. BW2 = imerode(BW1,SE);

    imshow(BW2)

    This removes all the lines, but also shrinks the rectangles.

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    29/42

    5. To restore the rectangles to their original sizes, dilate the eroded image using the samestructuring element, SE.

    6. BW3 = imdilate(BW2,SE);imshow(BW3)

    Dilation- and Erosion-Based Functions

    This section describes two common image processing operations that are based on dilation and erosion:

    Skeletonization Perimeter determination

    This table lists other functions in the toolbox that perform common morphological operations that arebased on dilation and erosion. For more information about these functions, see their reference pages.

    Dilation- and Erosion-Based Functions

    Function Morphological Definition

    bwhitmiss Logical AND of an image, eroded with one structuring element, and the image'scomplement, eroded with a second structuring element.

    imbothat Subtracts the original image from a morphologically closed version of the image. Can beused to find intensity troughs in an image.

    imclose Dilates an image and then erodes the dilated image using the same structuring element forboth operations.

    imopen Erodes an image and then dilates the eroded image using the same structuring element forboth operations.

    imtophat Subtracts a morphologically opened image from the original image. Can be used to

    enhance contrast in an image.

    http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22448http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22448http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-34991http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-34991http://www.mathworks.in/help/images/ref/bwhitmiss.htmlhttp://www.mathworks.in/help/images/ref/imbothat.htmlhttp://www.mathworks.in/help/images/ref/imbothat.htmlhttp://www.mathworks.in/help/images/ref/imclose.htmlhttp://www.mathworks.in/help/images/ref/imopen.htmlhttp://www.mathworks.in/help/images/ref/imopen.htmlhttp://www.mathworks.in/help/images/ref/imtophat.htmlhttp://www.mathworks.in/help/images/ref/imtophat.htmlhttp://www.mathworks.in/help/images/ref/imtophat.htmlhttp://www.mathworks.in/help/images/ref/imopen.htmlhttp://www.mathworks.in/help/images/ref/imclose.htmlhttp://www.mathworks.in/help/images/ref/imbothat.htmlhttp://www.mathworks.in/help/images/ref/bwhitmiss.htmlhttp://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-34991http://www.mathworks.in/help/images/morphology-fundamentals-dilation-and-erosion.html#f18-22448
  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    30/42

    Skeletonization

    To reduce all objects in an image to lines, without changing the essential structure of the image,use the bwmorph function. This process is known asskeletonization.

    BW1 = imread('circbw.tif');

    BW2 = bwmorph(BW1,'skel',Inf);

    imshow(BW1)

    figure, imshow(BW2)

    Perimeter Determination

    The bwperim function determines the perimeter pixels of the objects in a binary image. A pixel isconsidered a perimeter pixel if it satisfies both of these criteria:

    The pixel is on. One (or more) of the pixels in its neighborhood is off.

    For example, this code finds the perimeter pixels in a binary image of a circuit board.

    BW1 = imread('circbw.tif');

    BW2 = bwperim(BW1);

    imshow(BW1)

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    31/42

    Results and Discussion

    Starch Grain

    MATLAB Code

    %Identifying Starch Grain from the microscopic images provided and finding its

    %parameters like perimeter, max & min axis length etc.

    clc; %clears the command screen

    clear all; %clears all the variables

    %Reading the Microscopic image of the Starch Grain

    rbg = imread('sg1', 'tif'); %reads the given image to the

    defined variable

    figure, imshow(rbg, 'InitialMagnification', 10) %displays the variable as an

    image at specified magnification

    title('Input Image of Starch Grain') %displays the string as the

    title of the image

    %Converting the RGB image To Grayscale of same size

    grayscale = rgb2gray(rbg); %convets the colour image to

    a grayscale image of same size

    figure, imshow(grayscale, 'InitialMagnification', 10) %displays the variable as an

    image at specified magnification

    title('Grayscale Image') %displays the string as the

    title of the image

    %Defining a flat morphological structuring element "seD"

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    32/42

    seD = strel('diamond',1); %creates a morphological

    structuring element

    %Smoothening the object using the pre-defined flat morphological structuring element

    smooth = imerode(grayscale, seD); %erodes the image using the

    defined structuring element

    figure, imshow(smooth, 'InitialMagnification', 10) %displays the variable as an

    image at specified magnification

    title('Smoothened Image') %displays the string as the

    title of the image

    %Defining a nonflat morphological structuring element "seB"

    seB = strel('ball',45,1,4); %creates a morphological

    structuring element

    % Dilating the image using the pre-defined nonflat morphological structuring element

    dilated = imdilate(smooth,seB); %dilate the image using the

    defined structuring element

    figure, imshow(dilated, 'InitialMagnification', 10) %displays the variable as an

    image at specified magnification

    title('Dilated Image') %displays the string as the

    title of the image

    %Finding edges in grayscale image using canny filter

    filtered=edge(dilated,'canny',sqrt(3)-1, sqrt(3)); %finds edges in a grayscale

    image

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    33/42

    figure, imshow(filtered, 'InitialMagnification', 25) %displays the variable as an

    image at specified magnification

    title('Output Image') %displays the string as the

    title of the image

    %Measuring various parameters of the image

    regionprops(filtered, 'Perimeter') %measures properties of image

    regions

    regionprops(filtered, 'MajorAxisLength') %measures properties of image

    regions

    regionprops(filtered, 'MinorAxisLength') %measures properties of image

    regions

    %Coded using Matlab R2012b

    Output

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    34/42

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    35/42

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    36/42

    Measurements

    Fibres

    MATLAB Code 1

    %Identifying fibres from the microscopic images provided

    clc;

    clear all;

    %Reading the Microscopic image of the Fibre

    f1 = imread('f3', 'tif');

    figure, imshow(f1, 'InitialMagnification', 10)

    title('Input Image of Fibres')

    %Converting the RGB image To Grayscale of same size

    f2 = rgb2gray(f1);figure, imshow(f2, 'InitialMagnification', 10)

    title('Grayscale Image')

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    37/42

    %Running aloop for all the possible angles

    fora=0:1:180

    SE = strel('line', 50, a); %Defining a morphological structuring element

    f3 = imdilate(f2, SE); % Dialating the image using the pre-defined

    nonflat morphological structuring element

    end

    %Preparing Output Image

    f4=f3-f2;

    figure, imshow(f4, 'InitialMagnification', 25)

    title('Output Image')

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    38/42

    MATLAB Code 2%Identifying fibres from the microscopic images provided

    clc;

    clear all;

    %Reading the Microscopic image of the Fibre

    f1 = imread('f3', 'tif');

    figure, imshow(f1, 'InitialMagnification', 10)

    title('Input Image of Fibres')

    %Converting the RGB image To Grayscale of same size

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    39/42

    f2 = rgb2gray(f1);

    figure, imshow(f2, 'InitialMagnification', 10)

    title('Grayscale Image')

    a = input('Input angle Value:'); %reads a angle value from the user

    SE = strel('line', 100, a); %Defining a morphological structuring

    element

    f3 = imdilate(f2, SE); % Dialating the image using the pre-

    defined nonflat morphological structuring element

    figure, imshow(f3, 'InitialMagnification', 25)

    title('Output Image')

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    40/42

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    41/42

    Conclusion

    In this project I have successfully identified two components i.e. starch grains and fibres. These codes can

    be used if the magnification of the images is very high. The code written for starch grain is highly efficient

    and physical parameters can also be calculated. On the other hand codes written for fibres have noise in

    them. If the project is completed by identifying the other components then a database of values can be

    created and can be compared to the sample powder to identify the leaf. This can be done by seeing the

    presence and absence the components, comparing the physical values of the components and density of

    presence in the sample image.

  • 8/13/2019 Final Report - Sreenivas Mamidi - 2009A3PS101P

    42/42