34 Convert 3 arrays, image_r, image_g, and image_b into an 8-bit RGB image.
40 Image to map to green.
46 RGB (integer, 8-bits per channel) color image as an NxNx3 numpy array.
48 image_r = np.asarray(image_r)
49 image_g = np.asarray(image_g)
50 image_b = np.asarray(image_b)
52 if (image_r.shape != image_g.shape)
or (image_g.shape != image_b.shape):
53 msg =
"The image shapes must match. r: {}, g: {} b: {}"
54 raise ValueError(msg.format(image_r.shape, image_g.shape, image_b.shape))
101 Use the mapping to convert images image_r, image_g, and image_b to a triplet of uint8 images.
103 image_r = image_r - self.
minimum[0]
104 image_g = image_g - self.
minimum[1]
105 image_b = image_b - self.
minimum[2]
109 image_rgb = [image_r, image_g, image_b]
112 with np.errstate(invalid=
"ignore"):
117 r0, g0, b0 = image_rgb
120 with np.errstate(invalid=
"ignore", divide=
"ignore"):
121 for i, c
in enumerate(image_rgb):
126 np.where(r0 >= pixmax, c * pixmax / r0, c),
127 np.where(b0 >= pixmax, c * pixmax / b0, c),
131 np.where(g0 >= pixmax, c * pixmax / g0, c),
132 np.where(b0 >= pixmax, c * pixmax / b0, c),
135 c[c > pixmax] = pixmax