This document is archived and information here might be outdated.  Recommended version.


How to pan sharpen an image (ArcObjects .NET 10.4 SDK)

How to pan sharpen an image


Summary
Pan sharpening is the process of fusing two image together, a multispectral image and a higher resolution panchromatic image, to achieve higher spatial resolution in the multispectral image. This topic shows how to achieve this utilizing a pan sharpening filter.

Pan sharpening an image

To pan sharpen an image, follow these steps:
  1. Create Raster objects from both multispectral and panchromatic raster datasets.
  2. Create a Raster object that contains only the near-infrared band (the fourth band used by the pan sharpening filter).
  3. Set the pan sharpened raster's properties.
  4. Create a pan sharpening filter and set its parameters.
  5. Set the filter to the multispectral raster (cast).
  6. Save as a pan sharpened image.
[C#]
public static void PanSharpening(IRasterDataset panDataset, IRasterDataset
    multiDataset)
{
    //panDataset—A raster dataset created from a single-band, higher-resolution image.
    //multiDataset—A raster dataset created from a multiband image. 
    //Assuming four bands: R,G,B, and NIR.
    //Create raster objects from pan/multi raster datasets.
    IRaster panRaster=((IRasterDataset2)panDataset).CreateFullRaster();
    IRaster multiRaster=((IRasterDataset2)multiDataset).CreateFullRaster();
    //Set infrared image.
    IRasterBandCollection rasterbandCol=(IRasterBandCollection)multiRaster;
    IRasterBandCollection infredRaster=new RasterClass();
    infredRaster.AppendBand(rasterbandCol.Item(3));

    //Set the pan sharpened raster's properties.
    IRasterProps panSharpenRasterProps=(IRasterProps)multiRaster;
    IRasterProps panRasterProps=(IRasterProps)panRaster;
    panSharpenRasterProps.Width=panRasterProps.Width;
    panSharpenRasterProps.Height=panRasterProps.Height;
    panSharpenRasterProps.Extent=panRasterProps.Extent;
    multiRaster.ResampleMethod=rstResamplingTypes.RSP_BilinearInterpolation;

    //Create the pan sharpening filter and set its parameters.
    IPansharpeningFilter pansharpenFilter=new PansharpeningFilterClass();
    pansharpenFilter.InfraredImage=(IRaster)infredRaster;
    pansharpenFilter.PanImage=(IRaster)panRaster;
    pansharpenFilter.PansharpeningType=esriPansharpeningType.esriPansharpeningESRI;
    pansharpenFilter.PutWeights(0.166, 0.167, 0.167, 0.5);

    //Set the pan sharpen filter to multispectral raster.
    IPixelOperation pixelOperation=(IPixelOperation)multiRaster;
    pixelOperation.PixelFilter=(IPixelFilter)pansharpenFilter;

    //Save the pan sharpened image.
    ISaveAs saveas=(ISaveAs)pixelOperation;
    saveas.SaveAs(@"c:\temp\pansharpentest.tif", null, "TIFF");
}
[VB.NET]
Public Shared Sub PanSharpening(panDataset As IRasterDataset, multiDataset As IRasterDataset)
'panDataset—A raster dataset created from a single-band, higher-resolution image.
'multiDataset—A raster dataset created from a multiband image.
'Assuming four bands: R,G,B, and NIR.
'Create raster objects from pan/multi raster datasets.
Dim panRaster As IRaster=CType(panDataset, IRasterDataset2).CreateFullRaster()
Dim multiRaster As IRaster=CType(multiDataset, IRasterDataset2).CreateFullRaster()

'Set infrared image.
Dim rasterbandCol As IRasterBandCollection=CType(multiRaster, IRasterBandCollection)
Dim infredRaster As IRasterBandCollection=New RasterClass()
infredRaster.AppendBand(rasterbandCol.Item(3))

'Set the pan sharpening raster's properties.
Dim panSharpenRasterProps As IRasterProps=CType(multiRaster, IRasterProps)
Dim panRasterProps As IRasterProps=CType(panRaster, IRasterProps)
panSharpenRasterProps.Width=panRasterProps.Width
panSharpenRasterProps.Height=panRasterProps.Height
panSharpenRasterProps.Extent=panRasterProps.Extent
multiRaster.ResampleMethod=rstResamplingTypes.RSP_BilinearInterpolation

'Create the pan sharpening filter and set its parameters.
Dim pansharpenFilter As IPansharpeningFilter=New PansharpeningFilterClass()
pansharpenFilter.InfraredImage=CType(infredRaster, IRaster)
pansharpenFilter.PanImage=CType(panRaster, IRaster)
pansharpenFilter.PansharpeningType=esriPansharpeningType.esriPansharpeningESRI
pansharpenFilter.PutWeights(0.166, 0.167, 0.167, 0.5)

'Set the pan sharpen filter to multispectral raster.
Dim pixelOperation As IPixelOperation=CType(multiRaster, IPixelOperation)
pixelOperation.PixelFilter=CType(pansharpenFilter, IPixelFilter)

'Save the pan sharpened image.
Dim saveas As ISaveAs=CType(pixelOperation, ISaveAs)
saveas.SaveAs("c:\temp\pansharpentest.tif", Nothing, "TIFF")
End Sub






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
Engine Developer Kit Engine