how to calculate the disease severity in percentage.
2 views (last 30 days)
Show older comments
The severity of a disease depends upon the region being covered by an infection.After identifying the test leaf image sample,percentation of a leaf infection can easily be computed as a ratio of the number of infected pixels is to the number of healthy pixels in the leaf image.
A=(sum of Ai/ AL)*100
Ai is the number of infected image pixels in cluster i(i=1,2,3) and AL represent the total number of pixels lying in the extracted ROI of a leaf image.
upto segmentation code is:
fontSize=10;
location='C:\Users\Keerthi Dev\Desktop\50datasample\original';%folder in which your images exists
ds=imageDatastore(location); %create datastore for all images in your folder
new_folder='C:\Users\Keerthi Dev\Desktop\50datasample\after_resized'; %new folder
k=1;
while hasdata(ds)
img=read(ds); %read image from datastore
scale=imresize(img,[256 256]);
fileName=sprintf('image_%d.jpg',k);
fullFileName=fullfile(new_folder,fileName);
imwrite(scale,fullFileName);
%size(scale)
k=k+1;
%lab conversion
labImage = rgb2lab(scale);
ab = labImage(:,:,2:3);
ab = im2single(ab);
%segmentation
nColors = 3; %repeat the clustering 3 times to avoid local minima
pixel_labels = imsegkmeans(ab,nColors,'NumAttempts',3);
%imshow(pixel_labels,[])
%title('Image labeled by cluster Index');
figure;
subplot(1,4,1)
imshow(scale);
title('leaf image');
mask1 = pixel_labels==1;
cluster1 = scale .* uint8(mask1);
subplot(1,4,2);
imshow(cluster1);
title('objects in cluster1');
mask2 = pixel_labels==2;
cluster2 = scale .* uint8(mask2);
subplot(1,4,3);
imshow(cluster2);
title('objects in cluster2');
mask3 = pixel_labels==3;
cluster3 = scale .* uint8(mask3);
subplot(1,4,4);
imshow(cluster3);
title('objects in cluster3');
end
how to calculate the disease severity?
2 Comments
Harsh Parikh
on 5 Oct 2020
Hi,
I believe the three cluster variables are 'cluster1', 'cluster2' and 'cluster3'.
Depending on the criteria for a pixel to be considered as 'infected' you can use the following piece of code: (I have, as an example, taken the pixel intensity <10, to be considered as an infected pixel.)
cluster1_infected = length(nonzeros(cluster1<10));
cluster2_infected = length(nonzeros(cluster2<10));
cluster3_infected = length(nonzeros(cluster3<10));
disease_severity = ((cluster1_infected+cluster2_infected+cluster3_infected)/(numel(cluster1)+numel(cluster2)+numel(cluster3)))*100
You can change the equations of clusterX_infected according to your need.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!