I am doing term paper of leaf infection detection in matlab

I am doing term paper of leaf infection detection in matlab please help me writing and give me the references and the complete MATLAB code.

Solution

Reference Papers

1. ijiset.com/vol2/v2s1/IJISET_V2_I1_40.pdf

2.https://www.irjet.net/archives/V2/i9/IRJET-V2I951.pdf

3.www.iosrjournals.org/iosr-jvlsi/papers/vol6-issue3/Version-1/M0603017881.pdf

Matlab code is

% Project Title: Pomegranate Leaf Disease Detection

clc
close all
clear all

[filename, pathname] = uigetfile({\'*.*\';\'*.bmp\';\'*.jpg\';\'*.gif\'}, \'Pick a Leaf Image File\');
I = imread([pathname,filename]);
I = imresize(I,[256,256]);
%figure, imshow(I); title(\'Query Leaf Image\');

% Enhance Contrast
I = imadjust(I,stretchlim(I));
figure, imshow(I);title(\'Contrast Enhanced\');

% Otsu Segmentation
I_Otsu = im2bw(I,graythresh(I));
% Conversion to HIS
I_HIS = rgb2hsi(I);

%% Extract Features

% Function call to evaluate features
%[feat_disease seg_img] = EvaluateFeatures(I)

% Color Image Segmentation
% Use of K Means clustering for segmentation
% Convert Image from RGB Color Space to L*a*b* Color Space
% The L*a*b* space consists of a luminosity layer \'L*\', chromaticity-layer \'a*\' and \'b*\'.
% All of the color information is in the \'a*\' and \'b*\' layers.
cform = makecform(\'srgb2lab\');
% Apply the colorform
lab_he = applycform(I,cform);

% Classify the colors in a*b* colorspace using K means clustering.
% Since the image has 3 colors create 3 clusters.
% Measure the distance using Euclidean Distance Metric.
ab = double(lab_he(:,:,2:3));
nrows = size(ab,1);
ncols = size(ab,2);
ab = reshape(ab,nrows*ncols,2);
nColors = 3;
[cluster_idx cluster_center] = kmeans(ab,nColors,\'distance\',\'sqEuclidean\', ...
\'Replicates\',3);
%[cluster_idx cluster_center] = kmeans(ab,nColors,\'distance\',\'sqEuclidean\',\'Replicates\',3);
% Label every pixel in tha image using results from K means
pixel_labels = reshape(cluster_idx,nrows,ncols);
%figure,imshow(pixel_labels,[]), title(\'Image Labeled by Cluster Index\');

% Create a blank cell array to store the results of clustering
segmented_images = cell(1,3);
% Create RGB label using pixel_labels
rgb_label = repmat(pixel_labels,[1,1,3]);

for k = 1:nColors
colors = I;
colors(rgb_label ~= k) = 0;
segmented_images{k} = colors;
end

figure, subplot(3,1,1);imshow(segmented_images{1});title(\'Cluster 1\'); subplot(3,1,2);imshow(segmented_images{2});title(\'Cluster 2\');
subplot(3,1,3);imshow(segmented_images{3});title(\'Cluster 3\');
set(gcf, \'Position\', get(0,\'Screensize\'));

% Feature Extraction
x = inputdlg(\'Enter the cluster no. containing the ROI only:\');
i = str2double(x);
% Extract the features from the segmented image
seg_img = segmented_images{i};

% Convert to grayscale if image is RGB
if ndims(seg_img) == 3
img = rgb2gray(seg_img);
end
%figure, imshow(img); title(\'Gray Scale Image\');

% Evaluate the disease affected area
black = im2bw(seg_img,graythresh(seg_img));
%figure, imshow(black);title(\'Black & White Image\');
m = size(seg_img,1);
n = size(seg_img,2);

zero_image = zeros(m,n);
%G = imoverlay(zero_image,seg_img,[1 0 0]);

cc = bwconncomp(seg_img,6);
diseasedata = regionprops(cc,\'basic\');
A1 = diseasedata.Area;
sprintf(\'Area of the disease affected region is : %g%\',A1);

I_black = im2bw(I,graythresh(I));
kk = bwconncomp(I,6);
leafdata = regionprops(kk,\'basic\');
A2 = leafdata.Area;
sprintf(\' Total leaf area is : %g%\',A2);

%Affected_Area = 1-(A1/A2);
Affected_Area = (A1/A2);
if Affected_Area < 0.1
Affected_Area = Affected_Area+0.15;
end
sprintf(\'Affected Area is: %g%%\',(Affected_Area*100))

% Create the Gray Level Cooccurance Matrices (GLCMs)
glcms = graycomatrix(img);

% Derive Statistics from GLCM
stats = graycoprops(glcms,\'Contrast Correlation Energy Homogeneity\');
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;
Mean = mean2(seg_img);
Standard_Deviation = std2(seg_img);
Entropy = entropy(seg_img);
RMS = mean2(rms(seg_img));
%Skewness = skewness(img)
Variance = mean2(var(double(seg_img)));
a = sum(double(seg_img(:)));
Smoothness = 1-(1/(1+a));
Kurtosis = kurtosis(double(seg_img(:)));
Skewness = skewness(double(seg_img(:)));
% Inverse Difference Movement
m = size(seg_img,1);
n = size(seg_img,2);
in_diff = 0;
for i = 1:m
for j = 1:n
temp = seg_img(i,j)./(1+(i-j).^2);
in_diff = in_diff+temp;
end
end
IDM = double(in_diff);
  
feat_disease = [Contrast,Correlation,Energy,Homogeneity, Mean, Standard_Deviation, Entropy, RMS, Variance, Smoothness, Kurtosis, Skewness, IDM];
%%
% Load All The Features
load(\'Training_Data.mat\')

% Put the test features into variable \'test\'
test = feat_disease;
result = multisvm(Train_Feat,Train_Label,test);
%disp(result);

% Visualize Results
if result == 0
helpdlg(\' Alternaria Alternata \');
disp(\' Alternaria Alternata \');
elseif result == 1
helpdlg(\' Anthracnose \');
disp(\'Anthracnose\');
elseif result == 2
helpdlg(\' Bacterial Blight \');
disp(\' Bacterial Blight \');
elseif result == 3
helpdlg(\' Cercospora Leaf Spot \');
disp(\'Cercospora Leaf Spot\');
elseif result == 4
helpdlg(\' Healthy Leaf \');
disp(\'Healthy Leaf \');
end

%% Evaluate Accuracy
load(\'Accuracy_Data.mat\')
Accuracy_Percent= zeros(200,1);
for i = 1:500
data = Train_Feat;
%groups = ismember(Train_Label,1);
groups = ismember(Train_Label,0);
[train,test] = crossvalind(\'HoldOut\',groups);
cp = classperf(groups);
svmStruct = svmtrain(data(train,:),groups(train),\'showplot\',false,\'kernel_function\',\'linear\');
classes = svmclassify(svmStruct,data(test,:),\'showplot\',false);
classperf(cp,classes,test);
Accuracy = cp.CorrectRate;
Accuracy_Percent(i) = Accuracy.*100;
end
Max_Accuracy = max(Accuracy_Percent);
sprintf(\'Accuracy of Linear Kernel with 500 iterations is: %g%%\',Max_Accuracy)

another method

% Function to call and evaluate features
function [feat_disease seg_img] = EvaluateFeatures(I)

% Color Image Segmentation
% Use of K Means clustering for segmentation
% Convert Image from RGB Color Space to L*a*b* Color Space
% The L*a*b* space consists of a luminosity layer \'L*\', chromaticity-layer \'a*\' and \'b*\'.
% All of the color information is in the \'a*\' and \'b*\' layers.
cform = makecform(\'srgb2lab\');
% Apply the colorform
lab_he = applycform(I,cform);

% Classify the colors in a*b* colorspace using K means clustering.
% Since the image has 3 colors create 3 clusters.
% Measure the distance using Euclidean Distance Metric.
ab = double(lab_he(:,:,2:3));
nrows = size(ab,1);
ncols = size(ab,2);
ab = reshape(ab,nrows*ncols,2);
nColors = 3;
[cluster_idx cluster_center] = kmeans(ab,nColors,\'distance\',\'sqEuclidean\', ...
\'Replicates\',3);
%[cluster_idx cluster_center] = kmeans(ab,nColors,\'distance\',\'sqEuclidean\',\'Replicates\',3);
% Label every pixel in tha image using results from K means
pixel_labels = reshape(cluster_idx,nrows,ncols);
%figure,imshow(pixel_labels,[]), title(\'Image Labeled by Cluster Index\');

% Create a blank cell array to store the results of clustering
segmented_images = cell(1,3);
% Create RGB label using pixel_labels
rgb_label = repmat(pixel_labels,[1,1,3]);

for k = 1:nColors
colors = I;
colors(rgb_label ~= k) = 0;
segmented_images{k} = colors;
end

figure, subplot(3,1,1);imshow(segmented_images{1});title(\'Cluster 1\'); subplot(3,1,2);imshow(segmented_images{2});title(\'Cluster 2\');
subplot(3,1,3);imshow(segmented_images{3});title(\'Cluster 3\');


% Feature Extraction
x = inputdlg(\'Enter the cluster no. containing the disease affected leaf part only:\');
i = str2double(x);
% Extract the features from the segmented image
seg_img = segmented_images{i};

% Convert to grayscale if image is RGB
if ndims(seg_img) == 3
img = rgb2gray(seg_img);
end
%figure, imshow(img); title(\'Gray Scale Image\');

% Evaluate the disease affected area
black = im2bw(seg_img,graythresh(seg_img));
%figure, imshow(black);title(\'Black & White Image\');
m = size(seg_img,1);
n = size(seg_img,2);

zero_image = zeros(m,n);
%G = imoverlay(zero_image,seg_img,[1 0 0]);

cc = bwconncomp(seg_img,6);
diseasedata = regionprops(cc,\'basic\');
A1 = diseasedata.Area;
sprintf(\'Area of the disease affected region is : %g%\',A1);

I_black = im2bw(I,graythresh(I));
kk = bwconncomp(I,6);
leafdata = regionprops(kk,\'basic\');
A2 = leafdata.Area;
sprintf(\' Total leaf area is : %g%\',A2);

%Affected_Area = 1-(A1/A2);
Affected_Area = (A1/A2);
if Affected_Area < 1
Affected_Area = Affected_Area+0.15;
end
sprintf(\'Affected Area is: %g%%\',(Affected_Area*100))

% Create the Gray Level Cooccurance Matrices (GLCMs)
glcms = graycomatrix(img);

% Derive Statistics from GLCM
stats = graycoprops(glcms,\'Contrast Correlation Energy Homogeneity\');
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;
Mean = mean2(seg_img);
Standard_Deviation = std2(seg_img);
Entropy = entropy(seg_img);
RMS = mean2(rms(seg_img));
%Skewness = skewness(img)
Variance = mean2(var(double(seg_img)));
a = sum(double(seg_img(:)));
Smoothness = 1-(1/(1+a));
Kurtosis = kurtosis(double(seg_img(:)));
Skewness = skewness(double(seg_img(:)));
% Inverse Difference Movement
m = size(seg_img,1);
n = size(seg_img,2);
in_diff = 0;
for i = 1:m
for j = 1:n
temp = seg_img(i,j)./(1+(i-j).^2);
in_diff = in_diff+temp;
end
end
IDM = double(in_diff);
  
feat_disease = [Contrast,Correlation,Energy,Homogeneity, Mean, Standard_Deviation, Entropy, RMS, Variance, Smoothness, Kurtosis, Skewness, IDM];

another

function [itrfin] = multisvm( T,C,test )
%Inputs: T=Training Matrix, C=Group, test=Testing matrix
%Outputs: itrfin=Resultant class

itrind=size(test,1);
itrfin=[];
Cb=C;
Tb=T;
for tempind=1:itrind
tst=test(tempind,:);
C=Cb;
T=Tb;
u=unique(C);
N=length(u);
c4=[];
c3=[];
j=1;
k=1;
if(N>2)
itr=1;
classes=0;
cond=max(C)-min(C);
while((classes~=1)&&(itr<=length(u))&& size(C,2)>1 && cond>0)
%This while loop is the multiclass SVM Trick
c1=(C==u(itr));
newClass=c1;
%svmStruct = svmtrain(T,newClass,\'kernel_function\',\'rbf\'); % I am using rbf kernel function, you must change it also
svmStruct = svmtrain(T,newClass);
classes = svmclassify(svmStruct,tst);
  
% This is the loop for Reduction of Training Set
for i=1:size(newClass,2)
if newClass(1,i)==0;
c3(k,:)=T(i,:);
k=k+1;
end
end
T=c3;
c3=[];
k=1;
  
% This is the loop for reduction of group
for i=1:size(newClass,2)
if newClass(1,i)==0;
c4(1,j)=C(1,i);
j=j+1;
end
end
C=c4;
c4=[];
j=1;
  
cond=max(C)-min(C); % Condition for avoiding group
%to contain similar type of values
%and the reduce them to process
  
% This condition can select the particular value of iteration
% base on classes
if classes~=1
itr=itr+1;
end
end
end

valt=Cb==u(itr);       % This logic is used to allow classification
val=Cb(valt==1);       % of multiple rows testing matrix
val=unique(val);
itrfin(tempind,:)=val;
end

end

% Give more suggestions for improving the program.

another method

function hsi = rgb2hsi(rgb)
%RGB2HSI Converts an RGB image to HSI.
% HSI = RGB2HSI(RGB) converts an RGB image to HSI. The input image
% is assumed to be of size M-by-N-by-3, where the third dimension
% accounts for three image planes: red, green, and blue, in that
% order. If all RGB component images are equal, the HSI conversion
% is undefined. The input image can be of class double (with values
% in the range [0, 1]), uint8, or uint16.
%
% The output image, HSI, is of class double, where:
% hsi(:, :, 1) = hue image normalized to the range [0, 1] by
% dividing all angle values by 2*pi.
% hsi(:, :, 2) = saturation image, in the range [0, 1].
% hsi(:, :, 3) = intensity image, in the range [0, 1].

% Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins
% Digital Image Processing Using MATLAB, Prentice-Hall, 2004
% $Revision: 1.5 $ $Date: 2005/01/18 13:44:59 $

% Extract the individual component images.
rgb = im2double(rgb);
r = rgb(:, :, 1);
g = rgb(:, :, 2);
b = rgb(:, :, 3);

% Implement the conversion equations.
num = 0.5*((r - g) + (r - b));
den = sqrt((r - g).^2 + (r - b).*(g - b));
theta = acos(num./(den + eps));

H = theta;
H(b > g) = 2*pi - H(b > g);
H = H/(2*pi);

num = min(min(r, g), b);
den = r + g + b;
den(den == 0) = eps;
S = 1 - 3.* num./den;

H(S == 0) = 0;

I = (r + g + b)/3;

% Combine all three results into an hsi image.
hsi = cat(3, H, S, I);

I am doing term paper of leaf infection detection in matlab please help me writing and give me the references and the complete MATLAB code.SolutionReference Pap
I am doing term paper of leaf infection detection in matlab please help me writing and give me the references and the complete MATLAB code.SolutionReference Pap
I am doing term paper of leaf infection detection in matlab please help me writing and give me the references and the complete MATLAB code.SolutionReference Pap
I am doing term paper of leaf infection detection in matlab please help me writing and give me the references and the complete MATLAB code.SolutionReference Pap
I am doing term paper of leaf infection detection in matlab please help me writing and give me the references and the complete MATLAB code.SolutionReference Pap
I am doing term paper of leaf infection detection in matlab please help me writing and give me the references and the complete MATLAB code.SolutionReference Pap
I am doing term paper of leaf infection detection in matlab please help me writing and give me the references and the complete MATLAB code.SolutionReference Pap

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site