0

附件是matlab附带的图像,cameraman.tif但在应用[fuzzy c-means] 1之后

在此处输入图像描述

此外,算法的输出是u2(像素的隶属度)。有关此数据,请参见matlab.mat

我想要做的是从附加的图像中选择像素,其u2值为equal to 1.

关于如何做到这一点的任何想法matlab

谢谢。

4

2 回答 2

3

获取适当像素的索引:

ind = find( u2 == 1 ); % return indices of all pixels with u2 eq to 1

自己获取像素

pixels = img( ind );
于 2013-02-20T13:13:17.660 回答
2

Alternatively, you can avoid using find and go straight into logical indexing.

Given an image as:

>> image = [1 3 5; 2 3 1; 3 2 2]

image =

     1     3     5
     2     3     1
     3     2     2

you can find the pixels with value 2 using the condition iamge == 2:

K>> image == 2

ans =

     0     0     0
     1     0     0
     0     1     1

If for instance you want to manipulate these pixels by setting them to 7 you can easily do that with a single line:

image(image == 2) = 7

image =

     1     3     5
     7     3     1
     3     7     7
于 2013-02-20T14:24:35.797 回答