def setup(self): self.image = np.random.random((200, 200, 100)) self.image[:100, :100, :] += 1 self.image[150:, 150:, :] += 0.5 self.msk = np.zeros((200, 200, 100)) self.msk[10:-10, 10:-10, 10:-10] = 1 self.msk_slice = self.msk[..., 50] if Version(skimage.__version__) >= Version('0.17.0'): self.slic_kwargs = dict(start_label=1) else: self.slic_kwargs = {}
def setup(self, *args): try: # use a separate skeletonize_3d function on older scikit-image if Version(skimage.__version__) < Version('0.16.0'): self.skeletonize = morphology.skeletonize_3d else: self.skeletonize = morphology.skeletonize except AttributeError: raise NotImplementedError("3d skeletonize unavailable") # we stack the horse data 5 times to get an example volume self.image = np.stack(5 * [util.invert(data.horse())])
def setup(self): try: mask = np.zeros((64, 64)) > 0 mask[10:-10, 10:-10] = 1 segmentation.slic(np.ones_like(mask), mask=mask) except TypeError: raise NotImplementedError("masked slic unavailable") self.image = np.random.random((200, 200, 100)) self.image[:100, :100, :] += 1 self.image[150:, 150:, :] += 0.5 self.msk = np.zeros((200, 200, 100)) self.msk[10:-10, 10:-10, 10:-10] = 1 self.msk_slice = self.msk[..., 50] if Version(skimage.__version__) >= Version('0.17.0'): self.slic_kwargs = dict(start_label=1) else: self.slic_kwargs = {}
from functools import partial from multiprocessing import Pool import numpy as np from numpy.lib import NumpyVersion as Version import scipy if Version(scipy.__version__) >= Version('1.4.0'): import scipy.fft _fft = scipy.fft else: import scipy.fftpack _fft = scipy.fftpack def _image_tv(x, axis=0, n_points=3): """ Computes total variation (TV) of matrix x across a given axis and along two directions. Parameters ---------- x : 2D ndarray matrix x axis : int (0 or 1) Axis which TV will be calculated. Default a is set to 0. n_points : int Number of points to be included in TV calculation. Returns
] _scipy_150 = False try: import scipy import scipy.fft as _scipy_fft except ImportError: class _DummyModule: def __getattr__(self, name): return None _scipy_fft = _DummyModule() else: from numpy.lib import NumpyVersion as Version _scipy_150 = Version(scipy.__version__) >= Version('1.5.0') del Version del scipy # Backend support for scipy.fft __ua_domain__ = 'numpy.scipy.fft' _implemented = {} def __ua_convert__(dispatchables, coerce): if coerce: try: replaced = [ cupy.asarray(d.value) if d.coercible and d.type is np.ndarray else d.value