Why am I not getting the expected result?

2 visualizaciones (últimos 30 días)
med-sweng
med-sweng el 23 de Feb. de 2013
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.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 23 de Feb. de 2013
Editada: Azzi Abdelmalek el 23 de Feb. de 2013
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

Más respuestas (1)

Walter Roberson
Walter Roberson el 23 de Feb. de 2013

Categorías

Más información sobre Grid Lines, Tick Values, and Labels en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by