This function creates an ENVIRaster to which NNDiffuse pan sharpening has been applied. It is the pan sharpened result of (LowResRaster and HighResRaster).

NNDiffuse pan sharpening works best when the spectral response function of each multispectral band has minimal overlap with one another, and the combination of all multispectral bands covers the spectral range of the panchromatic raster.

The following are input raster requirements for running the NNDiffuse pan sharpening algorithm:

  • The pixel size of the low-resolution raster must be an integral multiple of the pixel size of the high-resolution raster. If it is not, then pre-process (resample) the rasters.
  • When the rasters have projection information, it must be in the same projection. If it is not the same, then reproject the rasters.
  • The rasters must be aligned. If the rasters have misalignment, then register the rasters.
  • Ensure that the rasters line up, particularly in the upper-left corner (see the following diagram). When alignment is as little as 1/2 pixel off between the two, pan sharpening accuracy will be affected. If both input rasters have map information, they will be automatically subsetted so that they line up. If the rasters do not line up and do not have map information, then use spatial subsetting.


Sun, W., B. Chen, and D.W. Messinger. "Nearest Neighbor Diffusion Based Pan Sharpening Algorithm for Spectral Images." Optical Engineering 53, no. 1 (2014).

The result is a virtual raster, which has some additional considerations with regard to methods and properties. See Virtual Rasters for more information, including how they differ from ENVITasks.

The equivalent task is NNDiffusePanSharpening.


The following code opens a low resolution multi-band raster and a high-resolution panchromatic raster and performs nearest neighbor diffusion (NNDiffuse) pan sharpening. It saves the output to a multi-band raster with higher resolution as ENVI format and displays the result.

; Start the application
e = ENVI()
; Open low-resolution raster and high-resolution raster input files
lowResFile = Filepath('qb_boulder_msi', Subdir=['data'], $
lowResRaster = e.OpenRaster(lowResFile )
highResFile = Filepath('qb_boulder_pan', Subdir=['data'], $
highResRaster = e.OpenRaster(highResFile)
; Create the NNDiffuse pan sharpening raster
nnDiffusePanSharpeningRaster = ENVINNDiffusePanSharpeningRaster(lowResRaster, highResRaster, $
; Save it as ENVI format
newFile = e.GetTemporaryFilename()
nnDiffusePanSharpeningRaster.Export, newFile, 'ENVI'
; Open the pan sharpened raster
nnDiffusePanSharpenedRaster = e.OpenRaster(newFile)
; Display the pan sharpened result
view = e.GetView()
layer = view.CreateLayer(nnDiffusePanSharpenedRaster)


Result = ENVINNDiffusePanSharpeningRaster(Low_Resolution_Raster, High_Resolution_Raster [, Keywords=value])

Return Value

This routine returns an ENVIRaster.



The low-resolution raster.


The high-resolution raster, which must be a single-band raster.


This virtual raster inherits methods and properties from ENVIRaster; however the following methods will override the ENVIRaster methods:



ENVINNDiffusePanSharpeningRaster is read-only, so the SetData, SetTile, and Save methods do not apply.


See ENVIRaster properties.


ENVINNDiffusePanSharpeningRaster inherits all properties from ENVIRaster. In addition, the following properties are unique to ENVINNDiffusePanSharpeningRaster.


Specify a string that identifies the raster.


A scalar number that defines the pixel size ratio of the low-resolution raster and the high-resolution raster. The NNDiffuse pan-sharpening algorithm requires that the pixel size ratio be an integer. If this property is not set, the value is determined from the metadata of the input rasters. For example, the pixel size of Ikonos low-resolution MSI data is 4 meters, and the pixel size of Ikonos high-resolution Pan data is 1 meter. The ratio is 4/1, so the value is 4.


A positive number that defines the spatial smoothness factor (σs) of the NNDiffuse pan sharpening algorithm. SPATIAL_SMOOTHNESS should be set to a value that will resemble a bicubic interpolation kernel. The default value is PIXEL_SIZE_RATIO x 0.62.


A positive number that defines the intensity smoothness factor (σ) of the NNDiffuse pan sharpening algorithm. A smaller INTENSITY_SMOOTHNESS value will restrict diffusion and produce sharper images, but will have more noise. For example, a smaller value is good for pan sharpened images that will be used for visualization. A larger INTENSITY_SMOOTHNESS value will produce smoother results with less noise, which is suggested for images that will be used for classification and segmentation purposes. A larger value is also suggested for panchromatic scenes with high contrast (they require less diffusion sensitivity), and with complex scenes (to reduce the possibility of noise). The default is to dynamically adjust to local similarity, as shown in the equation that follows. You can enter a value to override the default, for example, a value in the range 10 x √2 to 20.

where Nj is the difference factor of the nine neighbors given by the following equation:

where Ωj (x,y) defines the diffusion region for each of the nine neighboring super pixels, and (x,y) denotes the position of a pixel in the high-resolution coordinate.

Version History

ENVI 5.2


ENVI 5.3.1

Documented the dehydrated form of this virtual raster

ENVI 5.4

Added Dehydrate and Hydrate methods; added NAME keyword

API Version


See Also

ENVIRaster, NNDiffusePanSharpening Task