%matplotlib inline
import math
import numpy as np
import matplotlib.pyplot as plt
from skimage import filters
from skimage import io
image = io.imread("../images/neuron-dsRed-roi.tif")
Convert the SimpleITK image to a numpy array and display it.
fig, ax = plt.subplots(figsize=(8, 8))
plt.imshow(image, cmap='gray')
plt.show()
Calculate the image histogram to understand what is going on. You will need to wait a while unil the histogram is computed.
plt.hist(image)
plt.show()
nda = np.array(image)
print (np.amax(nda))
Transform the image such that
$$ [0, 4000] \rightarrow [0, 10000] $$A threshold is applied to set the values $h(x,y) > 10000$ to a constant value.
nda_new = 10.0/4.0 * nda
nda_trans = np.clip(nda_new, 0, 10000)
fig, ax = plt.subplots(figsize=(8, 8))
plt.imshow(nda_trans, cmap='gray')
plt.show()
plt.hist(nda_trans)
plt.show()
print (np.amax(nda))