problem in image segmentatiion by using FCM
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,i want segmentation image by using FCM function. my code :
img = imread('wpeppers.jpg');
%convert to L*a*b
cform = makecform('srgb2lab');
lab_he = applycform(img,cform);
ab = double(lab_he(:,:,2:3));
nrows = size(ab,1);
nColors = 3;
% repeat the clustering 3 times to avoid local minima
[cluster_center,cluster_idx ] = fcm(ab,nColors);
pixel_labels = reshape(cluster_idx,nrows,ncols);
imshow(pixel_labels,[]), title('image labeled by cluster index');
please guide me about it. Error using reshape To RESHAPE the number of elements must not change.
0 Commenti
Risposte (1)
Image Analyst
il 23 Lug 2016
Modificato: Image Analyst
il 23 Lug 2016
The size of cluster_idx is not equal to nrows * ncols. Try this:
fprintf('Size of cluster_idx = %d elements.\n', numel(cluster_idx));
fprintf('Rows * columns = %d elements.\n', nrows * ncols);
What do you see?
The fact is ab is a 2D variable with nrows * ncols * 2 elements, because you extracted two color channels into it. I'm not sure how fcm handles a 3D two color image because I don't have that function, but you need to look into it. It might give an index for every element rather than every 2-color pixel.
Anyway, why don't you try the Classification Learner app on the Apps tab of the tool ribbon. Maybe FCM is not the best approach. Experiment around with the others like kmeans, SVM, etc.
0 Commenti
Vedere anche
Categorie
Scopri di più su Data Clustering in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!