Substituting particular matrix values
Mostrar comentarios más antiguos
I have four 512x512 matrices: X1a and X1b, X2a and X2b
I first want to find the coordinates in X1a and X2a where an element equals 255. For this I have been using:
[r,c,v] = find(X1a==255);
a= [r, c, v];
[r,c,v] = find(X2a==255);
b= [r, c, v];
c= [a; b];
Then I want to use ALL the coordinates that I have found (matrix c) to replace the elements in X1a AND X2a with the elements at the same coordinates from X1b and X2b respectively. However- I am unsure how to do this.
Any help would be most appreciated.
Respuestas (1)
Andrei Bobrov
el 22 de Abr. de 2014
Editada: Andrei Bobrov
el 22 de Abr. de 2014
t1 = X1a == 255;
X1a(t1) = X1b(t1);
t2 = X2a == 255;
X2a(t2) = X2b(t2);
or
Xa = cat(3,X1a,X2a);
Xb = cat(3,X1b,X2b);
t = Xa == 255;
Xa(t) = Xb(t);
X1a = Xa(:,:,1);
X2a = Xa(:,:,2);
1 comentario
Charlotte
el 22 de Abr. de 2014
Categorías
Más información sobre Gaussian Mixture Models en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!