def test_richardson_lucy_filtered(): test_img_astro = rgb2gray(astronaut()) psf = np.ones((5, 5)) / 25 data = convolve2d(test_img_astro, psf, 'same') deconvolved = restoration.richardson_lucy(data, psf, 5, filter_epsilon=1e-6) path = image_fetcher.fetch('restoration/tests/astronaut_rl.npy') np.testing.assert_allclose(deconvolved, np.load(path), rtol=1e-3, atol=1e-8)
def test_richardson_lucy_filtered(): from skimage.data import image_fetcher test_img_astro = rgb2gray(astronaut()) psf = cp.ones((5, 5)) / 25 data = cp.asarray(convolve2d(test_img_astro.get(), psf.get(), "same")) deconvolved = restoration.richardson_lucy(data, psf, 5, filter_epsilon=1e-6) path = image_fetcher.fetch("restoration/tests/astronaut_rl.npy") cp.testing.assert_allclose(deconvolved, np.load(path), rtol=1e-3, atol=1e-6)
def test_richardson_lucy_filtered(dtype_image, dtype_psf): if dtype_image == np.float64: atol = 1e-8 else: atol = 1e-5 test_img_astro = rgb2gray(astronaut()) psf = np.ones((5, 5), dtype=dtype_psf) / 25 data = convolve2d(test_img_astro, psf, 'same') data = data.astype(dtype_image, copy=False) deconvolved = restoration.richardson_lucy(data, psf, 5, filter_epsilon=1e-6) assert deconvolved.dtype == data.dtype path = image_fetcher.fetch('restoration/tests/astronaut_rl.npy') np.testing.assert_allclose(deconvolved, np.load(path), rtol=1e-3, atol=atol)
def single_tiff(): return [image_fetcher.fetch('data/multipage.tif')]
def irregular_images(): return [image_fetcher.fetch(f'data/{n}.png') for n in ('camera', 'coins')]
def single_png(): return [image_fetcher.fetch('data/camera.png')]
def rgb_png(): return [image_fetcher.fetch('data/astronaut.png')]
def two_pngs(): return [image_fetcher.fetch(f'data/{n}.png') for n in ('moon', 'camera')]
import matplotlib.pyplot as plt import matplotlib.patches as patches from matplotlib import cm, colors from mpl_toolkits.mplot3d import Axes3D import numpy as np from skimage import exposure import imageio as io # Prepare data and apply histogram equalization # Try using skimage.data.image_fetcher for cached data loading, # otherwise fall back to reading the data from url from skimage.data import image_fetcher try: path = image_fetcher.fetch('data/cells.tif') im_orig = io.volread(path) except: im_orig = io.volread('https://github.com/scikit-image/' 'skimage-tutorials/blob/master/' 'images/cells.tif?raw=True') # Reorder axis order from (z, y, x) to (x, y, z) im_orig = im_orig.transpose() # Rescale image data to range [0, 1] im_orig = np.clip(im_orig, np.percentile(im_orig, 5), np.percentile(im_orig, 95)) im_orig = (im_orig - im_orig.min()) / (im_orig.max() - im_orig.min()) # Degrade image by applying exponential intensity decay along x
(2006) "A lentiviral RNAi library for human and mouse genes applied to an arrayed viral high-content screen" Cell, 124(6):1283-98. PMID: 16564017 :DOI:`10.1016/j.cell.2006.01.040` """ import matplotlib.pyplot as plt import numpy as np from scipy import ndimage as ndi from skimage import (color, feature, filters, io, measure, morphology, segmentation, util) from skimage.data import image_fetcher path = image_fetcher.fetch('data/mitosis.tif') image = io.imread(path) fig, ax = plt.subplots() ax.imshow(image, cmap='gray') ax.set_title('Microscopy image of human cells stained for nuclear DNA') plt.show() ##################################################################### # We can see many cell nuclei on a dark background. Most of them are smooth # and have an elliptical shape. However, we can distinguish some brighter # spots corresponding to nuclei undergoing # `mitosis <https://en.wikipedia.org/wiki/Mitosis>`_ (cell division). ##################################################################### # Another way of visualizing a greyscale image is contour plotting: