problem in image segmentatiion by using FCM
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Image Analyst
2016 年 7 月 23 日
編集済み: Image Analyst
2016 年 7 月 23 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Clustering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!