Image processing

This module contains operations commonly used in image processing.

morphocut.image.ExtractROI(image, mask, regionprops, alpha=0.5, bg_color=1.0)[source]

Extract part of an image using a RegionProperties instance.

To be used in conjunction with FindRegions.

Parameters
  • image (np.ndarray or Variable) – Image from which regions are to be extracted.

  • regionprops (RegionProperties or Variable) – RegionProperties instance returned by FindRegions.

morphocut.image.FindRegions(mask, image=None, min_area=None, max_area=None, padding=0)[source]

Stream Find regions in a mask and calculate properties.

For more information see skimage.measure.regionprops().

Note

This Node creates multiple objects per incoming object.

Parameters
  • image (np.ndarray or Variable) – An image whose mask we have to find region with.

  • mask (np.ndarray or Variable) – Mask of a given image.

  • min_area (int) – Minimum area of the region. If the area of our prop/region is smaller than our min_area then it will discard it.

  • max_area (int) – Maximum area of the region. If the area of our prop/region is bigger than our max_area then it will discard it.

  • padding (int) – Size of the slices/regions of our image.

Example

mask = ...
regionsprops = FindRegions(mask)

# regionsprops: A skimage.measure.regionsprops object.
morphocut.image.Gray2RGB(image)[source]

Create an RGB representation of a gray-level image.

Note

Uses the skimage library skimage.color.gray2rgb() to convert from Grayscale to RGB.

Parameters

image (numpy.ndarray or Variable) – Gray-level input image.

Returns

Variable[numpy.ndarray]

The RGB image:

An array which is the same size as the input array, but with a channel dimension appended.

morphocut.image.ImageReader(fp)[source]

Read and open the image from a given path.

Use Python Imaging Library PIL to open the file from a given path.

Parameters

fp (file or Variable) – A filename (string), pathlib.Path object or file object.

morphocut.image.ImageStats(image, name='')[source]

Parse information from a path

morphocut.image.ImageWriter(fp, image)[source]

Write the image into the given directory path.

Use Python Imaging Library PIL to save the image in a given path.

Parameters
  • fp (file or Variable) – A filename (string), pathlib.Path object or file object.

  • image (np.ndarray or Variable) – Image that is to be saved into a given directory.

morphocut.image.RGB2Gray(image)[source]

Compute luminance of an RGB image using skimage.color.rgb2gray().

Parameters

image (numpy.ndarray or Variable) – The image in RGB format.

Returns

Variable[numpy.ndarray]

The luminance image:

An array which is the same size as the input array, but with the channel dimension removed and dtype=float.

morphocut.image.RescaleIntensity(image, in_range='image', dtype=None)[source]

Rescale the intensities of the image.

Note

Uses the skimage library skimage.exposure.rescale_intensity().

Parameters
  • image (np.ndarray or Variable) – An image file to be rescaled.

  • in_range ((str or 2-tuple) or Variable) – min/max as the intensity range.

  • dtype (str or Variable) – min/max of the image’s dtype as the intensity range.

Returns

Variable[np.ndarray] – Image with intensities rescaled.

morphocut.image.ThresholdConst(image, threshold)[source]

Calculate a mask by applying a constant threshold.

The result will be image <= threshold.

Parameters
  • image (np.ndarray or Variable) – Image for which the mask is to be calculated.

  • threshold (Number or Variable) – Threshold. Image intensities less than this will be True in the result.