Image processing¶
This module contains operations commonly used in image processing.
-
morphocut.image.
ExtractROI
()[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 byFindRegions
.alpha – 1=Background completely reset to bg_color; 0 = Background fully visible.
bg_color – Color for the background.
-
morphocut.image.
FindRegions
()[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
mask (np.ndarray or Variable) – Mask of a given image.
image (np.ndarray or Variable) – An image whose mask we have to find region with.
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.
warn_empty (bool or str or Variable) – Warn for empty images (default false). If a String is supplied, it is used as an identifier for the image.
Example
mask = ... regionsprops = FindRegions(mask) # regionsprops: A skimage.measure.regionsprops object.
-
morphocut.image.
Gray2RGB
()[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.
ImageProperties
()[source]¶ Calculate region properties for an image containing a single object.
For more information see
skimage.measure.regionprops()
.- Parameters
mask (np.ndarray or Variable) – Mask of a given image.
image (np.ndarray or Variable) – An image whose mask we have to find region with.
Example
image = ... mask = image < 128 regionsprops = ImageProperties(mask, image) # regionsprops: A skimage.measure.regionsprops object.
-
morphocut.image.
ImageReader
()[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.
ImageWriter
()[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.
**kwargs – Arguments for
PIL.Image.Image.save()
.
-
morphocut.image.
RGB2Gray
()[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.
-
class
morphocut.image.
RegionProperties
(*args, **kwargs)[source]¶ Like skimage.measure.RegionProperties but without storing the whole image.
Please refer to skimage.measure.regionprops for more information on the available region properties.
-
property
image
¶ Sliced binary region image which has the same size as bounding box.
-
property
-
morphocut.image.
RescaleIntensity
()[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
()[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.
- Returns
Variable[np.ndarray] – Mask.