附件是matlab附带的图像,cameraman.tif
但在应用[fuzzy c-means]
1之后
此外,算法的输出是u2
(像素的隶属度)。有关此数据,请参见matlab.mat。
我想要做的是从附加的图像中选择像素,其u2
值为equal to 1
.
关于如何做到这一点的任何想法matlab
?
谢谢。
附件是matlab附带的图像,cameraman.tif
但在应用[fuzzy c-means]
1之后
此外,算法的输出是u2
(像素的隶属度)。有关此数据,请参见matlab.mat。
我想要做的是从附加的图像中选择像素,其u2
值为equal to 1
.
关于如何做到这一点的任何想法matlab
?
谢谢。
获取适当像素的索引:
ind = find( u2 == 1 ); % return indices of all pixels with u2 eq to 1
自己获取像素
pixels = img( ind );
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