# Visualize # First setup a 5-4-3 composite def color_stretch(image, index, minmax=(0, 10000)): colors = image[:, :, index].astype(np.float64) max_val = minmax[1] min_val = minmax[0] # Enforce maximum and minimum values colors[colors[:, :, :] > max_val] = max_val colors[colors[:, :, :] < min_val] = min_val for b in range(colors.shape[2]): colors[:, :, b] = colors[:, :, b] * 1 / (max_val - min_val) return colors img543 = color_stretch(img, [4, 3, 2], (0, 8000)) # See https://github.com/matplotlib/matplotlib/issues/844/ n = class_prediction.max() # Next setup a colormap for our map colors = dict(( (0, (0, 0, 0, 255)), # Nodata (1, (0, 150, 0, 255)), # Forest (2, (0, 0, 255, 255)), # Water (3, (0, 255, 0, 255)), # Herbaceous (4, (160, 82, 45, 255)), # Barren (5, (255, 0, 0, 255)) # Urban )) # Put 0 - 255 as float 0 - 1 for k in colors: v = colors[k] _v = [_v / 255.0 for _v in v] colors[k] = _v index_colors = [colors[key] if key in colors else (255, 255, 255, 0) for key in range(1, n + 1)] cmap = plt.matplotlib.colors.ListedColormap(index_colors, 'Classification', n) # Now show the classmap next to the image plt.subplot(121) plt.imshow(img543) plt.subplot(122) plt.imshow(class_prediction, cmap=cmap, interpolation='none') plt.show()
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4