最小限の作業例:
% some sample rgb image
MyImage = imread('autumn.tif');
% display it
figure; imshow(MyImage)
% size of the image
sz = size(MyImage);
% reshape the image to column format (each color band into one column). I guess you
%also did this for the k-means. If not that's why you did get poor results.
ImageInColumnFormat = reshape(MyImage,[],sz(3));
% number of clusters you want
NumberOfClusters = 4;
% U shows how likely each pixel belongs to each cluster.
% double() is only necessary because the sample image is uint8 and fcm has trouble with that format. You may not have to do that.
[~,U] = fcm(double(ImageInColumnFormat),NumberOfClusters);
% Get for each pixel the most likely cluster
[~,Labels] = max(U,[],1);
% reshape it back into the image format
LabelsInImageFormat = reshape(Labels,sz(1),sz(2));
% show result
figure; imagesc(LabelsInImageFormat)
Moesinger〜私の質問はあなたにダムかもしれないが、なぜあなたが使用しています。ここで〜を使う目的は何ですか? matlabのドキュメントでは「[centers、U] = fcm(data、Nc)」と書かれています。また、私はエラーが発生しています。比較する2つの行列と2つの出力引数を持つMAX MAXを使用するとエラーが発生します。 血液の異常(ライン18) [〜、ラベル] = max(U、1); max()が1つの入力引数を受け付けるため、このエラーが発生していることがわかります。このエラーを解決して、最も可能性の高いクラスタを得る方法。 –
@sidraAleem '〜'は、未使用の変数の作成を避けるために、関数の特定の出力を無視します。この状況では、これは「U」のみに興味があり、クラスタセンターを必要としないために行われます。 https://ch.mathworks.com/help/matlab/matlab_prog/ignore-function-outputs.htmlを参照してください。「max()」エラーについて:私の間違いは、それを指摘している誤植です。一定。 –