def test_florinate(): plus_one = add(1) data = 0 for i in range(1, 101): data = plus_one(data) assert data == i worlder = concat('World') data = 'Hello' expected = 'Hello' for _ in range(100): data = worlder(data) expected = ' '.join([expected, 'World']) assert data == expected data = np.zeros((7, 7), dtype=np.uint8) selem = np.zeros((3, 3), dtype=np.uint8) data[3, 3] = 1 selem[0, 1] = 1 selem[1, :] = 1 selem[2, 1] = 1 dilation = florinate(binary_dilation)(selem=selem) erosion = florinate(binary_erosion)(selem=selem) result = dilation(data) assert np.all(result == binary_dilation(data, selem)) result2 = dilation(data) assert np.all(result2 == result) result_dil = dilation(result) assert np.all(result_dil == binary_dilation(result, selem)) result2_dil = dilation(result2) assert np.all(result2_dil == result_dil) result = erosion(result_dil) assert np.all(result == binary_erosion(result_dil, selem)) result2 = erosion(result2_dil) assert np.all(result2 == result) result = erosion(result) assert np.all(result == data) result2 = erosion(result2) assert np.all(result2 == result) assert np.all(result2 == data)
def __getattr__(self, key): if key in self.__dict__['submodules']: return self.__dict__['submodules'][key] else: try: target = importlib.import_module('.'.join( [self.inner_module.__name__, key])) except ImportError: target = getattr(self.inner_module, key) if inspect.ismodule(target): self.__dict__['submodules'][key] = ImportWrapper(target) return self.__dict__['submodules'][key] elif callable(target): return florinate(target) else: return self.__dict__[key]
binary_erosion Perform a binary morphological erosion on an image. binary_opening Perform a binary morphological opening on an image. remove_small_holes Fill in contiguous holes smaller than the specified size. remove_small_objects Remove contiguous objects smaller than the specified size. """ import skimage.morphology from florin.closure import florinate closing = florinate(skimage.morphology.closing) dilation = florinate(skimage.morphology.dilation) erosion = florinate(skimage.morphology.erosion) opening = florinate(skimage.morphology.opening) binary_closing = florinate(skimage.morphology.binary_closing) binary_dilation = florinate(skimage.morphology.binary_dilation) binary_erosion = florinate(skimage.morphology.binary_erosion) binary_opening = florinate(skimage.morphology.binary_opening)
self.bounds[key] = (-float('inf'), val) elif isinstance(val, str): self.bounds[key] = ('', val) else: self.bounds[key] = (min(val), max(val)) def classify(self, obj): """Determine if an object is in this class. Parameters ---------- obj : skimage.measure._regionprops.RegionProperties The object to classify. Returns ------- bool True if the object is within all defined boundaries else False. If no boundaries were provided, return True (e.g., the default class). """ if len(self.bounds) > 0: return all([ v[0] <= getattr(obj, k) <= v[1] for k, v in self.bounds.items() ]) else: return True classify = florinate(classify)
Parameters ---------- tiles : collection of FlorinArray The collection of tiles to join. shape : tuple of int The shape of the joined array. Returns ------- joined : array_like The array created by joining the tiles and inserting them into the correct positions. """ out = None for tile, metadata in tiles: if out is None: out = np.zeros(metadata['original_shape'], dtype=tile.dtype) start = np.asarray(metadata['origin']) end = start + np.asarray(tile.shape) slices = [slice(start[i], end[i]) for i in range(tile.ndim)] out[tuple(slices)] += tile return out.astype(tile.dtype) tile = florinate(tile_generator) join = florinate(join_tiles)
Performs Sigmoid Correction on the input image. adjust_log Determine if an image is low contrast. Notes ----- The functions defined here are wrappers for functions in the `skimage.exposure` module. Full documentation may be found in the `scikit-image documentation`_. .. _scikit-image documentation: https://scikit-image.org/docs/stable/api/skimage.exposure.html """ import skimage.exposure from florin.closure import florinate histogram = florinate(skimage.exposure.histogram) equalize_hist = florinate(skimage.exposure.equalize_hist) equalize_adapthist = florinate(skimage.exposure.equalize_adapthist) rescale_intensity = florinate(skimage.exposure.rescale_intensity) cumulative_distribution = florinate(skimage.exposure.cumulative_distribution) adjust_gamma = florinate(skimage.exposure.adjust_gamma) adjust_log = florinate(skimage.exposure.adjust_log) __all__ = ['histogram', 'equalize_hist', 'equalize_adapthist', 'rescale_intensity', 'cumulative_distribution', 'adjust_gamma', 'adjust_log']
Invert an image. Notes ----- The functions defined here are wrappers for functions in the `skimage.util` module. Full documentation may be found in the `scikit-image documentation`_. .. _scikit-image documentation: https://scikit-image.org/docs/stable/api/skimage.util.html """ import skimage.util from florin.closure import florinate img_as_float32 = florinate(skimage.util.img_as_float32) img_as_float64 = florinate(skimage.util.img_as_float64) img_as_float = florinate(skimage.util.img_as_float) img_as_int = florinate(skimage.util.img_as_int) img_as_uint = florinate(skimage.util.img_as_uint) img_as_ubyte = florinate(skimage.util.img_as_ubyte) img_as_bool = florinate(skimage.util.img_as_bool) view_as_blocks = florinate(skimage.util.view_as_blocks) pad = florinate(skimage.util.pad) crop = florinate(skimage.util.crop) random_noise = florinate(skimage.util.random_noise) regular_grid = florinate(skimage.util.regular_grid) regular_seeds = florinate(skimage.util.regular_seeds) invert = florinate(skimage.util.invert) __all__ = [
"""Convenience functions for image thresholding operations. Functions --------- ndnt Binarize data with N-Dimensional Neighborhood Thresholding. """ from florin.closure import florinate from florin.ndnt import ndnt ndnt = florinate(ndnt)