Effacer les filtres
Effacer les filtres

How to mask pixels of certain ndvi values?

38 vues (au cours des 30 derniers jours)
Devendra
Devendra le 14 Avr 2024 à 22:52
Commenté : Devendra le 15 Avr 2024 à 13:26
I am using following matlab code to divide the parcels into cropland and non cropland
if mean(parcel_ndvi(idx == 1)) > mean(parcel_ndvi(idx == 2))
cropland = 1;
noncropland = 2;
else
cropland = 2;
noncropland = 1;
end
mask = idx == cropland;
now I want to mask only those pixels within cropland whose ndvi values are greater than 0.4. I request you to please suggest me how to create the said mask. I would appreciate your kind help.
Devendra

Réponse acceptée

DGM
DGM le 15 Avr 2024 à 4:36
Here's my guess.
% idx is apparently some sort of label array where the labels are unknown
% so this simply figures out which label corresponds to which class
if mean(parcel_ndvi(idx == 1)) > mean(parcel_ndvi(idx == 2))
croplandidx = 1;
noncroplandidx = 2;
else
croplandidx = 2;
noncroplandidx = 1;
end
% a logical mask of cropland
cropmask = idx == croplandidx;
% a logical mask of cropland with NDVI > 0.4
hi_ndvi_cropmask = cropmask & (parcel_ndvi > 0.4);
  1 commentaire
Devendra
Devendra le 15 Avr 2024 à 13:26
Thanks a lot for your kind help. I appreciate your kind cooperation and support.
Deva

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by