18368aa9
David Mayerich
added a new set o...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 23 16:04:33 2017
@author: david
"""
import numpy
import colorsys
#generate a 2D color class map using a stack of binary class images
def classcolor2(C):
#determine the number of classes
nc = C.shape[-1]
#generate an RGB image
RGB = numpy.zeros((C.shape[0], C.shape[1], 3), dtype=numpy.ubyte)
#for each class
for c in range(0, nc):
hsv = (c * 1.0 / nc, 1, 1)
color = numpy.asarray(colorsys.hsv_to_rgb(hsv[0], hsv[1], hsv[2])) * 255
RGB[C[:, :, c], :] = color
return RGB
|