In the meantime I implemented a python script to do the color conversion manually, but it is very very slow. How can I make things more efficient? I won't have a chance to convert my final raster.
import arcpy
from arcpy import sa
import string
import numpy
import colorsys
arcpy.env.workspace = r"U:\path" # internal drive
inRast = r"U:\path\multiple_bands.tif"
outRast = r"U:\path\hsv"
Ymin = float(str(arcpy.GetRasterProperties_management(inRast, "BOTTOM")))
Xmin = float(str(arcpy.GetRasterProperties_management(inRast, "LEFT")))
Ymax = float(str(arcpy.GetRasterProperties_management(inRast, "TOP")))
rows = float(str(arcpy.GetRasterProperties_management(inRast, "ROWCOUNT")))
cols = float(str(arcpy.GetRasterProperties_management(inRast, "COLUMNCOUNT")))
# create numpy arrays
shape = rows, cols
hueArray = numpy.empty(shape)
satArray = numpy.empty(shape)
valArray = numpy.empty(shape)
x = 0
while x < cols:
y = 0
while y < rows:
#Get the Cell values of the three bands
values = arcpy.GetCellValue_management(inRast, str(Xmin + 5 + 10*x) + " " + str(Ymax - 5 - 10*y), "1;2;3")
# save values in list
slist = string.split(str(values), "\\", 3)
b = float(slist[0])/255 # 1. Band Green equals blue in RGB
nlist = string.split(slist[1], "n", 2)
g = float(nlist[1])/255 # 2. Band Red equals green in RGB
nnlist = string.split(slist[2], "n", 2)
r = float(nnlist[1])/255 # 3. Band NIR equals red in RGB
# convert ot HSV
result = colorsys.rgb_to_hsv(r, g, b)
hueArray[y,x] = result[0]*360
satArray[y,x] = result[1]*100
valArray[y,x] = result[2]*100
y = y + 1
x = x + 1
xymin = arcpy.Point(Xmin, Ymin)
hueRast = arcpy.NumPyArrayToRaster(hueArray, xymin, 10, 10)
satRast = arcpy.NumPyArrayToRaster(satArray, xymin, 10, 10)
valRast = arcpy.NumPyArrayToRaster(valArray, xymin, 10, 10)
satRast.save(outRast+"_sat.tif")
valRast.save(outRast+"_val.tif")
hueRast.save(outRast+"_hue.tif")
... View more