フィルターのクリア

how to copy the segmented image in to single variable?

2 ビュー (過去 30 日間)
Melaku Eneayehu
Melaku Eneayehu 2018 年 3 月 13 日
コメント済み: Image Analyst 2018 年 3 月 14 日
how to copy the segmented image in to single variable?
test=imread(fname);
imData=reshape(test,[],1);
imData=double(imData);
[IDX nn obj]=fcm(imData,4);

回答 (1 件)

Image Analyst
Image Analyst 2018 年 3 月 13 日
I don't have the Fuzzy Logic Toolbox, but if it gives you a vector, you can reshape it
[rows, columns, numberOfColorChannels] = size(test);
classifiedImage = reshape(IDX, rows, columns];
imshow(classifiedImage, []);
  4 件のコメント
Melaku Eneayehu
Melaku Eneayehu 2018 年 3 月 13 日
Images are gray scale and IDX is
Name Size Bytes Class Attributes
IDX 4x1 32 double
i also try mat2gray but it doesn't work
Image Analyst
Image Analyst 2018 年 3 月 14 日
You need to use nn. (This is why it's good to name variables sensibly.)
[centers,U,objFunc] = fcm(___)
U: Fuzzy partition matrix, returned as a matrix with Nc rows and Nd columns. Element U(i,j) indicates the degree of membership of the jth data point in the ith cluster. For a given data point, the sum of the membership values for all clusters is one.
So you need to scan U and find out what column the max value is in. That's what class it thinks that pixel is in. Something like (untested because I don't have that toolbox):
classifiedImage = zeros(rows, columns);
for k = 1 : length(U)
% For every pixel...
[~, col] = max(U(k, :));
outputImage(k) = col;
end
outputImage = reshape(outputImage, rows, columns);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFuzzy Logic Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by