College Papers

CHAPTER 1 INTRODUCTION 1

CHAPTER 1
INTRODUCTION
1.1 Preamble
India is one of the agriculture based fastest growing country in the world. some of major crops grown in India are maize, wheat and rice etc. Maize is considered a promising option for diversity agriculture in upland areas of India. It now ranks as third most important growing crop in India. It is important to detect and manage nitrogen level in plants; Nitrogen is one of the nutrients which play an important role in yield of crops. Leaf normally contains 1% to 5% nitrogen level by weight. So we propose an approach for identification of nitrogen content in maize leaf using image processing technique.
The present way to find nitrogen content in leaves is Kjeldahl method. This method is also known as Nitrate test (chemical test method). This consumes time of about 96 hours, manpower, and is also costlier. To overcome these shortcomings the proposed system will find out the nitrogen content in the leaves using image processing technique in lesser time and lower cost.
Estimation of nitrogen content in maize leaf using image processing technique is the aim of this system. We use regression modelling to find the correlation between various image features and nitrogen content of leaves got from laboratory test results. Regression model is a statistical technique to determine the relationship between two or more variables. Regression is primarily used for prediction and causal inference. It is important to recognize that regression analysis is fundamentally different from ascertaining the correlations among different variables. Correlation determines the strength of the relationship between variables, while regression attempts to describe that relationship between these variables in more detail.
1.2 Overview of Chemical Analysis Method (Kjeldahl)
The Kjeldahl strategy is utilized for quantitative determination of nitrogen in synthetic substances and was created by Johan Kjeldahl. At first a test leaf of 0.2 g was broiler dried for 72 hours and after that legitimately squashed 2. The specimen was then blended with 5 ml H2SO4 (Hydrochloric Sulphuric Acid) in the nearness of K2SO4 (Potassium Sulphate) and CUSO4 (Copper Sulphate) and afterward warmed in the processing jar on the radiator for 4 hrs. Warming the substance with sulphuric acid separates the characteristic nitrogen to ammonium sulphate. In this step, potassium sulphate was added to increase the boiling point of the medium (from 337? to 373?). The arrangement was refined with sodium hydroxide (included little amounts around 10 ml) to change over the ammonium salt into ammonia. The measure of alkali present (henceforth the measure of nitrogen present in the example) was controlled by back titration. The end of the condenser was plunged into a solution of hydrochloric destructive or sulphuric acid.The ammonia reacts with the acid and the excess acid was then titrated with a sodium carbonate arrangement with a methyl orange pH pointer. Kjeldahl nitrogen results are calculated using this formula:
N% Sample Concentration-Blank concentrationSample WeightX Volume made (1) 1.3 NDVI (Normalized Difference Vegetation Index)
It is a numerical marker that uses near infrared region of the electromagnetic spectrum to observe whether the target contains live green vegetation or not. The light that plants absorb or not can in roundabout way quantify the measure of nitrogen the plants have. NDVI can be gained from satellite picture which may have high cost and not sensible for choosing nitrogen in little range. Contains various examples, it is to a great degree dreary.

1.4 SPAD Meter
It is chlorophyll measurement device. It is used by clipping the meter head on the leaf, the meter measures transmission of 650 nm red light which chlorophyll absorb it and transmission of 940 nm infrared light which chlorophyll does not absorb.The meter gives the relative value that has no unit but since the nitrogen quantity will vary with the quantity of chlorophyll, there are many research studies on converting SPAD value to nitrogen quantity in plant so the meter can be used to measure nitrogen quantity in plant too. This method suitable for medium area because of measuring nitrogen in 1 leaf, the sample leaf must be measured by SPAD meter at least 5 times and then find the average value. For a large area which contains many samples, it is very time-consuming.
Leaf Color Chart
It is a chart that’s consists of many shades of leaf color from light green to dark green. It is used by comparing the leaf colour with the colour in the chart. The chart will give a range of nitrogen quantity possible in that leaf. Different crop species requires different chart. This is the easiest but also the least accurate method and it is suitable for medium area.
The chemical test method takes too much time, NDVI method costs too much money from satellite image, leaf color chart are not accurate enough and SPAD meter is hard to use and takes too much time when using with sugarcane due to the height of sugarcane and crowded leaves as it grow.
1.6 Motivation for the project
The motivation of the project is:
Its various practical application and need to the farmer and agriculture society.

Estimation of nitrogen content in leaves based on color and texture.

1.7 Problem Statement
To design and implement an efficient method for “Estimation of Nitrogen Content in Maize Leaves using Image Processing Technique”. Here, the input is an image of a maize leaf and output is percentage of nitrogen in the leaf. Estimation of nitrogen content in leaves by extracting the features like entropy, mean, average energy and variance using image processing techniques and regression modelling.

1.8 Scope of the project
The proposed approach can be used in several situations:
Automatic and faster nitrogen content estimation method in a plant based on leaf colour and it would be helpful for farmers.

Explore the possibility of determining the quality and quantity of crop yield by using texture and colour features.

1.9 Objectives of the project
The main objectives of the proposed system are :Estimation of nitrogen content based on colour and texture.

Proposing a method that is efficient and gives fast result.

1.10 Review of Literature
Vasudev B. Sunagar et al have proposed image processing technique for estimation of nitrogen content in leaves based on color and texture. The image is acquired using digital camera having high resolution. The camera is located at a position normal to the object. After getting the image, pre-processing technique is applied to remove the noise of the source image. The color and texture characters of maize leaves are extracted. Color characters analysed using RGB and HSI model. Texture features are entropy, energy, contrast and homogeneity. A relationship between extracted features and nitrogen content is developed.

V.K.Tewari et al 2 have proposed image processing technique using Regression Model for estimation of nitrogen content in paddy crop based on color. They have taken various color features such as R, G and B normalized ‘r’ and normalized ‘g’. Regression models were developed and evaluated between various image features; they have observed minimum and average accuracy. Actual and predicted values of nitrogen percent were linearly correlated with R2 value; this showed that the plant nitrogen content can be successfully estimated by its color image feature.
Piti Auearunyawat et al have proposed image processing technique using Regression Model for estimation of nitrogen content in sugarcane leaf based on color. Here, sugarcane leaf images are captured by a portable camera and then relationships between nitrogen content and leaf colors in red (R), green (G), blue (B) and near infrared (IR) are examined. They found that of the terms R, G, B, G/B, G/R, R/B and ((IR-R) / (IR+R)) had the significant relationship with nitrogen concentration in the sugarcane leaves.

M. M. Ali et al 4 have proposed image processing technique using Dark Green Color Index (DGCI) for estimation of plant chlorophyll and nitrogen contents in tomato leaf based on color. In this paper they have developed a non-destructive approach to detect plant Ch (Chlorophyll) and N levels using an image processing technique using the RGB (Red, Green and Blue) colour model. The experiment was conducted on tomato (Tommy Toy) in field with three N treatments (nitrogen application), where images leaf were collected using a camera. The algorithm achieves better correlation with the value of Ch and N that are-, measured in laboratory, compared with the existing non-destructive methods of SPAD 502 and Dark Green Colour Index (DGCI).

Asaram Pandurang Janwale et al 5 have proposed image processing technique using color model for estimation of nitrogen contents in cotton (Gossypium Hirsutum L) based on color. This paper reviews these different techniques used to detect Nitrogen deficiency in cotton plant and conclude image processing techniques using color models is the best technique to detect deficiency in cotton plant easily, inexpensively and more accurately.

Santosh S.Lomte et al 5 have proposed shading analysis; this study was used to develop a non-destructive procedure for checking cotton advancement and N status using an electronic camera. Electronic pictures were taken of the cotton covers amongst advancement and full grow. The result showed that the best relationship between safe house spread and over-the-ground hard and fast N content had a 2 estimation of 0.926 and a RMSE estimation of 1.631 gm. In this study 2 distinctive segments of picture of leaf were deleted, for instance, the condition of leaf, scope of leaf, condition of crevices present on the leaf, disease spots et cetera. These segments were removed using differing picture planning strategies. The segment extraction was the key motivation behind this work. These isolated components were used to choose the occasion of the particular deficiency related to key supplements of cotton plant. Nitrogen deficiency perceived by two preliminary strides, Histogram examination and estimation of leaf locale.
1.11 Organization of Report
The project report is organized as follows:
Chapter 2- System Requirements Specification
This chapter presents a brief description of the Matlab software used in project along with other software, hardware requirements.

Chapter 3- High Level Design
This chapter presents a brief discussion about the high level design of proposed system and description about texture features like entropy, mean, average energy and variance.

Chapter 4–Detailed Design
This chapter presents the Flow Chart for estimation of nitrogen content in maize leaves.
Chapter 5–Implementation
This chapter contains pseudo code of the proposed work.
Chapter 6–System Testing
This chapter deals with software test environment, test procedure and test cases for each module.

Chapter 7–Results and Discussion
This chapter gives the experimental results and analysis of the proposed system and process.

Chapter 8–Conclusion and Future work
This chapter gives the conclusion of the project and the future enhancement.

1.12 Summary
This chapter introduces overview of estimation of nitrogen content in section 1.1. Overview of chemical analysis method (Kjeldahl) is given in section 1.2. NDVI (Normalized Difference Vegetation Index) is explained in section 1.3. Section 1.4 briefly explains about SPAD meter. Explanation of the leaf color chart is given in section 1.5. Motivation of our project is mentioned in section 1.6. Problem statement of our project given in section 1.7. Scope of the project is listed in section 1.8. The objectives are clearly mentioned in section 1.9. The literature survey is described in section 1.10 and organization of the report is given in section 1.11.

CHAPTER 2
SOFTWARE REQUIREMENT
SPECIFICATION (SRS)
This chapter describes an overview and specification of Matlab programming language which is used for implementation of proposed work. It also represents other related requirements for normal operation of Matlab and the project. The SRS contains functional and non-functional requirements for solving the problem. A best specification gives complete statement of what the system is to do and is used as the basis for system design.
2.1 Specific Requirements
Matlab Tool
MATLAB, which initially stood for MATrix LABoratory, has developed into a state-of-the-art mathematical software package, which is used extensively in both academia and industry. It is an interactive program for numerical computation and data visualization, which along with its programming capabilities provides a very useful tool for almost all areas of science and engineering. It is one of the leading software packages for numerical computation. MATLAB program and script files have filenames ending with “.m” and also supporting “.p” but our project developing based on “.m” file10. The programming language is exceptionally straightforward since almost every data object is assumed to be an array. Graphical output is available to supplement numerical results.
Optimization Toolbox Product Description
Optimization Toolbox provides functions for finding parameters that minimize or maximize objectives while satisfying constraints. The toolbox includes several solvers for linear programming, mixed-integer linear programming, quadratic programming, nonlinear optimization, and nonlinear least squares (Curve fitting), graphical user interface 10. One can use these solvers to find optimal solutions to continuous and discrete problems, perform trade-off analyses, and incorporate optimization methods into algorithms and applications.

Curve Fitting Tool Box
Curve Fitting Toolbox provides functions for fitting curves and surfaces to data. The toolbox lets you perform exploratory data analysis, pre-process and post-process data, compare candidate models, and remove outliers. One can conduct regression analysis using the library of linear and nonlinear models provided or specify your own custom equations.  The library provides optimized solver parameters and starting conditions to improve the quality of your fits. The toolbox also supports nonparametric modelling techniques, such as splines, interpolation, and smoothing.

Image Processing Tool Box
Image Processing Toolbox provides a comprehensive set of reference-standard algorithms, functions, and apps for image processing, analysis, visualization, and algorithm development. One can perform image analysis, image segmentation, image enhancement, noise reduction, geometric transformations, and image registration.

2.2 Minimum Hardware Requirements
Processor : Minimum Dual core Pentium 4
RAM : Minimum 2GB
Hard disk size : 40GB
2.3 Software Requirements
Operating System: Windows 7 and above
Programming Language: MATLAB 2014b 64bit
2.4 Summary
This chapter describes about the particular prerequisites in section 2.1. Least equipment necessities for the project is given in section 2.2. Programming prerequisites are given in section 2.3.

CHAPTER 3
HIGH LEVEL DESIGN
High level design provides an overview of the system flow. It gives more information for the user to understand the logic. Here we see the basic knowledge about the system design in flowchart. Following are the issues that are the primary modules for the design.
3.1 Proposed System
The proposed system framework contains the procedures to collect the sample images of maize leaf using camera under different illuminations (i.e., natural day light, fluorescent light ; incandescent light), image pre-processing, prediction of plant nitrogen content using regression model.

Sample Collection
Collect the sample of maize leaves. Capture the image of collected samples under the different uniform illumination (Day Natural light, Fluorescent light and Incandescent light) with a dark black background. To capture images a 13 mega pixel Sony digital camera is used. Nitrogen content of collected leaves is calculated in laboratory using Kjeldahl method which becomes the reference for development of proposed system.
Apply Pre-processing Techniques
Outside interference will cause a variety of noise in the process of image acquisition, which will significantly affect the quality of the image 1. So it is needed to pre-process the image, such as removing noise and enhancing image.

The noise of captured image often shows as the mutation of the isolated pixel in the image which is called as grain noise. Grain noise show high frequency characteristics and it has great gray difference. Also the spaces are not interrelated 5. The commonly used methods of smoothing were the median filter, neighbourhood mean, spatial low pass filter and frequency low pass filter. In this study, we use the median filter.

Gray Level Co-occurrence Matrix
A GLCM (Gray Level Co-occurrence Matrix) is a square matrix which contains of the same number of rows and columns as the number of gray levels in an image 1. Each matrix element represents the relative frequency with which two pixels, separated by a pixel distance (?x, ?y) occur within a given neighbourhood for the reliability of the statistical estimate 1, the matrix must contain a reasonably high level. To achieve this either the number of gray level values is reduced or a larger window is used. A compromise of the two approaches is generally used. Properties of GLCM are used for texture feature extraction.
3.2 Texture Analysis
Texture features like Entropy, Mean, Average energy and Variance are extracted from the leaf image along with color features.
Entropy
E, a scalar value representing the entropy of gray scale image I. Entropy is a statistical measure of randomness that can be used to characterize the texture of the input image.
E=ip*(log2(p)) (1)
Where p is a pixel gray scale value.Mean
The mean is the average of the numbers: a calculated “central” value of a set of numbers.
x=xN (2)
Where:
x is the mean of the image.

x is the sum of the pixel values of an image.

N is the total number of pixel in the image.
Variance
It is an estimation of the spread between numbers in a data set. It measures how far each number in the set is from the mean. Variance is computed by taking the difference between each number in the set and the mean, squaring the differences and dividing the sum of the squares by the number of values in the set.
S2 = i=1n Xi- Xavg2n-1 (3)
Average Energy
Need to find the average energy, of pixels in an image or a window.
AE=i.jp(i,j)2 (4)
Returns the sum of squared elements.
Correlation
Correlation is a statistical measure that indicates the extent to which two or more variables fluctuate together. A positive correlation indicates the extent to which those variables increase or decrease in parallel; a negative correlation indicates the extent to which one variable increases as the other decreases.

Correlation is calculated using the formula below:
C=i,j(i-?i)(j-?j)p(i,j)?i?j (5)
Where:
? is the mean
? is the variance
p is the pixel
i,j is the pixel co-ordinate values
Returns a measure of how correlated a pixel is to its neighbour over the whole image. Range = -1 1, Correlation is 1 or -1 for a perfectly positively or negatively correlated image.
3.3 Color Features
Color features such as RGB and HSV are extracted from a leaf image.
RGB (Red Green Blue)
RGB refers to a system for representing the colors to be used on a computer display. Red, green, and blue can be combined in various proportions to obtain most colors in the visible spectrum.

HSI (Hue Saturation Intensity)
HSI color system directly describes the light colour by brightness (or lightness), tonality and saturation, which are suitable for color description by humans 1. It is easy for human visual system to distinguish different tonalities, but it is difficult to distinguish different color through brightness and saturation. In this system, H is defined as hue or tonality; I and S are defined as light intensity and saturation respectively. For the above characteristics correlation model is developed to analyse the dependency of nitrogen over the characteristics.
3.4 Normalization
Normalization is the process that changes to the range of pixel intensity values. NormalizedRed= RR2+G2+B2(6)
NormalizedGreen= GR2+G2+B2(7)
Estimation of Nitrogen
The nitrogen content of an image can be estimated by using the following steps
Linear fit using straight line equation based on regression model
Estimate the nitrogen content in maize leaves using regression model
Summary
This chapter explained about proposed system in section 3.1. Explained about texture analysis in section 3.2. Review of the color features is given in section 3.3. Normalization is depicted in section 3.4 and steps for estimation of nitrogen are given in section 3.5.

CHAPTER 4
DETAIL DESIGN
Figure 4.1 shows the flow chart for estimation of nitrogen content, the steps of the estimation process is explained later in this chapter.
4.1 Flow Chart of the Proposed System for estimation of nitrogen content
Start
Read input image from source
Pre-Processing image
Convert the RGB image into R, G and B three planes
Extract R, G and B components
Segment R, G and B component using thresholdingStop
Estimate the N Content using Regression model

Figure 4.1: Flow Chart of the Proposed System for estimation of nitrogen content.
Figure 4.1 shows the flow chart for the estimation of nitrogen content. The flow chart depicts following procedure:
The image is obtained through digital camera using different light sources such as day natural light, fluorescent light and incandescent light. The camera is located at a position normal to the object. Subsequent to getting the image, pre-processing techniques are used to remove the noise in source image. Then convert the RGB image into R, G and B images considering a segment R, G and B part utilizing thresholding techniques 2.Then apply regression model to estimate the plant nitrogen content.
4.2 Estimation of leaves nitrogen content using Regression model.

Start
Read input image from source
Pre-Processing image
Convert the RGB image into Gray
Obtained normalized ‘r’ ‘g’ ; ‘b’ from gray image
Extract the image features
Stop
Correlate between each features ; actual nitrogen content
Select the best Correlated feature
Estimate ‘N’ content using straight line equation

Fig 4.2 Estimation of leaves nitrogen content using Regression model.

Regression mels were developed between image feature and the plant nitrogen content, estimated by chemical analysis with Kjeldahl method. After pre-processing of the image, they were converted into the R, G, B, normalized ‘r’ and normalized ‘g’ image. Various image features were calculated such as mean, variance, average energy and entropy. After features calculation, they were compared with the actual lab values to develop a regression model to get a straight line equation. Then we take feature value and multiply it with slope value (m) of the regression line then add the y intercept constant value to get the estimated nitrogen content of that sample.
4.3 Summary
This chapter explains about the flow chart of the proposed system for estimation of nitrogen content in section 4.1. Explains about estimation of leaves nitrogen content using regression model in section 4.2.CHAPTER 5
IMPLEMENTATION
Implementation is the phase where the system goes for actual functioning.
5.1 Programming Language Selection.
5.1.1 Key Features of Matlab are:
Functions for integrating MATLAB based algorithms with external applications and languages such as C, Java, .NET, and Microsoft Excel.
Tools for building applications with custom graphical interfaces.

Development tools for improving code quality and maintainability and maximizing performance.

Built-in graphics for visualizing data and tools for creating custom plots.

Mathematical functions for linear algebra, statistics, Fourier analysis, filtering, optimization, numerical integration, and solving ordinary differential equations.

High-level language for numerical computation, visualization and application development.

Interactive environment for iterative exploration, design, and problem solving.

5.1.2 MAT LAB GUI (Graphical User Interface)
A graphical user interface (GUI) is a graphical display in one or more windows containing controls, called components that enable a user to perform interactive tasks. The user of the GUI does not have to create a script or type commands at the command line to accomplish the tasks. Unlike coding programs to accomplish tasks, the user of a GUI need not understand the details of how the tasks are performed. GUI components can include menus, toolbars, push buttons, radio buttons, list boxes, and sliders just to name a few. GUIs created using MATLAB. Tools can also perform any type of computation, read and write data files, communicate with other GUIs, and display data as tables or as plots.
5.2 Pseudo codes for pre-processing procedures
Pseudo code for picture obtaining and showing
Input image obtained from source or assumption database and shows the original image.
imread(‘URL’);//Read the image from source URL
figure(); //display the window
imshow();//shows the original image
Pseudo code for smoothing a given information picture
Smoothing, likewise called obscuring, is a straightforward picture preparing operation. In this we will concentrate on smoothing keeping in mind the end goal to diminish noise.
for()//Looping
sm(:,:,i)=medfilt2(a(:,:,i),);//Applying median filter for //smoothing purpose
end//Loop end
Pseudo code for smoothing of leaf boundary
In this section we are utilizing morphological operation in light of the fact that dialet and erosion because noise removing from smoothing image.
imMask=imerode();//Morphological operation
imMask=imdilate();//Dilate the image
5.3 Pseudo code for Image Feature Extraction
Pseudo code for Color Components
To acquired color component like Red, Green and Blue from given input image
R=im1(:,:,1);//Extracting R component
G=im1(:,:,2);//Extracting G component
B=im1(:,:,3);//Extracting B component
Pseudo code for Normalization
Normalization means RGB image converted into three plane like R,G and B.

Normalized Red, Normalized Green, Normalized Blue=normal () //Normalization
Image_rgb1 = double();//Precision value setting
Image_rgb = imresize(, ); //find the image resize
Image_red = Image_rgb1(:,:,1);//Red plane
Image_green = Image_rgb1(:,:,2);//Green plane
Image_blue = Image_rgb1(:,:,3);//Blue plane
for y = 1:row //number of rows in image
for x = 1:col //number of columns in the image
Red = Image_red(y,x);//x and y values of Red component
Green = Image_green(y,x);// x and y values of Green //component
Blue = Image_blue(y,x); //x and y values of Blue component
NormalizedRed = Red/sqrt(Red^2 + Green^2 + Blue^2);//Computing the normalization red.

NormalizedGreen = Green/sqrt(Red^2 + Green^2 + Blue^2); // Computing the normalization Green.

NormalizedBlue = Blue/sqrt(Red^2 + Green^2 + Blue^2);
// Computing the normalization Blue.

Image_red(y,x) = NormalizedRed;
Image_green(y,x) = NormalizedGreen;
Image_blue(y,x) = NormalizedBlue;
End//loop is end
End//loop is end
Image_rgb1(:,:,1) = Image_red;
Image_rgb1(:,:,2) = Image_green;
Image_rgb1(:,:,3) = Image_blue;
Pseudo code for Converting RGB to Gray
In this section we are converting RGB to Gray image because easy to find image feature values like average energy, entropy, mean and variance.

gI = rgb2gray();//Converting RGB to Gray
Pseudo code for Average Energy
averageenergy = graycomatrix(gI);// co-occurrence matrix //syntax finding a normal from dark image
stats = graycoprops(averageenergy,{‘Energy’}) //calculates the statistics //specified in properties from the gray-level co-occurence matrix glcm.
Pseudo code for Entropy
E = entropy(I) returns E, a scalar value representing the entropy of gray scale image gI. Entropy is a statistical measure of randomness that can be used to characterize the texture of the input image.
e=entropy(gI);//entropy sentence structure
Pseudo code for Mean
The mean is the average of the numbers
m = mean2(gI); //Mean syntax Matlab
Pseudo code for Variance
An estimation of the spread between numbers in a data set. It measures how far each number in the set is from the mean. Variance is computed by taking the difference between each number in the set and the mean, squaring the qualifications and dividing the sum of the squares by the number of values in the set.
variance = var(double(im2(:)))// Variance syntax in matlab
Pseudo code for Nitrogen Calculation Part using Regression model
X = ; //Where ‘x’ indicates feature value like normalised ‘r’.
m;// m is a slope value
c;// c is a constant value
n= (x.*m) + c;//Estimate the ‘n’ content
disp(n); // display the n value
y= ; //Where ‘y’ indicates actual nitrogen content
error = y-n; //Subtract between actual nitrogen content and //estimating ‘n’ content. After subtract we got error //on each sample.
Pseudo code for Nitrogen Calculation Part using HSB (Hue Saturation Brightness)
R=double(im3(:,:,1));
G=double(im3(:,:,2));
B=double(im3(:,:,3));
R_av=mean(mean(R))/255; //Average value of R
G_av=mean(mean(G))/255;// Average value of G
B_av=mean(mean(B))/255; //Average value of B
maxi = max(max(R_av,G_av),B_av); // extract the maximum //average value
mini = min(min(R_av,G_av),B_av); //extract the minimum average value
if maxi == R_av H=((G_av-B_av)/(maxi-mini))*60;
end if maxi == G_av H=(((B_av-R_av)/(maxi-mini))+2)*60;
end if maxi == B_av H=(((R_av-G_av)/(maxi-mini))+4)*60;
end S=(maxi-mini)/maxi;
B=maxi;
N1 = ((H – 60)/60 + (1 – S) + (1 – B))/3;// Nitrogen Content in the Image
fprintf(1,’Nitrogen percentage =%f
‘,N1)
NP=mean(mean(N1))//mean of nitrogen content
5.4 Pseudo code for Computing R2 from Polynomial Fits
X = ;// X stores the feature values
Y = ; // Y stores the actual nitrogen content values
p = polyfit(X,Y,1)// Use polyfit to compute a linear regression //that predicts y from x
result yfit://Result of yfit Yfit = p(1) * X + p(2);// Using polyval saves you from typing the fit //equation
Yresid = Y – Yfit;// Compute the residual values.

SSresid = sum(Yresid.^2);// Square the residuals and total them //to obtain the residual sum of squares
SStotal = (length(Y)-1) * var(Y);// Compute the total sum of //squares of y by multiplying the variance of y by the number of observations minus 1
rsq = 1 – SSresid/SStotal// Compute R2 using the formula
5.5 Summary
This chapter presents pseudo codes for estimation of nitrogen content and image features extraction. Here briefly explains about programming language in section 5.1. The pseudo codes for pre-processing procedures are depicted in section 5.2. Pseudo code for image feature extraction is outlined in section 5.3. And pseudo code for computing R2 from polynomial fits given in section 5.4.

CHAPTER 6
SYSTEM TESTING
Software testing is essential for correcting errors and improving the quality of the software system. The software testing process starts once the program is written and the documentation and related data structures are designed. Without proper testing or with incomplete testing, the program or the project is said to be incomplete.

Testing is an important phase in the development life cycle of the product; this is the phase where the error remaining from all the previous phases will be detected. Hence testing plays a very critical role for quality assurance and ensuring the reliability of the software. During the testing, the program will be executed with a set of test cases and the output of the program for the test cases will be evaluated to determine whether the program is performing as expected. Errors which may be found during the testing will be corrected by using the following testing steps and correction will be recorded for future references. The testing stage has the following goals:
To maintain the quality of the project.

To find and eliminate any residual errors from previous stages.

To validate the software as a solution to the original problem.

To provide operational reliability of the system.

During testing the major activities are concentrated on the examination and modification of the source code.

6.1 Software test environment
In this section, the programs that made up the system were tested. This is considered as functional testing. During the development process itself all the syntax errors got rooted out. For this we developed test case that results in executing every instruction in the program or module i.e. every path through the program was tested.

Preparation of test data plays a vital role in the system testing. In this section we present some test images which we used to examine the system. We consider test images of three illuminations for testing as shown in table 6.1

Table 6.1: Different illumination of sample images is considered for testing.

SI no. Illumination types Number of images
1 Day natural light 100 images
2 Fluorescent light 100 images
3 Incandescent light 100 images
6.2 Test procedures
Test cases are the key factors to the success of any system. Performance of a system is analysed based on the cases written for functional performance of a system. Test cases are critical for the successful performance of the system. Test procedures will be command procedures which in general will do the following:
Compile ; link reference programs.

Execute reference program with test input data.

6.3 Functional test cases
6.3.1 Test cases for grade based on illumination.

Testing focuses on functional task of the system. Here the results obtained manually from Agriculture University that the results we are compared with the computed results obtained from the program. Some test results are mentioned in table 6.1 and all other test results are represented in results and analysis section. Here we compared three illumination images, and then we are deciding which illumination is correctly matched to actual results.

Sl.noIllumination image Test status
1
Day Natural Light
Accepted
2
Fluorescent Light Accepted
3
Incandescent Light Rejected
6.3.2 Test cases for prediction results and manual results on leaves.

Test case Illumination Type Actual results or Chemical test result Estimation of N content using regression model Errors in %
Sample 1
a) 0.43425 0.486 11
b) 0.43425 0.388 10
c) 0.43425 0.488 -12
Sample 2
a) 0.45763 0.485
6
b) 0.45763 0.364
20
c) 0.45763 0.488
-7
Sample 3
a) 0.44957 0.502
11
b) 0.44957 0.363
18
c) 0.44957 0.489
-8
Sample 4
a) 0.47420 0.486
2
b)
0.47420 0.396
16
c)
0.47420 0.489
-3
Sample 5
a)
0.47431 0.480
1
b) 0.47431 0.389
17
c) 0.47431 0.487
-2
Sample 6
a) 0.49552 0.479
3
b) 0.49552 0.404
18
c) 0.49552 0.489
1
Sample 7
a) 0.50485 0.481
4
b) 0.50485 0.423
15
c) 0.50485 0.488
2
Sample 8
a) 0.53902 0.490
8
b)
0.53902 0.401
25
c)
0.53902 0.487
9
Sample 9
a) 0.52987 0.495
6
b) 0.52987 0.386
26
c) 0.52987 0.490
7
Sample10
a) 0.53351 0.501
5
b)
0.53351 0.421
20
c) 0.53351 0.488
8
The goal is to find the how much sample has matched to chemical test results or experimental results. Test results are represented in table 6.2.

6.4 Summary
This chapter presents software test environment in section 6.1. Test procedure is given in section 6.2. Functional test cases are shown in section 6.3.

CHAPTER 7
RESULTS AND ANALYSIS
Table 7.1.1 Some sample images on Different Illumination
Samples Day Natural Light Fluorescent Light Incandescent Light
Sample 01
Sample 02
Sample 03
Sample 04
Sample 05
Sample 06
Sample 07
Sample 08
Sample 09
Sample 10

7.1 Results of Maize Leaves on Different Illumination
Fig7.1 shows initially get the image from source. Then applied pre-processing techniques for noise removal and smoothing the image. After pre-processing image features are extracted from gray image and then analysis the nitrogen content of leaf part is done. Initially we have taken different illumination images.
Results on day natural light.

0264795
(a) Input image(b) Smooth image
Nitrogen (%) = 0.495

(c) Gray image
Results on fluorescent light.

(b) Input image(c) Smooth image
Nitrogen (%) = 0.386

(d) Gray image
Results on incandescent light.

(e)Input image (f) Smooth image
Nitrogen (%) = 0.490

(g) Gray image Fig 7.1 Estimation of Nitrogen Content in Maize Leaves on Different Illuminations
The above figure 7.1 shows the calculation of nitrogen content for day natural light, fluorescent light and incandescent light.
We have collected ten samples and each sample contains ten images on different illumination and angle.
7.2 Actual Nitrogen content of leaves and corresponding image features under fluorescent light
Table 7.2 lists various features extracted from the leaf images under fluorescent light. The actual nitrogen content of the sample leaves are plotted against the image features corresponding to the leaves images. Fig 7.2 shows the various plots of the actual nitrogen content vs. the image features extracted from the corresponding leaf images. Each plot contains the parameters m (slope) and c (y – intercept) of the regression line along with the coefficient of determination (R2) of the linear regression.

To further analyse the data, polynomial curve (quadratic and cubic) were used for curve fitting for the computed data, but the results were not satisfactory, hence only linear line fitting was retained for all the other data.

Image Features v/s Actual Nitrogen Content got by Kjeldahl method are plotted and a line is drawn using linear regression as can be seen in Fig 7.2.

Table 7.2 Image Features v/s Actual Nitrogen Content
Samples Actual nitrogen (%) Image Features
Average Energy Mean Entropy Variance Normalized R Normalized G
Sample_01 0.434 0.297 51.979 5.231 62.468 0.580 0.630
Sample_02 0.457 0.402 53.539 5.297 41.799 0.559 0.663
Sample_03 0.449 0.509 37.036 5.275 55.736 0.558 0.625
Sample_04 0.474 0.464 115.477 4.956 57.901 0.588 0.625
Sample_05 0.474 0.508 37.060 5.263 35.437 0.581 0.642
Sample_06 0.495 0.617 35.423 5.139 21.099 0.595 0.593
Sample_07 0.504 0.330 75.556 5.507 33.653 0.612 0.645
Sample_08 0.539 0.298 110.597 5.409 22.893 0.591 0.655
Sample_09 0.529 0.376 39.239 5.303 11.805 0.579 0.626
Sample_10 0.533 0.453 66.176 5.167 23.509 0.610 0.688

(a) Average Energy v/s Nitrogen Content (b) Entropy v/s Nitrogen Content
(c) Mean v/s Nitrogen Content (d) Variance v/s Nitrogen Content

(e) Normalized R v/s Nitrogen Content (f) Normalized G v/s Nitrogen Content
Fig 7.2. Image Features v/s Actual Nitrogen content got by Kjeldahl method are plotted and along with linear regression line.

7.3 Actual Nitrogen content of leaves and corresponding image features under day natural light.

Image Features v/s Actual Nitrogen Content got by Kjeldahl method are plotted and a line is drawn using linear regression as can be seen in Fig 7.3.

Table 7.3 Image Features v/s Actual Nitrogen Content
Samples Actual nitrogen (%) Image Features
Average Energy Mean Entropy Variance Normalized R Normalized G
Sample_01 0.434 0.175 102.961 5.954 13.269 0.592 0.553
Sample_02 0.457 0.262 160.670 5.639 12.353 0.592 0.542
Sample_03 0.449 0.252 171.783 6.025 28.960 0.618 0.554
Sample_04 0.474 0.430 135.445 4.862 35.589 0.594 0.559
Sample_05 0.474 0.322 120.713 5.195 12.822 0.583 0.562
Sample_06 0.495 0.326 145.529 5.390 4.156 0.581 0.551
Sample_07 0.504 0.287 146.310 5.426 17.022 0.586 0.552
Sample_08 0.539 0.254 118.437 5.988 15.957 0.599 0.548
Sample_09 0.529 0.223 151.557 6.001 6.786 0.607 0.545
Sample_10 0.533 0.434 92.377 3.921 9.274 0.616 0.539

(a) Average Energy v/s Nitrogen Content (b) Entropy v/s Nitrogen Content

(c) Mean v/s Nitrogen Content (d) Variance v/s Nitrogen Content

(e) Normalized R v/s Nitrogen Content (f) Normalized G v/s Nitrogen Content
Fig 7.3. Image Features v/s Actual Nitrogen Content got by Kjeldahl method are plotted and a line is drawn using linear regression.

7.4 Actual Nitrogen content of leaves and corresponding image features under incandescent light.

Image Features v/s Actual Nitrogen Content got by Kjeldahl method are plotted and a line is drawn using linear regression as can be seen in Fig 7.4.

Table 7.4 Image Features v/s Actual Nitrogen Content
Samples Actual nitrogen (%) Image Features
Average Energy Mean Entropy Variance Normalized R Normalized G
Sample_01 0.434 0.351 84.872 5.087 141.68 0.820 0.452
Sample_02 0.457 0.328 89.093 5.166 214.750 0.801 0.429
Sample_03 0.449 0.244 84.950 5.464 151.981 0.839 0.211
Sample_04 0.474 0.313 93.663 5.432 293.433 0.838 0.411
Sample_05 0.474 0.222 98.902 5.903 199.617 0.790 0.474
Sample_06 0.495 0.248 85.147 5.399 114.754 0.834 0.377
Sample_07 0.504 0.282 73.471 5.883 152.359 0.804 0.446
Sample_08 0.539 0.306 76.801 5.981 190.872 0.797 0.459
Sample_09 0.529 0.244 63.632 5.226 96.369 0.853 0.397
Sample_10 0.533 0.410 53.321 3.839 78.173 0.822 0.464

(a) Average Energy v/s Nitrogen Content (b) Entropy v/s Nitrogen Content

(c) Mean v/s Nitrogen Content (d) Variance v/s Nitrogen Content

(e) Normalized R v/s Nitrogen Content (f) Normalized G v/s Nitrogen Content
Fig 7.4. Image Features v/s Actual Nitrogen Content got by Kjeldahl method are plotted and a line is drawn using linear regression.

7.5 Comparison between Nitrogen content computed using Regression model and Actual Nitrogen content under Fluorescent light From the plots of various features under different light sources in previous figures, it can be seen that the Normalised R and G features have minimum R2 value. Using the regression line parameters m (slope) and c (y-intercept) and the image features, nitrogen content was computed. Table 7.5 gives the actual nitrogen content got by using Kjeldahl method and the computed nitrogen content using the regression line, along with the errors.

Table 7.5 (a) Nitrogen content (Regression) v/s Actual nitrogen content with errors.

Samples Actual nitrogen (%) Normalized R Nitrogen content (%) computed using Regression line Error Error in (%)
Sample_01 0.434 0.580 0.388 0.045 10
Sample_02 0.457 0.559 0.364 0.092 20
Sample_03 0.449 0.558 0.363 0.085 18
Sample_04 0.474 0.588 0.396 0.077 16
Sample_05 0.474 0.581 0.389 0.084 17
Sample_06 0.495 0.595 0.404 0.090 18
Sample_07 0.504 0.612 0.423 0.080 15
Sample_08 0.539 0.591 0.401 0.138 25
Sample_09 0.529 0.579 0.386 0.142 26
Sample_10 0.533 0.610 0.421 0.111 20
Average 18.5%
Table 7.5 (b) Nitrogen content (Regression) v/s Actual nitrogen content with errors.

Samples Actual nitrogen (%) Normalized G Nitrogen content (%) using Regression Error Error in (%)
Sample_01 0.434 0.630 0.484 -0.050 -11
Sample_02 0.457 0.663 0.499 -0.042 -9
Sample_03 0.449 0.625 0.482 -0.033 -7
Sample_04 0.474 0.625 0.482 -0.008 -1
Sample_05 0.474 0.642 0.489 -0.015 -3
Sample_06 0.495 0.593 0.467 0.027 5
Sample_07 0.504 0.645 0.491 0.012 2
Sample_08 0.539 0.655 0.495 0.043 7
Sample_09 0.529 0.626 0.482 0.046 8
Sample_10 0.533 0.688 0.510 0.022 4
Average -0.5
7.6 Comparison between Nitrogen Content (Regression model) and Actual Nitrogen Content on Day natural light.

Finding errors between actual nitrogen content and nitrogen content using regression.
Table 7.6 (a) Nitrogen content (Regression) v/s Actual nitrogen content with errors.

Samples Actual nitrogen (%) Normalized R Nitrogen content (%) using Regression Errors Error in (%)
Sample_01 0.434 0.592 0.486 0.051 11
Sample_02 0.457 0.592 0.485 0.028 6
Sample_03 0.449 0.618 0.502 0.052 11
Sample_04 0.474 0.594 0.486 0.012 2
Sample_05 0.474 0.583 0.800 0.005 1
Sample_06 0.495 0.581 0.479 0.015 3
Sample_07 0.504 0.586 0.481 0.022 4
Sample_08 0.539 0.599 0.490 0.048 8
Sample_09 0.529 0.607 0.495 0.033 6
Sample_10 0.533 0.616 0.501 0.031 5
Average 6
Table 7.6 (b) Nitrogen content (Regression) v/s Actual nitrogen content with errors.

Samples Actual nitrogen (%) Normalized G Nitrogen content (%) using Regression Errors Error in (%)
Sample_01 0.434 0.553 0.483 -0.049 -11
Sample_02 0.457 0.542 0.509 -0.052 -11
Sample_03 0.449 0.554 0.481 -0.032 -7
Sample_04 0.474 0.559 0.469 0.004 1
Sample_05 0.474 0.562 0.462 0.011 2
Sample_06 0.495 0.551 0.488 0.006 1
Sample_07 0.504 0.552 0.486 0.018 3
Sample_08 0.539 0.548 0.495 0.043 7
Sample_09 0.529 0.545 0.502 0.026 4
Sample_10 0.533 0.539 0.517 0.016 3
Average -0.8
7.7 Comparison between Nitrogen Content (Regression model) and Actual Nitrogen Content on Incandescent light.

Finding errors between actual nitrogen content and nitrogen content using regression.

Table 7.7 (a) Nitrogen content (Regression) v/s Actual nitrogen content with errors.

Samples Actual nitrogen (%) Normalized R Nitrogen content (%) using Regression Errors Error in (%)
Sample_01 0.434 0.820 0.488 -0.054 -12
Sample_02 0.457 0.801 0.488 -0.034 -7
Sample_03 0.449 0.839 0.489 -0.040 -8
Sample_04 0.474 0.838 0.489 -0.015 -3
Sample_05 0.474 0.790 0.487 -0.013 -2
Sample_06 0.495 0.834 0.489 0.005 1
Sample_07 0.504 0.804 0.488 0.015 2
Sample_08 0.539 0.797 0.487 0.051 9
Sample_09 0.529 0.853 0.490 0.038 7
Sample_10 0.533 0.822 0.488 0.044 8
Average -0.5
Table 7.7 (b) Nitrogen content (Regression) v/s Actual nitrogen content with errors.

Samples Actual nitrogen (%) Normalized G Nitrogen content (%) using Regression Errors Error in (%)
Sample_01 0.434 0.452 0.489 -0.055 -12
Sample_02 0.457 0.429 0.488 -0.031 -6
Sample_03 0.449 0.211 0.479 -0.030 -6
Sample_04 0.474 0.411 0.487 -0.013 -2
Sample_05 0.474 0.474 0.490 -0.016 -3
Sample_06 0.495 0.377 0.486 0.008 1
Sample_07 0.504 0.446 0.489 0.014 2
Sample_08 0.539 0.459 0.489 0.049 9
Sample_09 0.529 0.397 0.487 0.041 7
Sample_10 0.533 0.464 0.490 0.042 7
Average -0.3
7.8 Maximum R2 value on features in under each light condition.

Table 7.8 Maximum R2 value on features in under each light condition
Illumination types
Day natural light-R2 value on
Normalized R ; G Fluorescent light-R2 value on
Normalized R ; G Incandescent light-R2value on
Normalized R ; G
R G R G R G
0.0496 0.2166 0.3957 0.0966 0.0005 0.0014
Table 7.8 shows maximum R2 values on features like normalized R ;G. After estimating maximum R2 values under each light condition we got maximum R2 values on normalized R in fluorescent light. In this proposed work we conclude fluorescent light is better for estimating maximum R2 values
7.10 Summary
This chapter explains about samples images collected on different illumination, Results of maize leaves on different illumination in section 7.1. Actual nitrogen content of leaves and corresponding image features under fluorescent light is given in section 7.2. Section 7.3 depicts the actual nitrogen content of leaves and corresponding image features under day natural light. Actual nitrogen content of leaves and corresponding image features under incandescent light is given in section 7.4. Review about the comparison between nitrogen content computed using the regression model and actual nitrogen content under fluorescent light is given in section 7.5. Comparison between nitrogen content (regression model) and actual nitrogen content on day natural light with errors in section 7.6. Explain table for nitrogen content (regression model) and actual nitrogen content on incandescent light with errors in section 7.7. Estimate the maximum r2 value on features in under each light condition in section 7.8. Results for estimation of nitrogen content on different illumination in section 7.9.

CHAPTER 8
CONCLUSION AND FUTURE WORK
8.1 Conclusion
In this work, estimation of nitrogen content in a maize leaf is done based on color and texture features like entropy, mean, average energy, and variance.
The literature review outlines several methods of estimation of nitrogen content in the leaf. The two estimation methods like Kjeldahl (chemical test) and SPAD meter, these are costlier and time consuming. The image processing methods like regression techniques may work well with commonly speedier for estimating nitrogen content in leaves.

This work explored the possibility of using image processing techniques to estimate the nitrogen content in maize leaves. To test the proposed method, 10 sample leaves were taken from different maize plants and their images were captured under various illumination sources. Then they were analysed at the laboratory in the agriculture university get the actual nitrogen content in the leaves. Ten images were captures under 3 different illumination sources (natural day light, incandescent light and fluorescent light) for each of the10 leaf samples to result in 300 digital images.

We carried out experiments by extracting various features from the images and correlated the features with the actual nitrogen content data using regression approach. The features that have maximum correlation will have higher value of R2. From the experiments, we can say that the images captured under fluorescent light perform better. Further, the image features like normalized ‘r’ and normalized ‘g’ give the better correlation result with highest value of R2(coefficient of determination). The regression model was developed between various image features and the plant nitrogen content shows that that the plant nitrogen content can be successfully estimated using its color image features.

8.2 Future work
Expansion of this work may target estimation of nitrogen content based on different illumination like infrared and ultra violet light. Also the use of other surface texture and color features can be explored for comparison between manual results.
Acknowledgement
My special thanks to Prof. Dr. HEMLA NAIK and Dr. GURUMURTHY, department of plant analysis, Agriculture University Shivamogga, for providing necessary laboratory results means chemical test results using Kjeldahl method on my project samples.

REFERENCES
1 Vasudev B. Sunagar, Pradeep A. Kattimani, vimala A. Padasali, neetha V. Hiremath “Estimation of nitrogen content in leaves using image processing” proceeding of International Conference on Advanced in Engineering ; Technology, 20th April-2014,Goa,India,ISBN-978-93-84204-06.

2 V.K.Tewari, Ashok Kumar Arudra, Satya Prakash Kumar, Vishal Pandey, Narendra Singh Chandel, “Estimation of plant nitrogen content using digital image processing”, proceeding Agri Eng. Int: CIGR Journal-july-2013.

3Piti Auearunyawat, Teerasit Kasetkasem, Audthasit Wongmaneeroj, Akinori Nishihara and Rachaporn Keinprasit. An Automatic Nitrogen Estimation Method in Sugarcane Leaves Using Image Processing Techniques”, International Conference on Agricultural, Environment and Biological Sciences (ICAEBS’2012) May 26-27, 2012 Phuket.4 M. M. Ali, Ahmed Al-Ani, Derek Eamus and Daniel K. Y. Tan. “An Algorithm Based on the RGB Colour Model to Estimate Plant Chlorophyll and Nitrogen Contents”, 2013 International Conference on Sustainable Environment and Agriculture IPCBEE vol.57 (2013) © (2013) IACSIT Press, Singapore DOI: 10.7763/IPCBEE. 2013. V57. 10.

5 Asaram Pandurang Janwale and Santosh S. Lomte, “Automatic Estimation of Nitrogen content in Cotton (Gossypium Hirsutum L) Plant by using Image Processing Techniques: A Review”. International Journal of Computer Applications (0975 – 8887) Volume 120 – No.20, June 2015.
6 Bremner, J.M. and C.S. Mulvaney. 1982. Total nitrogen, pp. 595–624. In: A.L. Page, R.H. Miller, and D.R. Kenney (Eds.), Method of Soil Analysis. Part 2. Agronomy Monograph No. 9. American Society of Agronomy, Madison, WI.7 Baethegen, W.E. and M.M. Alley. 1989. A manual colorimetric procedure for measuring ammonium nitrogen in soil and plant Kjeldahl digests. Comrnun. Soil Sci. Plant Anal. 20:961-969.
8 Bradstreet, R.B. 1965. The Kjeldahl Method for Organic Nitrogen. Academic Press, New York. Bremner, J.M. and D.R. Keeney. 1965. Steam distillation methods for the determination of ammonium, nitrate, and nitrite. Anal. Chetn. 32:485^195.
9 Bremner, J.M. and M.A. Tabatabai. 1972. Use of an ammonia electrode for deterrnina- tion of ammonium in Kjeldahl analysis of soils. Commun. Soil Sci. Plant Anal. 3:159-165.

10 www.mathworks.in.