Visit the wiki pages to find some additional documentation and instructions on how view an interactive verson of these notebooks using binder.

In [1]:
%matplotlib inline
In [2]:
import math
import numpy as np
import matplotlib.pyplot as plt

from skimage import filters
from skimage import io

Read a 16 bit tiff image

In [4]:
image = io.imread("../images/neuron-dsRed-roi.tif")

Display the image

Convert the SimpleITK image to a numpy array and display it.

In [7]:
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.

In [8]:
plt.hist(image)
plt.show()
nda = np.array(image)
print (np.amax(nda))
10220

Transform the image

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.

In [9]:
nda_new = 10.0/4.0 * nda 

nda_trans = np.clip(nda_new, 0, 10000)
In [10]:
fig, ax = plt.subplots(figsize=(8, 8))
plt.imshow(nda_trans, cmap='gray')
plt.show()
In [11]:
plt.hist(nda_trans)
plt.show()
print (np.amax(nda))
10220
In [ ]: