Selecting pixels within a matrix
Afficher commentaires plus anciens
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 commentaire
philippa
le 12 Sep 2011
Réponses (1)
Fangjun Jiang
le 12 Sep 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;
Catégories
En savoir plus sur Denoising and Compression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!