Selecting pixels within a matrix
Mostrar comentarios más antiguos
Suppose I have a matrix of land heights which range from 0-5000m.
How can i create a new matrix of the same size, that keeps only the values between 300-400, and sets all the rest to 0.
eg. Orignial matrix (completely hypothetical) = [0 100 300 800 5000; 200 400 600 1000 2000; 400 3000 4000 4000 5000; etc etc] New Matrix = [0 0 300 0 0; 0 400 0 0 0;400 0 0 0 0; etc ]
So far i have this: [m,n] = size(Land) for i = 1:m for j = 1:n if 300<Land(i,j)<400 matrix(i,j) = Land(i,j) else matrix(i,j) = 0 end end end
However this isnt even close to being right! Please help!Thank you!
1 comentario
philippa
el 12 de Sept. de 2011
Respuestas (1)
Fangjun Jiang
el 12 de Sept. de 2011
A=[0 100 300 800 5000; 200 400 600 1000 2000; 400 3000 4000 4000 5000]
A(A<=300)=0;
A(A>=400)=0;
Categorías
Más información sobre Denoising and Compression 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!