ColorspaceConversion

Zusammenfassung

Converts the color model of a three-band unsigned 8-bit image from either the hue, saturation, and value (HSV) to red, green, and blue (RGB) or vice versa.

Diskussion

For more information about how this function works, see the Color Model 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.

Syntax

ColorspaceConversion (raster, {conversion_type})
ParameterErläuterungDatentyp
raster

An unsigned 8-bit pixel type input raster.

Raster
conversion_type

The color conversion type to perform.

  • rgb_to_hsvRGB to HSV
  • hsv_to_rgbHSV to RGB

(Der Standardwert ist rgb_to_hsv)

String
Rückgabewert
DatentypErläuterung
Raster

The output raster.

Codebeispiel

ColorspaceConversion example 1

This example applies the Colorspace Conversion function to the input raster.

from arcpy.ia import *
out_hsv_3bands = ColorspaceConversion("slope_rgb_3bands.tif", "rgb_to_hsv")
out_hsv_3bands.save("C:/arcpyExamples/outputs/slope_hsv_3bands.tif")
ColorspaceConversion example 2

This example applies the Colorspace Conversion function to the input raster.

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

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

# Set the local variables
# the pixeltype of the input raster must be unsigned 8-bit, otherwise,
# the function would fail
in_raster = "slope_rgb_3bands.tif"

# Execute ColorspaceConversion function
slope_hsv_3bands = ColorspaceConversion(in_raster, "rgb_to_hsv")

# Save the output
slope_hsv_3bands.save("C:/arcpyExamples/outputs/slope_hsv_3bands.tif")