cytometer/utils.py
def transform_im(im, transform_skimage, output_shape=None, order=1):
    """
    Apply a scikit.image transformation to an image.

    The motivation for this function is that keras apply_transform() doesn't enable nearest neighbour
    interpolation. Thus, when applied to label or segmentation images, its bi-linear interpolation
    creates bogus labels.

    :param im: (row, col, channel) or (row, col)-np.array image.
    :param transform_skimage: skimage transform, e.g. created with keras2skimage_transform()
    :param output_shape: (def None) (height, width) tuple with the size of the output image. By default,
    the shape of the input image is preserved.
    :param order: (def 1) interpolation order. 0: nearest neighbour, 1: bi-linear, 2: bi-quadratic, ..., 5: bi-quintic.
    :return:
    * im_out: np.array with the same shape and dtype as im.
    """

    # apply transformation to image
    im_out = warp(im, transform_skimage.inverse, order=order, preserve_range=True, output_shape=output_shape)

    # correct output type
    im_out = im_out.astype(im.dtype)

    return im_out

    Apply a scikit.image transformation to an image.

    The motivation for this function is that keras apply_transform() doesn't enable nearest neighbour
    interpolation. Thus, when applied to label or segmentation images, its bi-linear interpolation
    creates bogus labels.

    :param im: (row, col, channel) or (row, col)-np.array image.
    :param transform_skimage: skimage transform, e.g. created with keras2skimage_transform()
    :param output_shape: (def None) (height, width) tuple with the size of the output image. By default,
    the shape of the input image is preserved.
    :param order: (def 1) interpolation order. 0: nearest neighbour, 1: bi-linear, 2: bi-quadratic, ..., 5: bi-quintic.
    :return:
    * im_out: np.array with the same shape and dtype as im.
    
Apply a scikit.image transformation to an image.
The motivation for this function is that keras apply_transform() doesn't enable nearest neighbour
interpolation. Thus, when applied to label or segmentation images, its bi-linear interpolation
creates bogus labels.
Apply a scikit . image transformation to an image . The motivation for this function is that keras apply_transform () doesn ' t enable nearest neighbour interpolation . Thus when applied to label or segmentation images its bi - linear interpolation creates bogus labels .
def transform_im(im, transform_skimage, output_shape=None, order=1):
    im_out = warp(im, transform_skimage.inverse, order=order, preserve_range=True, output_shape=output_shape)
    im_out = im_out.astype(im.dtype)
    return im_out
def transform_im ( im , transform_skimage , output_shape = None , order = 1 ) : im_out = warp ( im , transform_skimage . inverse , order = order , preserve_range = True , output_shape = output_shape ) im_out = im_out . astype ( im . dtype ) return im_out
Apply a scikit.image transformation to an image.
Apply a scikit . image transformation to an image .
"""
    Apply a scikit.image transformation to an image.

    The motivation for this function is that keras apply_transform() doesn't enable nearest neighbour
    interpolation. Thus, when applied to label or segmentation images, its bi-linear interpolation
    creates bogus labels.

    :param im: (row, col, channel) or (row, col)-np.array image.
    :param transform_skimage: skimage transform, e.g. created with keras2skimage_transform()
    :param output_shape: (def None) (height, width) tuple with the size of the output image. By default,
    the shape of the input image is preserved.
    :param order: (def 1) interpolation order. 0: nearest neighbour, 1: bi-linear, 2: bi-quadratic, ..., 5: bi-quintic.
    :return:
    * im_out: np.array with the same shape and dtype as im.
    """ # apply transformation to image # correct output type
np.array with the same shape and dtype as im.
np . array with the same shape and dtype as im .
im
(row, col, channel) or (row, col)-np.array image.
( row col channel ) or ( row col ) - np . array image .
transform_skimage
skimage transform, e.g. created with keras2skimage_transform()
skimage transform e . g . created with keras2skimage_transform ()
output_shape
(def None) (height, width) tuple with the size of the output image. By default,
the shape of the input image is preserved.
( def None ) ( height width ) tuple with the size of the output image . By default the shape of the input image is preserved .
order
(def 1) interpolation order. 0: nearest neighbour, 1: bi-linear, 2: bi-quadratic, ..., 5: bi-quintic.
( def 1 ) interpolation order . 0 : nearest neighbour 1 : bi - linear 2 : bi - quadratic ... 5 : bi - quintic .