Created
November 18, 2016 00:46
Star
You must be signed in to star a gist
This file contains 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.morphology import disk | |
from skimage.morphology import opening | |
from skimage.filters import threshold_otsu, threshold_adaptive | |
import matplotlib.pyplot as plt | |
##adaptive threasholding | |
##input data is 512*512 image. | |
thres = threshold_adaptive(data, 33, offset=-100) | |
op = opening(thres,disk(1)) | |
##data coloring | |
##change pixels where opened image has True to red | |
image = np.zeros((512,512,3),dtype=np.float32) | |
color = 1.*(data-1*np.amin(data))/(np.amax(data)-np.amin(data)) | |
image[:,:,0] = color | |
image[:,:,1] = 1.*np.logical_not(op)*color | |
image[:,:,2] = 1.*np.logical_not(op)*color | |
plt.figure(1) | |
plt.imshow(image) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment