You are on page 1of 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 SCHOOL II STATION OF

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, PILANI PILANI (JUNE, 2013)

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 SCHOOL II STATION OF

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, PILANI PILANI (JUNE, 2013)

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE PILANI (RAJASTHAN) Practice School Division

Station:

CSIR-CEERI

Centre: Chennai

Duration: 51/4 months Date Of Start: 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 Name and Designation Of the expert : DR. A.Gopal, Scientist & Mr. A.S.S.Sarma, Scientist Mr. V.R.RAJAN Sreenivas Mamidi / 2009A3PS101P

Name Of the PS Faculty: Keywords: Project Areas: Abstract:

Image Processing, Matlab, Starch Grain, Fibers, Canny filter, Dilation, Erosion Identification and quantization using Image Processing.

The project is about identifying the various components in the images of the sample powders. For this we use 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 Date

Signature Of PS Faculty Date

BIRLA INSTITUE OF TECHNOLOGY & SCIENCE PILANI (RAJASTHAN) PRACTICE SCHOOL DIVISION

Response Option Sheet Station: CSIR-CEERI


SREENIVAS MAMIDI / 2009A3PS101P

Centre: CHENNAI

ID No. & Name:

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. Code No. 1. 2. Response Options A new course can be designed out of this project Course No. & Name NO

The project can help modification of the course content NO Of some of the existing courses.

3.

The project can be used directly in some of the existing NO Compulsory Discipline courses (CDC) /Disciplines Compulsory Discipline courses (DCOC) / Emerging Area (EA) etc. Courses

4.

The project can be used in preparatory courses like NO Analysis and Application Oriented Courses (AAOC)/ Engineering Science (ES)/ Technical Art (TA) and Core Courses.

5.

This project cannot come under any of the above- YES mentioned options as it relates to the professional work of the host organization.

Signature Of Student

Signature Of Faculty

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 Chennai 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.

TABLE OF CONTENTS
Acknowledgments 1. Background and Profile of Organization 2. Aim/Scope of the PS-II Project 3. Introduction 3.1 History of Medicinal Plants 3.2 Components of Powdered Leaf 3.3 Image Processing 3.4 MATLAB Image Processing toolbox 4. Methodology 4.1 Canny edge detector 4.2 Morphology Fundamentals: Dilation and Erosion 4.2.1 Dilation 4.2.2 Erosion 5. Results and Discussion 5.1 Starch Grain 5.2 Fibers 6. Conclusion 7. References 31 36 41 42 17 19 24 26 08 09 12 16 05 07 08

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.

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 crucial to our existence. The use of plants to heal or combat illness is probably as old as humankind. Out 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. Most 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 is today 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 nature to

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

Fibres

Parenchyma Cells

Sclereids

10

Starch Grains

Stone Cells

Trichomes

11

Image Processing

The field of digital image processing refers to processing digital images by means of a digital 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 image analyzes and at the far end performing the functions relates to human vision.

12

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 enhancement, which 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.

13

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

14

Image Formats The following are some of the image formats: BMP - Bitmap Image File JPEG - Joint Picture Expert Group PNG - Portable Network Graphics TIFF Tagged 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 thirdparty 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 into practice management software programs facilitating integration of data. With networks, the images can

15

be viewed in more than one room and can be used in conjunction with pictures obtained with an optical camera to enhance the patients understanding of treatment.

Applications of Image Processing Agricultural (Fruit grading, harvest control, seeding, fruit picking ...) Communications (compression, video conferencing, tele. X ...) Character recognition (printed and handwritten) Commercial (Bar code reading, bank cheques, signature ...) Document processing (electronic circuits, mechanical drawings, music ...) Human (Heads and faces, hands, body ...) Industrial (Inspection, part pose estimation and recognition, control...) Medical (X-rays, CT, NMR, PET, SPECT, ultrasound, intensity ...) Military (tracking, detection ...) Police (fingerprints, surveillance, DNA analysis, biometry ...) Traffic and transport (Road, airport, seaport, license identification ...) X application (remote sensing, astronomy, biology, surveillance ...)

In general the fields that use digital image processing techniques may be divided into forensics, criminology, morphology, photography, remote sensing, medical imaging, transportation and military applications.

MATLAB Image Processing toolbox Image Processing Toolbox provides a comprehensive set of reference-standard algorithms and graphical tools for image processing, analysis, visualization, and algorithm development. You can perform image enhancement, image deblurring, feature detection, noise reduction, image segmentation, spatial transformations, and image registration. Many toolbox functions are multithreaded to take advantage of multicore and multiprocessor computers. Image Processing Toolbox supports a diverse set of image types, including high dynamic range, gigapixel resolution, ICC-compliant colour, and tomographic. Graphical tools let you explore an image, examine a region of pixels, adjust the contrast, create contours or histograms, and manipulate regions of

16

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 detection the algorithm should mark as many real edges in the image as possible. good localization edges marked should be as close as possible to the edge in the real image. minimal response a given edge in the image should only be marked once, and where possible, image noise should not create false edges.

To satisfy these requirements Canny used the calculus of variations a 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 significant

17

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 coloured to 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).

18

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 thresholds high 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 Image Processing Toolbox watershed segmentation example. Understanding Dilation and Erosion Morphology is 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 the same size. In a morphological operation, the value of each pixel in the output image is based on a comparison of the corresponding pixel in the input image with its neighbors. By choosing the size and shape 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 the boundaries of objects in an image, while erosion removes pixels on object boundaries. The number of pixels added or removed from the objects in an image depends on the size and shape of the structuring element used to process the image. In the morphological dilation and erosion operations, the state of any given pixel in the output image 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 the rules for both dilation and erosion.

19

Rules for Dilation and Erosion Operation Rule Dilation The value of the output pixel is the maximum value of all the pixels in the input pixel's neighborhood. In a binary image, if any of the pixels is set to the value 1, the output pixel is set to 1. The value of the output pixel is the minimum value of all the pixels in the input pixel's neighborhood. In a binary image, if any of the pixels is set to 0, the output pixel is set to 0.

Erosion

The following figure illustrates the dilation of a binary image. Note how the structuring element defines the neighborhood of the pixel of interest, which is circled. (See Understanding Structuring Elements for more information.) The dilation function applies the appropriate rule to the pixels in the neighborhood and assigns a value to the corresponding pixel in the output image. In the figure, the morphological dilation function sets the value of the output pixel to 1 because one of the elements in the neighborhood defined 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 processing of a particular pixel in the input image. Note how the function applies the rule to the input pixel's neighborhood and uses the highest value of all the pixels in the neighborhood as the value of the corresponding pixel in the output image. Morphological Dilation of a Grayscale Image

20

Processing Pixels at Image Borders (Padding Behavior) Morphological functions position the origin of the structuring element, its center element, over the pixel of interest in the input image. For pixels at the edge of an image, parts of the neighborhood defined by the 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 the functions had padded the image with additional rows and columns. The value of these padding pixels varies for dilation and erosion operations. The following table describes the padding rules for dilation and 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 data type. For binary images, these pixels are assumed to be set to 0. For grayscale images, the minimum value for uint8 images is 0. Erosion Pixels beyond the image border are assigned the maximum value afforded by the data type. For binary images, these pixels are assumed to be set to 1. For grayscale images, the maximum value for uint8 images is 255. Note By using the minimum value for dilation operations and the maximum value for erosion operations, 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 erosion padded with a minimum value, eroding an image would result in a black border around the edge of the output image. Understanding Structuring Elements An essential part of the dilation and erosion operations is the structuring element used to probe the input image. A structuring element is a matrix consisting of only 0's and 1's that can have any arbitrary shape and size. The pixels with values of 1 define the neighborhood. Two-dimensional, or flat, 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 neighborhood of the structuring element. These pixels are also considered in dilation or erosion processing.

21

Three-dimensional, or nonflat, structuring elements use 0's and 1's to define the extent of the structuring element in the x- and y-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 elements are MATLAB objects, you cannot use the size of the STREL object itself in this calculation. You must use the STREL getnhood method to retrieve the neighborhood of the structuring element from the STREL object. For information about other STREL object methods, see the strel function reference page.) 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 use the strel function to create STRELs of any arbitrary size and shape. The strel function also includes built-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 you want to process in the input image. For example, to find lines in an image, create a linear structuring element. For example, this code creates a flat, diamond-shaped structuring element. se = strel('diamond',3) se =

22

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, a technique known as structuring element decomposition. For example, dilation by an 11-by-11 square structuring element can be accomplished by dilating first with 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 is somewhat less. Structuring element decompositions used for the 'disk' and 'ball' shapes are approximations; all other decompositions are exact. Decomposition is not used with an arbitrary structuring element unless it is a flat structuring element whose neighborhood matrix is all 1's. To view the sequence of structuring elements used in a decomposition, use the STREL getsequence method. The getsequence function returns an array of the structuring elements that form the decomposition. For example, here are the structuring elements created in the decomposition of a diamond-shaped structuring element. sel = strel('diamond',4) sel =

23

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. See the bwpack reference page for information.) This example dilates a simple binary image containing one rectangular object. BW = zeros(9,10);

24

BW(4:6,4:7) = 1 BW = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

To expand all sides of the foreground component, the example uses a 3-by-3 square structuring element object. (For more information about using the strel function, see Understanding Structuring Elements.) SE = strel('square',3) SE =

Flat STREL object containing 3 neighbors.

Neighborhood: 1 1 1 1 1 1 1 1 1

To dilate the image, pass the image BW and the structuring element SE to the imdilate function. Note how dilation adds a rank of 1's to all sides of the foreground object.

25

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 input image as packed binary. If the image is packed binary, M identifies the number of rows in the original image. (Packing is a method of compressing binary images that can speed up the processing of the image. See the bwpack reference 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, see Understanding 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 0 10. 0 1 0 0 0 11. 0 0 1 0 0 12. 0 0 0 1 0

26

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 the structuring 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 closing of an 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 morphological opening. Note, however, that the toolbox already includes the imopen function, which performs this processing. The toolbox includes functions that perform many common morphological operations. See Dilation- and Erosion-Based Functions for a complete list.

27

Morphological Opening You can use morphological opening to remove small objects from an image while preserving the shape and size of larger objects in the image. For example, you can use the imopen function to remove all the circuit lines from the original circuit image, circbw.tif, creating an output image that contains only 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 not large enough to remove the rectangles. It should consist of all 1's, so it removes everything but large contiguous 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.

28

5. To restore the rectangles to their original sizes, dilate the eroded image using the same structuring 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 are based 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's complement, eroded with a second structuring element. imbothat imclose imopen imtophat Subtracts the original image from a morphologically closed version of the image. Can be used to find intensity troughs in an image. Dilates an image and then erodes the dilated image using the same structuring element for both operations. Erodes an image and then dilates the eroded image using the same structuring element for both operations. Subtracts a morphologically opened image from the original image. Can be used to enhance contrast in an image.

29

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 as skeletonization. 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 is considered 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)

30

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; clear all;

%clears the command screen %clears all the variables

%Reading the Microscopic image of the Starch Grain

rbg = imread('sg1', 'tif'); defined variable figure, imshow(rbg, 'InitialMagnification', 10) image at specified magnification title('Input Image of Starch Grain') title of the image

%reads the given image to the %displays the variable as an %displays the string as the

%Converting the RGB image To Grayscale of same size

grayscale = rgb2gray(rbg); a grayscale image of same size figure, imshow(grayscale, 'InitialMagnification', 10) image at specified magnification title('Grayscale Image') title of the image

%convets the colour image to %displays the variable as an %displays the string as the

%Defining a flat morphological structuring element "seD"

31

seD = strel('diamond',1); structuring element

%creates a morphological

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

smooth = imerode(grayscale, seD); defined structuring element figure, imshow(smooth, 'InitialMagnification', 10) image at specified magnification title('Smoothened Image') title of the image

%erodes the image using the %displays the variable as an %displays the string as the

%Defining a nonflat morphological structuring element "seB"

seB = strel('ball',45,1,4); structuring element

%creates a morphological

% Dilating the image using the pre-defined

nonflat morphological structuring element

dilated = imdilate(smooth,seB); defined structuring element figure, imshow(dilated, 'InitialMagnification', 10) image at specified magnification title('Dilated Image') title of the image

%dilate the image using the %displays the variable as an %displays the string as the

%Finding edges in grayscale image using canny filter

filtered=edge(dilated,'canny',sqrt(3)-1, sqrt(3)); image

%finds edges in a grayscale

32

figure, imshow(filtered, 'InitialMagnification', 25) image at specified magnification title('Output Image') title of the image

%displays the variable as an %displays the string as the

%Measuring various parameters of the image

regionprops(filtered, 'Perimeter') regions regionprops(filtered, 'MajorAxisLength') regions regionprops(filtered, 'MinorAxisLength') regions

%measures properties of image %measures properties of image %measures properties of image

%Coded using Matlab R2012b

Output

33

34

35

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')

36

%Running aloop for all the possible angles

for a=0:1:180 SE = strel('line', 50, a); f3 = imdilate(f2, SE); end %Defining a morphological structuring element % Dialating the image using the pre-defined

nonflat morphological structuring element

%Preparing Output Image f4=f3-f2; figure, imshow(f4, 'InitialMagnification', 25) title('Output Image')

37

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

38

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); element

%Defining a morphological structuring

f3 = imdilate(f2, SE); defined

% Dialating the image using the pre-

nonflat morphological structuring element

figure, imshow(f3, 'InitialMagnification', 25) title('Output Image')

39

40

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.

41

References
[1] CHONG-SZE TONG, SIU-KAI CHOY, ZHONG-ZHEN ZHAO, ZHI-TAO LIANG, AND HUBIAO CHEN, Identification of Starch Grains in Microscopic Images Based on Granulometric Operations [2] Rafael C. Gonzalez, Richard E. Woods, Digital Image Processing, Second Edition , Prentice Hall, ISBN: 0-201-18075-8 [3] http://www.mathworks.com/ [4] CHONG-SZE TONG, SIU-KAI CHOY, ZHONG-ZHEN ZHAO, ZHI-TAO LIANG, AND HUBIAO CHEN, Characterization of Shapes for Use in Classification of Starch Grains Images [5] https://en.wikipedia.org/wiki/Main_Page [6] R.M. Haralick, K.Shanmugam, and I. Dinstein, Textural Features for Image Classification, IEEE Trans. On Systems, Man and Cybernetics, Vol.SMC-3, pp.610-621, 1973. [7] Abdolvahab Ehsanirad and Sharath Kumar Y.H, Leaf recognition for plant classification using GLCM and PCA methods, Oriental journal of Computer Science & technology, Vol.3(1), 31-36 (2010). [8] M-W Lin, J-R Tapamo and B Ndovie, A Textue-based Method for Document Segmentation and Classification, Joint Special Issue Advances in end-user data-mining techniques. [9] M. M. Mokji, S.A.R. Abu Bakar. Gray Level Co-Occurrence Matrix Computation Based On Haar Wavelet, Computer Graphics, Imaging and Visualisation(CGIV) 2007 IEEE Computer Society. [10] M.Vasantha, Dr.V.Subbiah Bharathi and R.Dhamodharan, Medical Image Feature, Extraction, Selection and Classification, International Journal of Engineering Science and Technology, Vol. 2(6), 2010, 2071-2076.

42