NDVI Image Processing Using Python:
Normalized Difference Vegetation Index (NDVI)
To determine the density of green on a patch of land, researchers must observe the distinct colors (wavelengths) of visible and near-infrared sunlight reflected by the plants. As can be seen through a prism, many different wavelengths make up the spectrum of sunlight. When sunlight strikes objects, certain wavelengths of this spectrum are absorbed and other wavelengths are reflected. The pigment in plant leaves, chlorophyll, strongly absorbs visible light (from 0.4 to 0.7 µm) for use in photosynthesis. The cell structure of the leaves, on the other hand, strongly reflects near-infrared light (from 0.7 to 1.1 µm). The more leaves a plant has, the more these wavelengths of light are affected, respectively.
By taking the ratio of red and near infrared bands from a remotely-sensed image, an index of vegetation “greenness” can be defined. The Normalized Difference Vegetation Index (NDVI) is probably the most common of these ratio indices for vegetation. NDVI is calculated on a per-pixel basis as the normalized difference between the red and near infrared bands from an image:
Many factors affect NDVI values like plant photosynthetic activity, total plant cover, biomass, plant and soil moisture, and plant stress. Because of this, NDVI is correlated with many ecosystem attributes that are of interest to researchers and managers (e.g., net primary productivity, canopy cover, bare ground cover). Also, because it is a ratio of two bands, NDVI helps compensate for differences both in illumination within an image due to slope and aspect, and differences between images due things like time of day or season when the images were acquired. Thus, vegetation indices like NDVI make it possible to compare images over time to look for ecologically significant changes.
The output of NDVI is a new image file/layer. Values of NDVI can range from -1.0 to +1.0, but values less than zero typically do not have any ecological meaning, so the range of the index is truncated to 0.0 to +1.0. Higher values signify a larger difference between the red and near infrared radiation recorded by the sensor – a condition associated with highly photosynthetically-active vegetation. Low NDVI values mean there is little difference between the red and NIR signals. This happens when there is little photosynthetic activity, or when there is just very little NIR light reflectance (i.e., water reflects very little NIR light).
Programming in Python [Convert IR to NDVI]:
At first we need some Libraries to call in the script:-
To know about matplotlib, LinearSegment
Color Bar to indicate color bandwidth in the output:
A function performs the NDVI calculation and returns an GrayScaled frame with mapped colors)
This script use NGB (Nir, Green, Blue) i.e; NOIR image and if you wish to run this script in virtual env then follow below steps:-
Install requirement.txt file which contains instruction libraries with specific version
Script Usage of NDVI.py
-i, input image
>>> python NDVI.py -i image.jpg -o test.jpg
Full source code can be downloaded for here.