Is my feature extraction using glcm is true or false? Please!!!
3 views (last 30 days)
Show older comments
i am doing plant disease detection and classification. i do the following steps:
- preprocessing using median filtering
- image segmentation using color thresholder app in matlab
- feature extraction using GLCM
- classification using SVM
In this, i have done step 3 but i'm not certain it is true. So, i want to check up my code in feature extraction don't call function. How can i check up?(Eg. if i get energy=0.5, how to calculate to get 0.5 by handwritten without using mathlab function?)
My code is given in the following:
% Title : Potato Leaf Disease Detection using SVM
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('Input Leaf Image');
%Preprocessing using median filtering
I1 = rgb2gray(I);
I2 = medfilt2(I1,[3 3]);
imshow(I2);title('Filtered Image');
%%Image Segmentation
%Background Removing using Color Thresholder app
[bw,rgb] = background_removal(I);
%Masking Green_Pixels
mask = (rgb(:,:,2)>rgb(:,:,1))&(rgb(:,:,2)>rgb(:,:,3));
seg_img=bsxfun(@times,rgb,cast(imcomplement(mask),'like',rgb));
imshow(seg_img);
%%Feature Extraction
% Convert to grayscale if image is RGB
img = rgb2gray(seg_img);
% Create the Gray Level Cooccurance Matrices (GLCMs)
glcms = graycomatrix(img);
%Evaluate 10 features from the disease affected region only
% 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)
Kurtosis = kurtosis(double(seg_img(:)));
Skewness = skewness(double(seg_img(:)));
% Put the 10 features in an array
feat_disease = [Contrast,Correlation,Energy,Homogeneity, Mean, Standard_Deviation, Entropy, RMS, Kurtosis, Skewness];
Someone can tell me my code is true or false?
5 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!