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")
I finally found Color Model Conversion under the Image Analysis window in ArcMap (10.2.2). Highlight your image name at top of window ->Processing->fx->Right click on Identity Function -> Insert->choose Color Model Conversion from list.
However it would not run on my 4 band Tiff. I don't know if this is because it is 4 bands (no option is given to select which bands to use for the color model) or because of its format. No useful error message, it just says the inputs are inappropriate.