You are on page 1of 44

Android-Based Image Processing Application for Rice Nitrogen Management

by Van Joshua L. Abergos BS ECE Philip Zesar Boreta BS ECE Ricardo John B. Comprado II BS ECE Stephen R. Soltes BS ECE Andy V. Tatel BS ECE

A Thesis Report Submitted in Partial Fulfilment of the Requirements for the Degree of Bachelor of Science in Electronics Engineering

Ateneo de Naga University March 2012

ABSTRACT

Leaf Color Chart (LCC) is a tool that provides an assessment of rices demand for nitrogen. The use of LCC is highly dependent on the persons relative color perception and is limited to a time of eight to ten in the morning and three onwards in the afternoon for reliable reading. The main objective of this research is to develop an application that will eliminate the disadvantages of LCC, and Image Processing Ability of Android OS Tablet PC holds promise to this application. An Android application was developed which automates the LCC using Image processing techniques such as color histogram analysis and pixel bitwise operations. Testing for accuracy was based on the correlation of results based on the LCC and the Android application. After a series of sampling, it was found out that the results of LCC and the applications reading shows minimal discrepancy based on the Z-test one proportion. Keywords: LCC (Leaf Color Chart), color histogram analysis, pixel bitwise operations, Z-test one proportion

Chapter 1 INTRODUCTION

1.1 Background of the Study One primary cause of high production cost in rice farming is the fertilizer. Farmers operate their farms in the traditional way that applies fertilizer not on the basis of plant condition but on a predetermined date upon seeding. This results to either over application or under application of fertilizer since rice growth is not uniform in every area. Both of these cases lead to rice deficiency resulting to a lower yield. Present agricultural technology researches discourage the use of traditional farming and advocate precision farming. Precision farming is described as that the production inputs (seed, fertilizer, chemicals, etc) should be applied only at the time that are needed for the most economic production in order to obtain the highest output (Gholizadeh et al., 2009). Methods of proper fertilizer applications have been developed. One of the most effective means to determine when to apply fertilizer and on what amount is through the Leaf Color Chart (LCC). The LCC is used to assess the plant Nitrogen (N) status. It is an inexpensive and easy-touse tool consisting of four color shades from yellowish green (window no. 2) to dark green (window no. 5). The color strips are fabricated with veins resembling those of rice leaves (irri.org). The assessment will depend on the greenness of the leaf matched to the LCC window. Each window defines a level of N status. Several limitations on the usage, however, are posed by the LCC. The color matching is relative to the persons color perception so it is recommended that same person should do the matching. The use of LCC is also limited to only some period of a day due to the effect of sunlight to the color.

This project aims to develop a mobile application that automates the LCC to eliminate its limitations. The application adopts the functionalities and guidelines of the LCC. It is capable of classifying a leaf sample to the window it matches. The standard values for matching are set according to the LCC standard. A controlled light module is used to eliminate the color variation imposed by sunlight. The fertilizer recommendation is based on the window specification of the LCC. Database system provides a continuous monitoring on rice status since it stores the readings on previous samples. The image acquisition device that is used to take the sample leaf images is the built-in camera of the Tablet PC. It is necessary that the samples be less prone to noise for accurate results; thus filtering methods are applied as necessary.

1.2 Statement of the Problem Fertilizer must be applied only when necessary and must be based on the crops nutrient status. However, most farmers rely on the age (days after transplanting) of rice and not on its condition (Alam et al. 2005). This, consequently, caused inefficiency levels of fertilizer in terms of growth, development, and yield. Moreover, there are farmers applying fertilizer even if the crop does not need it. As a result, there is an insignificant addition to the production cost and undesired effects on the growth of rice. Overuse of synthetic nitrogen fertilizer has become widespread resulting in severe environmental problems. If the excessive application of nitrogen fertilizer is not brought under control, the environment will continue to deteriorate. The Leaf Color Chart (LCC) is a tool to rapidly assess leaf N status and thereby guide the application of fertilizer N to maintain optimal leaf N content.

This is what motivates the researchers to develop a mobile application for fertilizer management and crop monitoring that aims to enable the farmer to check when it is necessary to apply fertilizer by means of leaf image processing.

1.3 Significance of the Study The main beneficiaries of this project are the farmers and the rice consumers. It is intended to make fertilizer management more precise and reliable. By making the farmers analysis of their rice quantitative by comparing previous and current readings, it is hoped that they will achieve maximum yield; thus increasing the rice supply to match the increasing demand for it. This study also aims to minimize the environmental pollution due to excessive application of fertilizer. Database is provided to give a comparative statistics based on the previous samples so that farmers will have a monitoring system regarding the growth of rice periodically.

1.4 Objectives of the Study The studys general objective is to develop a mobile application for rice leaf analysis based on the image processing capability of android OS Tablet PCs. The studys specific objectives are: To develop an Android application that can determine the level of Nitrogen deficiency of rice through image processing To incorporate a database system on the Android application to provide a continuous monitoring of the crops N status

1.5 Scope and Delimitation This study is delimited to the following: The guidelines and fertilizer recommendations set by the LCC are adopted (see Appendix A). The nutrient to be assessed is nitrogen since it is the primary element that contributes to the growth of rice. The leaf to be sampled must be in a controlled light module. This program uses tools and will rely on Java Environment. The camera of the Tablet PC is used as the image acquisition device.

Chapter 2 REVIEW OF RELATED LITERATURE This chapter provides the literatures and studies related to the proposed project. 2.1 Tablet PC Tablet PCs are complete computer systems in a slate format. There are several varieties on the market available in two form factors: a slate design without a keyboard and a traditional laptop that converts to a slate. Some users make notes on the tablet while out of the office, then put the computer in a docking station and use the keyboard at their desk. All tablets have touch sensitive displays that allow you to input data by writing directly on the screen with a stylus or your finger. Most have a full feature set with an 8 or 10-inch screen. Some models have optional displays that can be read in bright sunlight. There are many processor and memory options. For data storage, there are models that use compact flash cards, others with hard disk drives, and most have wireless communications built-in for accessing your network for data storage and retrieval and for connecting to the Internet. Rugged models that meet military specifications for durability are also available. Tablet PCs offer many potential benefits and advantages. They can help improve customer service by allowing the update of information from a remote location, and they can also help increase productivity by eliminating paperwork. Tablets can also easily provide full access to the Internet and business applications. (Hancock, 2002)

2.2 Image Acquisition Most image processing programs are designed to start by loading an image from disk. This is done by acquiring images directly from a camera or from a video source.

2.2.1 Camera Camera is equipped with its sensor, records and stores images which are either still or dynamic. There are two types of camera: the analog camera that stores images in magnetic tapes and the digital camera that has a more complex storage system with the use of electronic storage devices. Both types use image-sensor chip which captures the image digitally. (Chen et al, 2002)

2.2.2 Phone camera Most phone cameras are simpler than digital cameras. Their lenses are fixed and sensors are small that limit their performance especially in poor lighting. Smart phones, however, use phone cameras that have been manufactured to be closely related to digital cameras by suppressing those disadvantages especially that images are further used for image processing. (Wells, 2008)

2.3 Image processing Digital image processing is performed with a computer to manipulate information within an image to make it useful. Image processing in agricultural applications may consist of three

steps: (1) image enhancement, (2) image feature extraction, and (3) image feature classification. (Chen et al, 2002) Image enhancement deals with enhancing the details of the image specifically to correct problems in contrast, noise, and inadequate or non-uniform illumination. Several procedures like morphological operations, filters, and pixel-to-pixel operations are used for image enhancements. Image feature extraction is a method of capturing visual content of images for indexing and retrieval. (Raicu, 2004) For every image, there is always a unique feature that can be identified, that is, the color distribution which can be viewed in its histogram. These features are then classified. Image feature classification analyzes the numerical properties of various image features and organizes data into categories or clusters. Classification algorithms typically employ two phases of processing: training and testing. In the initial training phase, characteristic properties of typical image features are isolated and, based on these, a unique description of each classification category, that is, training class is created. In the subsequent testing phase, these feature-space partitions are used to classify image features.

2.3.1 Mobile image processing Image processing on mobile phones is a new field with many challenges due to limited hardware and connectivity. Phones with cameras, powerful CPUs, and memory storage devices are becoming increasingly common. The need for benchmarking basic image processing routines such as: addition, convolution, thresholding and edge detection is important for comparison of systems. With this information, developers and researchers can design complex computer vision

and image processing applications while being aware of the current state of the art limitations and bottlenecks on mobile phones. (Wells, 2008)

Acquisition

Pre-Processing

Feature Extraction

Feature Tracking

Fig. 2.1 Steps in a Computer Vision Application Image Acquisition refers to the capturing of image data by a particular sensor or data repository. Once the image data is acquired, Pre-Processing often includes rendering the acquired data to a format that can be handled by a set of algorithms for Feature Extraction that transform sub-image data to information which are often in turn maintained over time to provide temporal information.

2.3.2 Color Image Processing The central terminology of color image processing is that of the digital color image. A digital image is defined for image pixels that are assumed in the real plane or could be elements of a discrete set of points. A gray-level image E assumes an image value E (p) = E(x, y) (2.1)

in an image pixelp = (x , y) as a uniquely determined function value, approximately a numerical gray value u, which characterizes a determined gray tone. For this, E (x, y) = u is written formally. The triple (x,y,E(x,y)) = (x, y, u) (2.2)

is indicated as pixel (from picture element), where x and y are the coordinates in the image plane. The points in the image plane are converted by the image acquisition equipment into integervalued, device dependent coordinates of the row and column position. (Koshban and Abidi, 2008)

2.3.3 Histogram Histograms are used to depict image statistics in an easily interpreted visual format. With a histogram, it is easy to determine certain types of problems in an image. For example, it is simple to conclude if an image is properly exposed by visual inspection of its histogram. In fact, histograms are so useful that modern digital cameras often provide a real-time histogram overlay to help prevent taking poorly exposed pictures. It is important to catch errors like this at the image capture stage because poor exposure results in a loss of information which is not possible to recover later using image-processing techniques. In addition to their usefulness during image capture, histograms are also used later to improve the visual appearance of an image and as a "forensic" tool for determining what type of processing has previously been applied to an image. (Burger and Burge, 2008)

2.3.4 Color Image Histogram When referring to histograms of color images, typically what is meant is a histogram of the image intensity (luminance) or of the individual color channels. Both of these variants are supported by practically every image-processing application and are used to objectively appraise the image quality, especially directly after image acquisition(Burger and Burge, 2008).

10

2.4 Pixel A digital color image pixel is just a RGB (Red, Green, Blue) data value. Each pixel's color sample has three numerical RGB components (Red, Green, Blue) to represent the color. These three RGB components are three 8-bit numbers for each pixel. Three 8-bit bytes (one byte for each of RGB) are called 24 bit color. Each 8 bit RGB component can have 256 possible values, ranging from 0 to 255. For example, three values like (250, 165, 0), meaning (Red=250, Green=165, Blue=0) to denote one Orange pixel. Photo editor programs have an Eyedropper tool to show the 3 RGB color components for any image pixel. In the base 2 binary system, an 8 bit byte can contain one of 256 numeric values ranging from 0 to 255, because 2 to the 8th power is 256, as seen in the sequence 2,4,8,16,32,64,128,256. The 8th of these is 256. This is the same concept in base 10, that 3 decimal digits can store one of 1000 values, 0 to 999. 10 to the 3rd power is 1000, same idea as 2 to the 8th power is 256. What is being pointed out here is that 255 is the maximum possible number that can be stored in an 8 bit byte. Larger numbers require multiple bytes, for example two bytes (16 bits) can hold up to 256x256 = 65536 unique values. 24 bit RGB color images use 3 bytes, and can have 256 shades of red, and 256 shades of green, and 256 shades of blue. This is 256x256x256 = 16.7 million possible combinations or colors for 24 bit RGB color images. The pixel's RGB data value shows "how much" Red, and Green, and Blue, and the three colors and intensity levels will be combined at that image pixel, at that pixel location. The composite of the three RGB values creates the final color for that one pixel area. In the RGB system, we know Red and Green make Yellow. So, (255, 255, 0) means Red and Green, each fully saturated (255 is as bright as 8 bits can be), with no Blue (zero), with the resulting color being Yellow.

11

Black is a RGB value of (0, 0, 0) and White is (255, 255, 255). Gray is interesting too, because it has the property of having equal RGB values. So (220, 220, 220) is a light gray (near white), and (40, 40, 40) is a dark gray (near black). Gray has no unbalanced color cast. Since gray has equal values in RGB, Black and White gray scale images use only one byte of 8 bit data per pixel instead of three. The byte still holds values 0 to 255, to represent 256 shades of gray. Line art pixels are represented by only one binary bit with values 0 or 1, used to denote Black or White (2 colors, no gray). Line art data is stored packed 8 bits into one 8-bit byte. (Wayne Fulton, 1997-2010)

2.5 Android Operating System Android is a mobile operating system that is based on the modified version of Linux. It is owned by Google after it was bought in 2005 from Android, Inc. Smart phones, tablets, E-reader devices, Net books, MP4 players, and Internet TV are just few examples of devices powered by Android Operating System. Google made Android open and free. Most Android codes were released under the open-source Apache license and made it available for free download. (Lee, 2011) This gives rise to many different Android-based mobile applications. The architecture of Android OS is divided into five sections of four main layers. Linux kernel, the bottom section is the kernel used containing all low-level device drivers for various hardware components of an Android device. Libraries contain all the codes that provide the main features of this OS. Android runtime contains the core libraries that enable developers to develop applications using Java programming language. Application framework exposes its various capabilities to application developers that enable them to use their applications. Examples of

12

application framework are activity manager, window manager, telephony manager, and others. The top section is the application containing numerous applications created by developers.

2.6 Java programming language A Java program consists of one or more Java classes that are written using the Java programming language. These classes contain instructions that tell a computer what to do as well as the data necessary for the computer to carry out the task. Classes are written into a Java source code file using an editor. A Java source code file is similar to a word processing document. However, instead of containing text, the Java source code file has instructions written in the Java programming language. Java works differently than C++ and other high-level programming languages. High-level programming languages must be compiled into object code that is linked by a linker to form the machine language program that runs on a computer. Java source code is not compiled into object code. Instead, Java source code is compiled into byte code and saved in a file that has the file extension .class. The Java compiler is a component of the Java 2 Software Development Kit (J2SDK) that is free to download from the site of Sun Microsystems (Keogh, 2004).

2.7 Leaf Color Chart (LCC)

Fig. 2.2 Standard Leaf Color Chart

13

The Leaf Color Chart (LCC) as shown in Fig 2.2 is an easy-to-use and inexpensive diagnostic tool for monitoring the relative greenness of a rice leaf as an indicator of the plant N status. (Alam et al. 2005) The Nitrogen status of rice is manifested on the greenness of its leaves. The rices demand for nitrogen varies on its growing period thus assessment and monitoring of the required N content must be done periodically. LCC is basically a guide to supply the necessary N fertilizer for the optimal N content which is very necessary in achieving maximum yield. The LCC is composed of four or more panels each having different variations of color green. It is arranged in a ruler-shaped designed where the panels are arrayed horizontally from yellowish green to dark green. Before, LCC has many variations in terms of designs that created uncertainties on its reading. This urged IRRI to create a standard version with improved quality assurance for the reproducibility of colors and enhanced matching of rice leaves. (Witt et al. 2005) The standard version consists of four color green variations rated as 2 for yellowish green to 5 for the dark green. It is made of plastic and is five inches long. The strips are textured resembling as of the real rice leaf. The procedures are listed below on how to use the LCC. 1. Randomly select at least 10 disease-free rice plants (no discoloration or deformation) in a field with uniform plant population. 2. Select the topmost fully expanded leaf. Place the middle part of the leaf and compare which color strip on the panel match the color of the leaf. 3. 4. Measure the leaf color away from the sunlight for light will affect the color readingThe same person should do the reading at the same time of the day every time the process is done.. 5. Take the average LCC reading for the selected leaves

14

2.7.1 Fertilizer recommendation for Leaf Color Chart Window 2: leaves are yellowish in color. Apply high dose of nitrogen. For active tillering stage apply 45 kg/ha of Urea. For panicle initiation stage apply 45 kg/ha of urea. Window 3: leaves are yellowish green in color. Apply baseline dose of nitrogen. For active tillering stage apply 35 kg/ha of Urea. For panicle initiation stage apply 35 kg/ha of urea. Window 4: leaves are green in color. May apply a little dose of nitrogen. For active tillering stage apply 25 kg/ha of Urea. For panicle initiation stage apply 25 kg/ha of urea. Window 5: leaves are dark green in color. No need to apply nitrogen. (Witt et al. 2005)

2.8 Chlorophyll Meter

Fig 2.3 SPAD 502 Plus Chlorophyll Meter

15

Chlorophyll Meter is a lightweight, portable device developed by Minolta Camera Company to measure the chlorophyll content of rice leaf and other crops. Basically, it operates by measuring the amount of light that passes through the leaf. Meter readings are given in Minolta Company-defined SPAD (Soil Plant Analysis Development) values that indicate relative chlorophyll contents. (Gholizadeh et al, 2009) The linear relationship of the SPAD reading and the leaf nitrogen concentration has led to its adaptation as a tool to assess crop nitrogen status and the amount of nitrogen to be applied. To use SPAD chlorophyll meter, clamp it over the leafy tissue of a plant and an indexed chlorophyll content reading is displayed in less than two seconds. Assessment can then be done on the nitrogen needs of the rice based on the SPAD 502 Plus readings.

2.9 Nutrient Manager for Rice (NM Rice Mobile) NM Rice Mobile is a mobile phone application initiated by IRRI and the Department of Agriculture. Its main goal is to increase the farmers rice production and profit by receiving advises on proper fertilizer application. It applies the concept of Site Specific Nutrient Management (SSNM), a set of scientific principles for optimally supplying rice with essential nutrients. LCC is covered by SSNM. Farmers dial a toll-free number. A voice response will follow which will direct them to a set of 12 to 15 questions related to the status of his rice. After answering the questions, a text message will be sent on the farmers phone containing recommendations on fertilizer application duly customized for his field. In the Philippines, NM Rice Mobile is available in Tagalog, Cebuano, and Ilocano. (IRRI, 2011)

16

2.10 Importance and Effect of Nitrogen on Crop Quality and Health Nitrogen (N) is often the most limiting factor in crop production. Hence, application of fertilizer nitrogen results in higher biomass and protein yields. Concentration in plant tissue is commonly increased. Nitrogen often affects amino acid composition of protein and in turn, its nutritional quality. In cereals, abundant supply of nitrogen decreases the relative proportion of lysine and threonine, thus, reducing the biological value of the protein. Increasing nitrogen supply generally improves kernel integrity and strength, resulting in better milling properties of the grain. In oil seed crops, protein levels are increased upon nitrogen fertilization, whereas oil concentration is decreased. Effects of nitrogen fertilization on oil composition and quality are inconsistent. In sugar beet production, abundant supply of nitrogen results in a reduction of sucrose concentration per unit of fresh matter and to an increase in impurities (alpha-aminonitrogen, invert sugars, and lime salts), which negatively affect efficiency of sucrose extraction. Nitrogen supply to potatoes primarily influences tuber size, dry matter, and sugar contents. Nitrogen supply is managed according to market classes (table stock, French fries, and potato chips), which require different quality parameters. Rice is the primary source of dietary energy and protein for nearly three billion people in Asia. Head rice is more valuable than broken ones, and consumers prefer translucent, white grains. Nitrogen nutrition has a large influence on rice grain quality through effects on milling characteristics, translucence, and color. Most rice is consumed as white rice. White rice is obtained after dehulling the rough rice, as harvested from the field, to produce brown rice, which undergoes abrasive milling to remove the outer layers of pericarp, seed coat and nucleolus, the germ or embryo, and aleuronic layers. (Juliano, 1993) After milling, white rice represents about 70% of the original yield of

17

rough rice. Crop nitrogen supply and plant nitrogen status have a marked effect on final protein content of both the brown and white rice. Early work with improved rice varieties conducted in the 1960s and 1970s demonstrated that grain protein could be significantly increased by ensuring adequate nitrogen fertilizer application up to panicle initiation stage. (Nangju and De Datta, 1970; De Datta et al., 1972) Subsequent field research has found that improved fertilizer nitrogen use efficiency to achieve both high yields and high grain quality requires careful attention to the rate and timing of nitrogen fertilizer applications such that the total available nitrogen supply from soil and fertilizer is congruent with crop nitrogen demand. In high-yield production systems, improved congruence between nitrogen supply and crop demand sometimes requires several split applicationsincluding final nitrogen topdressing at flowering stage. (Perez et al., 1996) In one field study with transplanted rice in the Philippines, an additional nitrogen topdressing at flowering resulted in a 6% increase in rough rice yield and a 25% increase in grain protein compared to a treatment that received all of the nitrogen fertilizer by panicle initiation stage. Although the rate and timing nitrogen treatments are confounded in this study, additional studies have consistently demonstrated the effectiveness of nitrogen application at flowering to optimize both yield and grain protein in high yield systems where soil nitrogen is not sufficient to meet crop nitrogen demand during grain filling. (Blumenthal et al, 2008)

2.11 Image Processing Applied in Measuring Rice-Leaf Interveinal Characteristics This research was conducted to test the assumption of IRRI that a C4 rice plant could boost yields by 50% while using less water and fertilizer. Rice naturally belongs to C3 plant classification. C3 plants use RuBisCO, an enzyme that turns atmospheric carbon dioxide into a three-carbon compound which is a necessary step in the production of biomass. This enzyme,

18

however, also captures oxygen which the plant is going to release in the process called photorespiration, causing also the loss of some recently fixed carbon needed by the plant. C4 plants like corn have additional enzyme called PEP carboxylase produces a four carbon compound. This increases the concentration of carbon dioxide crowding oxygen out and suppressing photorespiration. In return, C4 plants are more efficient at turning solar radiation to biomass. (Mariano et al, 2010) The study focused on the analysis of leaf morphology and metabolism of each variety of rice plant. This essential information can be obtained by determining interveinal characteristics and chloroplast development in bundle sheath cells of rice plants. However, the said varieties are thousands in number. Thus imposes a lengthy, huge and tedious work for numerous scientists who mainly rely on manual processes or microscope related activity. The task is to develop an image processing application that will analyze the interveinal characteristics of rice regardless of the variety to compensate for the time constraints has the study been done manually. The sample leaf images were taken using Nikon digital SLR camera with a micro-lens. The image is then resized by cropping to minimize its disk space. The image to be processed is reduced from 1.5 Mb to 500 Kb of disk space.

Fig 2.4.1 Nikon DLSRs First Output

Fig 2.4.2 Nikon DLSRs Final Output

19

a. Rice Leaf Images were taken using a Nikon DSLR with micro-lens. A bright light source is behind the leaf that is placed above a glass sheath. This image served as input image in succeeding methods b. Final Output of the entire system given an input image. Mark each representative vein locations together with its thickness along the entire height of the input image. Cropped/Straightened image over Final Output Image.

2.12 Leaf Color Analysis using Digital Imaging Software Changes in foliar color are a valuable indicator of plant nutrition and health. Leaf color is measured with visual scales and inexpensive plant color guides that are easy to use, but not quantitatively rigorous, or by employing sophisticated instrumentation including chlorophyll meters, reflectometers, and spectrophotometers that are costly and may require special training. Digital color analysis has become an increasingly popular and cost-effective method utilized by resource managers and scientists for evaluating foliar nutrition and health in response to environmental stresses. Working with colorful autumn samples of sugar maple (Acer saccharum Marsh.) leaves, the researchers (Murakami, Turner, Van der Berg, Schaberg, 2005) developed and tested a new method of digital image analysis that uses Scion Image or NIH image public domain software to quantify leaf color. In order to assess the accuracy of using digital image color analysis as an indicator of foliar pigment concentrations, percentage leaf color and pigment content were determined for 326 sugar maple leaf images. Fresh leaves were scanned and leaf disks were carefully removed. Punches were shredded using a razor blade and placed in either acetone/H2O for extraction of chlorophylls or HCl/H2O/MeOH for extraction of anthocyanin according to the methods of

20

Gould et al. (2000). Pigment content was quantified using spectrophotometer. Chlorophyll concentrations were calculated using the equations of Lichtenthaler and Wellburn (1983). Absorbance of anthocyanin was measured at 530 nm and the overlap of chlorophylls was subtracted. Regression analyses were conducted to determine the relationship between percentage leaf color and pigment concentration using the least squares method (SAS 2002). Analyses with sugar maple leaves indicate that digital image analysis provides an accurate means of quantifying foliar color and estimating pigment concentration in multicolored leaves. Although this method has value, it is not intended to replace other more precise means of measuring color. However, it does provide researchers and scientists with an alternative means of quantifying leaf color and aspects of plant health that do not require specialized equipment or potentially hazardous chemicals.

2.13 Importance of Controlling Light in Image Processing Application One of the most important aspects of setting up your imaging environment is proper illumination. Images acquired under proper lighting conditions make your image processing software development easier and overall processing time faster. One objective of lighting is to separate the feature or part you want to inspect from the surrounding background by as many gray levels as possible. Another goal is to control the light in the scene. Set up your lighting devices so that changes in ambient illumination such as sunlight changing with the weather or time of day do not compromise image analysis and processing. Common types of light sources include halogen, LED, fluorescent, and laser. To learn more about lighting techniques and decide which is best for your application, visit the Web sites of National Instruments' lighting partners.

21

The type of lighting techniques you select can determine the success or failure of your application. Improper lighting can cause shadows and glares that degrade the performance of your image processing routine. For example, some objects reflect large amounts of light because of their curvature or surface texture. Highly directional light sources increase the sensitivity of specular highlights (glints), as shown on the barcode in Figure 7a. Figure 7b shows an image of the same barcode acquired under diffused lighting. (NI Developer, 2011)

2.14 The Importance of Light in a Picture Without light, photography would not exist. In fact, the word photography comes from the word photo, a Greek word meaning "light". Before you can understand photography, you must first understand light. Even if you have the most sophisticated camera, and the most expensive and sharpest lense, without light your photographs would be impossible, and your cameras and lenses would be useless. (http://library.thinkquest.org/25473/ph_02_03.shtml, 2003)

2.14.1 Focusing in Low Light Environment In low light environment, there is a high chance that a camera might not be able to focus correctly. A camera needs a certain level of lighting environment in order to complete its auto focus. Some digital camera have auto-focus-assist lamp that helps to focus during low light environment. However, the auto-focus-assist lamp also has its own limitation as the distance is very short.

22

The best way to overcome this problem is to attach the camera with an external flash. External flash have a much better focusing system and an auto-focus-assist lamp that can help auto focusing in low light environment. Other than this, we can also try to add external lighting such as torch light and external lamp for additiomsal help.. If all this can't help, one has to resort to manual focus by using our own hand to tune and eyes to detect the problem. (BasicCameraPhotography.com, 2008)

2.15 Automatic Plant Leaf Classification for a Mobile Field Guide

Fig 2.5 Sample Leaf Before and After Preprocessing

This describes the development of an Android application that gives users the ability to identify plant species based on photographs of the plants leaves taken with a mobile phone. At the heart of this application is an algorithm that acquires morphological features of the leaves, computes well-documented metrics such as the Angle Code Histogram (ACH), then classifies the species based on a novel combination of the computed metrics. The algorithm is first trained

23

against several samples of known plant species and then used to classify unknown query species. Aided by features designed into the application such as touch screen image rotation and contour preview, the algorithm is very successful in properly classifying species contained in the training library (Knight et al, 2005). At the highest level, the algorithm for classifying plant species proceeds as follows. An image of the leaf of interest is acquired and preprocessed to obtain a binary image of the leafs contour. For several samples of leaves from a given species, morphological features are extracted from the contour image. This data is used to train the algorithm by determining the median value of each feature of a given species. As more samples are added to the training set, the algorithm becomes more effective identifying a given species. This Android mobile application, the core of which is an algorithm, uses digital morphological features to classify plant species based on the nearest neighbor distance of the query leafs features from the median features of each species in the training set. The method proved quite robust under reasonable conditions. With further additions to the training set, the application can easily be tuned to recognize more plant species. This capability coupled with a polished user interface and linked information on the identified plant species could result in a very compelling mobile application, opening the surrounding environment to large numbers of users.

2.16 Reducing Nitrogen Fertilizer Use to Mitigate Negative Environmental Impact in China The overuse of N fertilizer inevitably leads to an increased risk to public health. Nitrate content in ground and drinking water found in 37 of 69 locations covering an area of about 140,000 square kilometers in northern China, and in 46% of 600 groundwater samples

24

taken in the provinces of Shanxi, Hebei, Shandong, Tianjin, and Beijing exceeded the World Health Organization (WHO) limit for nitrate content in drinking water of 50 mg per liter. Public health agencies have long recognized that excessive nitrate in water can sometimes lead to a fatal condition in infants . Nitrosamines, which are produced from nitrites and associated with various human cancers, have also been observed in ground and drinking water samples. There is evidence that increases in synthetic N fertilizer used reduce plant resistance to insect pests and tend to enhance insect pest populations. The increases in populations of major insect pests in most of the rice growing areas in Asia are closely related to the excessive application of nitrogen fertilizers. A range of crop pathogens, including fungi, bacteria, and viruses, also cause more severe damage when N inputs are high. The cropland area exposed to diseases and pests infestations in China increased from ~230 million hectares (Mha) year in the early 1990s to ~345 Mha year in the mid-2000s, although this trend cannot be attributed to excessive application of nitrogen fertilizers alone. Annual application of pesticides increased from ~0.77 million tons in 1991 to 1.62 million tons in 2007. Consequently, pesticide resistance has become a ubiquitous problem, as have the environmental and human health threats associated with pesticide transfers to air, water, and soil. (Huang, Sass,Yu, 2010)

2.17 Synthesis Image processing will be crucial in the system design emphasizing the techniques in color image processing. Histogram is a graphical representation of the color intensity of digital images. This is a tool to quantify every color that is present in an image. The project makes use of histogram to characterize the color intensity of rice leaf. The histogram of every sample will be correlated to the standard leaf color for matching.

25

Implementation of this project is done on a Tablet PC which is operated by an Android Operating System. Image acquisition is through the phone camera built in the Tablet PC. Image is displayed through a Graphical User Interface (GUI) programmed in Java Programming Language being the only capable language for Android OS devices. The Leaf Color Chart (LCC) is the source for standardizing the color matching. The color variations presented in the LCC are first processed, that is, to take their histogram. Those histograms are saved for they will be used for matching the sample leaf image histograms.

Chapter 3 Methodology 3.1 Process Construction

Acquisition of necessary materials i.e. tablet PC

Programming

Setting of the Standard color based on the LCC

Preliminary Testing

Troubleshooting

Final Testing

Certification from the Department of Agriculture

Fig. 3.1 Process Construction


26

27

The project construction began with the research on methods determining rice nitrogen content based on leaf color. The researchers came across the Leaf Color Chart (LCC), the existing tool for nitrogen detection based on rice leaf. The problems and limitations such as inaccuracy and user-bias were identified as the main issues resolved by this project. The

feasibility of implementing and improving LCC through an image processing system was first verified. Consultations were done for possible implementation of the project. After which, the researchers decided to implement the project using a Tablet PC which is equipped with image processing capabilities. The first issue to be resolved is portability, second is capability to acquire high resolution picture (at least 3 mega pixels) and lastly efficiency to process (1core-dualcore) java program. The specification matches analogously to a Tablet PC which the researchers decided to use. Since Tablet PCs operating system is Android, it is java-compatible as the programming language to develop the program for implementing the leaf image processing. A series of testing was done after the development of the mobile application. The results were then compared with the manual reading of the LCC with the supervision of the Department of Agriculture through the Bicol Integrated Agricultural Research Center (BIARC). Testing and evaluation were done based on the results of the manual LCC and the mobile application. Certification is sought from the Department of Agriculture regarding the efficiency and accuracy of the developed mobile system.

28

3.2 System Model

Start

System Trigger (GUI)

Image Acquisition

Image Processing

Data Comparison (Image Matching)

Output (assesment on rice nutrient status)

Save to Database

End

Figure 3.2 System Model

29

3.2.1 System Trigger A GUI (Graphical User Interface) represents the information and actions available to a user through graphical icons and visual indicators such as secondary notation, as opposed to textbased interfaces, typed command labels or text navigation. The actions are usually performed through direct manipulation of the graphical elements by providing menus to manually access the program.

3.2.2 Image Acquisition The first stage of any vision system is the image acquisition stage wherein the images to be acquired are series of pictures using the Android based tablet, within certain conditions. After the image has been obtained, various methods of processing can be applied to the image to perform many different vision tasks.

3.2.3 Image Processing In image processing and photography, a color histogram is a representation of the distribution of colors in an image. For digital images, a color histogram represents the number of pixels that have colors in each of a fixed list of color ranges, which span the image's color space, the set of all possible colors. The color histogram of the sample images will be correlated to the standard database interrelated to LCC (Leaf Color Chart) diagnostic tool.

30

3.2.4 Data Comparison The greenness value of each sampled leaf is obtained by the application and is compared to the standard greenness values for each Leaf Color Chart window saved in the application.

3.2.5 Output The output is a presentation of the processed data gathered from the series of random snap shots. The output presents the needed nitrogen, if there is any and on what amount to apply, in order to compensate the deficiencies of the rice.

3.2.6 Save to Database The result will be saved for future comparison purposes using the SQL database system which the Android OS is capable.

31

3.3 Program Flowchart


start

Show GUI about Developers

main menu

No

Start Yes No

Begin Sampling
Yes

No

Set Standard

Back No Yes

Yes

Begin Sampling

Set Standard

No
Instruction (English)

Instruction

Yes No

Tagalog Instruction Yes Instruction (Tagalog)

Home
No No

Back
Yes

Yes

No Display Previous Samplings

ViewLog Yes No

Back Yes

No

About

Yes No

Display about SANRice

Home

Back

No
Yes

Yes

Back

No Yes

End

Figure 3.3.1 Program Flowchart

32

Begin Sampling

Start

Reminder

Display average values of each window

No

Begin Sampling
No

Yes

Start of Loop (10 recognized pictures must be acquired) B

Take Sample
Yes

No

Back

Yes

No

Back
Yes

Yes

No No

Capture
Yes

No

Cancel

Back

Yes

B
Yes Yes No

Ok
Yes

No

Retake

No

Cancel

No

Back

Yes

No

Next Leaf to be Sample

No

Loop Satisfied?
Yes

Get Green
Yes

No

Back

Yes

End of Loop (10 pictures recognized and saved)

Image Recognize
Yes

No

no leaf detected

Shows all taken pictures' classification windows and their average Shows the Recommendations
Saved to Database (Results & Recommendations)
Yes

Show pixel value and what window

Store to initial Storage

Counter ++

Take another sampling?


No

End

Figure 3.3.2 Pre-defined Process (Begin Sampling)

33

Set Standard Start

Reminder

No

Set Standard
No No

Start of Loop Yes (4 recognized pictures must be acquired) B

Take Sample
Yes

No

Back

Yes

Back
Yes

Yes

No

Capture
Yes

No

Cancel

No

Back

Yes

B
Yes Yes No

Ok
Yes

No

Retake

No

Cancel

No

Back

Yes

No

Next Leaf to be Sample

No

Loop Satisfied?
Yes

Get Green
Yes

No

Back

Yes

End of Loop (4 pictures recognized and saved) Shows all taken pictures,their classification windows and their pixel value Saved to Database (to be used as standard values in sampling)
Reminder

Image Recognize
Yes

No

no leaf detected

Show pixel value and what window they will be set

Store to initial Storage

Counter ++ End

Figure 3.3.3 Pre-defined Process (Set Standard)

34

The program will start by taking the user to the main menu where there is four options, excluding the back button. First is the About option that mainly discuss about the program on how the project was designed and what are the factors that made the developers come up with this project. Second is the Instruction option that talks about on how to run the program properly. There are step-by-step procedures so that the program will be user-friendly. Third is the View Log option that shows the previous samplings, along with the results and recommendations. Its main function is for comparison and review purposes. Fourth is the Start option which directs the user to the main use of this project, which is to take leaf samples. The program will start by taking sample of images of rice leaves in the field. The image will be processed by comparing the greenness value of the sample image to the greenness value of standard images saved in the application. If the sample image doesnt match, for example, goes out of the set range, then it would be discarded and the same process will be done until the captured image is valid. The program will store ten greenness values including the equivalent windows based on the ten sample leaf images. The greenness value of the sample image will then be compared to the standard values per window. After sampling, an evaluation is displayed showing a table of greenness values and their corresponding equivalent windows. Then the user can evaluate the results to show the average window for all ten samples. Included in the evaluation is the fertilizer recommendation specified for the average window.

35

3.4 Physical Setup Based from the researchers calibrations, the most suitable height for the controlled-light module was 2.5 inches. If the height is lower than 2.5 inches the image captured becomes blurred. On the other hand, if the height is higher than 2.5 inches, the smallest size of rice leaf can no longer be contained at the center grid of the tablets camera. The lighting of the module consists of two white LEDs based from testing the image captured; using two LEDs gives the best quality of pictures. Using more than two LEDs gives the picture a lighter contrast, on the other hand, one LED gives a darker contrast.

Figure 3.4.1 Physical Setup

36

The module consisted of 9-volts battery so that it could supply enough power for the two 5-volts while LED is connected in parallel. It was also important to put 9-ohm resistor in the circuit because too much power due to the fluctuation on the supply from the battery might harm the two LEDs.

Figure 3.4.2 Schematic Diagram

3.5 Cost Breakdown The table shows the estimated cost breakdown of the materials and components used for the proposed project. Table 1 Cost Breakdown Parts Description Tablet PC white LED controlled-light module 9-volts Battery 9-ohm resistor Quantity 1 2 1 1 1 Price (Php) 12495 5 100 150 2 Total(Php) 12495 10 100 150 2 13757

37

3.6 Test and Evaluation A Z-test one proportion is a statistical test for which the distribution of the test statistic under the null hypothesis can be approximated by a normal distribution. Due to the central limit theorem, this test statistic is approximately normally distributed for large samples. So, for the Ztest one proportion to be applicable, certain conditions must be met: 1. Nuisance parameters should be known, or estimated with high accuracy (an example of a nuisance parameter would be the standard deviation in a one-sample location test). Z-test one proportion focus on a single parameter, and treat all other unknown parameters as being fixed at their true values. In practice, due to Slutsky's theorem, "plugging in" consistent estimates of nuisance parameters can be justified. 2. The test statistic should follow a normal distribution. Generally, one appeals to the central limit theorem to justify assuming that a test statistic varies normally. There is a great deal of statistical research on the question of when a test statistic varies approximately normally. If the variation of the test statistic is strongly non-normal, a Z-test test proportion should not be used.(UCLA, 2000) With the circumstances above, the researchers with the advice of Statistician, Ms. Yumi Valenzuela, decided to use the Z-test one proportion. Since the main objective of the research is that the readings of SANRice should be at least matched the readings of LCC, the first condition of the Z-test one proportion was met. The statistician also reminded the researchers that the testing should have at least 30 samples in using the Z-test one proportion to be reliable. For the second condition, since the output only varies if it matched the LCC readings or not, it is

38

justifiable to assume that the test statistics varies normally. With the conditions satisfied, it is safe to assume that the said statistical approach will really show the reliability of the research.

3.6.1 Results and Discussion The tables of the values in the final testing are at the Appendix (see Appendix C) and below are the formula and the output of the statistical test. no. of samples success success rate considering Z-test One Proportion : 30 : 24 :

Statistical method: Z-test One Proportion Null hypothesis (Ho): the output of automated device is not significantly different from the manual output. Decision: reject Ho if computed < 0.67 (critical value by looking at z-table, see Appendix D)

Where: Z-value = Where: = P = hypothesized value x no. of success n no. of samples

(3.1)

(3.2)

39

= 0.8 = 3.2863

Z-value =

The final testing was consisted of 30 leaf samples which were divided in three set with 10 leaf samples each. The leaf samples were manually checked by Mr. Anacleto B. Esplana, a rice specialist in the Department of Agriculture, whos an expert regarding in Leaf Color Chart. The researchers were also aware that the final testing between LCC and SANRice should be synchronized. So, after Mr. Esplana was done in a specific leaf, the SANRice immediately took picture of that leaf for its own reading so that the testing will be consistent because the leafs condition might change in a short time due to many factors. It can be seen that after the final testing, out of 30 leaf samples 24 of the readings of SANRice matched the readings of Mr. Esplana. The values gathered in the final testing was then set to the formula of Z-test one proportion and the output was 3.2863. Since the test statistic of 3.2863 exceeds the critical value of 0.67, the null hypothesis (Ho) is accepted, thus it can be concluded that the readings of SANRice matched the readings of Leaf Color Chart.

Chapter 4 CONCLUSION The researchers were able to meet their objectives, which is to develop an Android-based application that will determine the level of nitrogen deficiency of rice. The project also aims to improve the capability of the LCC by automation reading and by using android based features which allows the user to save his/her current readings in the database. During the actual testing, it was found that the discrepancy of reading was very minimal comparing the leaf color chart to the developed android application, which only shows the success in the projects accuracy in reading. The application was able to overcome the bias of color perception and color blindness since anyone who is not oriented to use LCC and with the disability of color perception cannot do readings without the bias of color perception. Since the light is controlled through the light module, the sunlight does not affect the consistency of the greenness of leaves and of the captured image in general. Therefore, it could be used in any time of the day. It is concluded that this project has provided particular upgrades necessary for the improvement of the LCC in future application.

40

Chapter 5 RECOMMENDATION

The researchers have the following recommendations to improve the application and its functions: a) Applicability to other crops since the leaf color chart adopted as standard in this application is only applied to rice. b) Multi-user functionality since the application does not have the ability to distinguish one user from another which might pertain to a different rice population. c) A more reliable source of power for the controlled-light module: Even if the modules source of power seems reliable as can be manifested by the consistency of the results based on the trials conducted, it is preferable if the source will come from the tablet itself. d) For a more accurate setting of standard values, it is recommended to use a SPAD meter since it outputs a reading which could be easily compared to the reading of the application. e) It is desirable that the results will be accessible through the internet or may have a printable version.

41

You might also like