Skip to main content

SpectralConversion

サマリー

Applies a matrix to a multiband image to affect the color values of the output.

ディスカッション

For more information about how this function works, see the Spectral Conversion raster function.

The referenced raster dataset for the raster object is temporary. To make it permanent, you can call the raster object's save method.

構文

SpectralConversion(raster, conversion_matrix)

パラメーター 説明 データ タイプ

raster

The input raster.

This can be a raster dataset within a mosaic dataset or raster catalog, or a raster dataset outside the mosaic dataset.

Raster

conversion_matrix

The matrix used to convert the input raster.

The equation used to perform this conversion is as follows:

\(Output \space Band_R \space = \space Weight_P \space * \space Band_C\)

where:

  • Band_R is an output band, where R is a number from 1 to the number of output bands.

  • Weight_P is a comma-delimited list of weights, 1 for each input band. The sum of the weights for each band should equal 1.

  • Band_C is the input image, where C is a number from 1 to the number of bands of the input image.

Raster

戻り値

データ タイプ 説明

Raster

The output raster.

コードのサンプル

SpectralConversion example 1

This example is applying a matrix to a multiband image to change the color values of the output.

from arcpy.ia import *
out_raster = SpectralConversion("3bands_raster",
                                [0.1, 0.9, 0, 0.3, 0, 0.7, 0.1, 0.1, 0.8])
out_raster.save("C:/arcpyExamples/outputs/out_spectralconversion_raster.tif")
SpectralConversion example 2

This example is applying a matrix to a multiband image to change the color values of the output.

# Import system modules
import arcpy
from arcpy.ia import *

# Set the analysis environments
arcpy.env.workspace = "C:/arcpyExamples/data"

# Set the local variables
in_raster = "3bands_raster"
in_conversion_matrix =  [0.1, 0.9, 0, 0.3, 0, 0.7, 0.1, 0.1, 0.8]

# Run SpectralConversion function
out_raster = SpectralConversion(in_raster, in_conversion_matrix)
#Output band 1 = (0.1 * InputBand1) + (0.9 * InputBand2) +(0 * InputBand3)
#Output band 2 = (0.3 * InputBand1) + (0 * InputBand2) +(0.7 * InputBand3)
#Output band 3 = (0.1 * InputBand1) + (0.1 * InputBand2) +(0.8 * InputBand3)

# Save output
out_raster.save("C:/arcpyExamples/outputs/out_spectralconversion_raster.tif")