imctoolkit.utils

hot_pixel_filter(img, hot_pixel_thres, inplace=False)

Hot pixel filter as implemented in https://github.com/BodenmillerGroup/ImcPluginsCP

Sets all hot pixels to the maximum of their 8-neighborhood. Hot pixels are defined as pixels, whose values are larger by hot_pixel_thres than the maximum of their 8-neighborhood.

Parameters
  • img (Union[ndarray, MultichannelImage]) – raw image data, shape: (c, y, x)

  • hot_pixel_thres (float) – hot pixel threshold

  • inplace (bool) – if True, the image is modified in-place

Return type

Union[ndarray, MultichannelImage]

Returns

The hot pixel-filtered image

median_filter_cv2(img, size, inplace=False)

Fast median blur using OpenCV

Parameters
  • img (Union[ndarray, MultichannelImage]) – raw image data, shape: (c, y, x)

  • size (int) – size of the median filter, must be odd

  • inplace (bool) – if True, the image is modified in-place when possible

Return type

Union[ndarray, MultichannelImage]

Returns

the median-filtered image

gaussian_filter_cv2(img, size=0, sigma=0, inplace=False)

Fast Gaussian blur using OpenCV

Parameters
  • img (Union[ndarray, MultichannelImage]) – raw image data, shape: (c, y, x)

  • size (int) – size of the median filter, must be odd

  • sigma (float) – Gaussian kernel standard deviation

  • inplace (bool) – if True, the image is modified in-place when possible

Return type

Union[ndarray, MultichannelImage]

Returns

the Gaussian-filtered image

rotate_centered_cv2(img, angle, border_mode=4, expand_bbox=False, inplace=False)

Fast centered image rotation using OpenCV

Parameters
  • img (Union[ndarray, MultichannelImage]) – raw image data, shape: (c, y, x)

  • angle (float) – rotation angle, in degrees

  • border_mode (int) – pixel extrapolation method, see cv2.warpAffine()

  • expand_bbox (bool) – if set to True, the bounding box of the resulting image is expanded to contain the full rotated image

  • inplace (bool) – if True, the image is modified in-place when possible

Return type

Union[ndarray, MultichannelImage]

Returns

the image, rotated around its center

to_table(arr)

Converts a two-dimensional xarray.DataArray to a pandas.DataFrame object

Parameters

arr (DataArray) – a two-dimensional xarray.DataArray

Return type

DataFrame

Returns

a pandas.DataFrame representation of the array