Why am I not getting the expected result?

1 次查看(过去 30 天)
I have the function listed at the bottom of this post which is supposed to return a matrix that has the same size of a matrix `x` with pixels that had a degree of membership `y`=1 to `1` and the other pixels to `0`.
But, when I ran the function I didn't get the expected results as follows (why is that?):
>> x = [1 4 3; 6 4 3; 6 9 3; 2 4 3; 5 4 0; 5 3 1; 6 4 7];
>> y = [0 0 1; 1 1 0; 1 1 0; 0 1 1; 0.2 0.8 0.54; 1 1 1; 0 0 0];
>> pixel_val(x,y)
ans =
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
1 1 1
0 0 0
function c = pixel_val(x, y)
[ii,jj]=find(y==1);
x(ii,jj)=1;
[ii2,jj2] = find (y~=1);
x(ii2,jj2)=0;
c = x;
end
Thanks.

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-2-23
编辑:Azzi Abdelmalek 2013-2-23
You don't need to create a function for this
x=zeros(size(y))
x(y==1)=1
and x is not used in your code

更多回答(1 个)

Walter Roberson
Walter Roberson 2013-2-23

类别

Help CenterFile Exchange 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by