sir ,i'm doing my project on leaf disease detection and classification using svm.so i have a set of 1500 images.The first step was the background elimination using freehand and L*a*b color conversion.I completed that two process.Next step was segmentation and rule formation.The background eliminated resized RGB image is converted into L*a*b first,then the segmentation module is executed on 'a*b' channel.A well known k-means clustering algorithm is utilised to separate infected and healthy leaf regions. The iterative k-means reassign each pixel to nearest cluster so as to decrease the sum distances and recalculate cluster centroids.here i am using euclidean distance measurement.This process results in an input image partitioned into three regions,each containing different portions of a leaf image sample .Index values corresponding to the three clusters are used to label image pixels in the original image.Grey level values of the resultant three colour clusters are then utilised for further processing.
I 'm just tried to code the segmentation part.but i am not sure is it correct or not. And also i want the entire background of cluster1 is white and background of cluster2 and cluster3 are black.but i didn't get it.can you please help me to solve these problems.
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
img=read(ds); %read image from datastore
labImage = rgb2lab(scale);
ab = labImage(:,:,2:3);
ab = im2single(ab);
nColors = 3; %repeat the clustering 3 times to avoid local minima
pixel_labels = imsegkmeans(ab,nColors,'NumAttempts',3);
%title('Image labeled by cluster Index');
mask1 = pixel_labels==1;
cluster1 = scale .* uint8(mask1);
title('objects in cluster1');
mask2 = pixel_labels==2;
cluster2 = scale .* uint8(mask2);
title('objects in cluster2');
mask3 = pixel_labels==3;
cluster3 = scale .* uint8(mask3);
title('objects in cluster3');
please help me to correct the code .