Created
November 26, 2012 04:24
-
-
Save stefanv/4146612 to your computer and use it in GitHub Desktop.
Reverse colormap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from skimage import io as sio | |
import skimage | |
import numpy as np | |
import matplotlib | |
import matplotlib.pyplot as plt | |
img = skimage.img_as_float(sio.imread('im2.tif')) | |
jet = plt.cm.jet | |
jet._init() | |
lut = jet._lut[..., :3] | |
z = img - lut[:, None, None, :] | |
z *= z | |
d = z.sum(axis=-1) | |
out = d.argmin(axis=0) | |
f, (ax0, ax1, ax2) = plt.subplots(1, 3) | |
ax0.imshow(img, cmap=plt.cm.gray) | |
ax1.imshow(out, cmap=plt.cm.gray) | |
ax2.imshow(out, cmap=plt.cm.jet) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment