forked from GERSL/Fmask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNDVI.m
36 lines (32 loc) · 773 Bytes
/
NDVI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function ndvi = NDVI( red,nir )
%NDVI Calculate Normalized Difference Vegetation Index (NDVI) using NIR and
% Red bands.
%
% Syntax
%
% ndvi = NDVI(red,nir)
%
% Description
%
% This function calculates Normalized Difference Vegetation Index (NDVI)
% using NIR and Red bands (as following equation). This range is between
% -1 and 1.
% NDVI=(NIR-Red)/(NIR+Red).
%
% Input arguments
%
% red Red band
% nir Near-infrared band
%
% Output arguments
%
% ndvi Normalized Difference Vegetation Index
%
%
% Author: Shi Qiu ([email protected])
% Date: 19. October, 2017
% calculate NDVI
ndvi=(nir-red)./(nir+red);
% fix unnormal pixels
ndvi((nir+red)==0)=0.01;
end