improutils.segmentation package

Submodules

improutils.segmentation.segmentation module

improutils.segmentation.segmentation.apply_mask(img, mask_bin)[source]

Apply binary mask on the image.

Parameters:
  • img (ndarray) – Input image.

  • mask_bin (ndarray) – Binary mask to be applied.

Return type:

Masked image.

improutils.segmentation.segmentation.segmentation_adaptive_threshold(img, size, constant=0)[source]

Segment image into black & white using calculated adaptive threshold using Gaussian function in pixel neighbourhood.

Parameters:
  • img (ndarray) – Input image.

  • size (int) – Size of used gaussian. Lowest value is 3. Algorithm uses only odd numbers.

  • constant (int) – Value that is added to calculated threshlod. It could be negative as well as zero as well as positive number.

Returns:

img – Output binary image.

Return type:

ndarray

improutils.segmentation.segmentation.segmentation_auto_threshold(img)[source]

Segment image into black & white using automatic threshold.

Parameters:

img (ndarray) – Input image.

Return type:

Output image.

improutils.segmentation.segmentation.segmentation_one_threshold(img, threshold)[source]

Segment image into black & white using one threshold.

Parameters:
  • img (ndarray) – Input image.

  • threshold (int) – Pixels with value lower than threshold are considered black, the others white.

Return type:

Output image.

improutils.segmentation.segmentation.segmentation_two_thresholds(img, lower, higher)[source]

Segment image into black & white using two thresholds.

Parameters:
  • img (ndarray) – Input image.

  • lower (int) – Pixels with value lower than threshold are considered black, the others white.

  • higher (int) – Pixels with value higher than threshold are considered black, the others white.

Return type:

Output image.

improutils.segmentation.segmentation.to_3_channels(image)[source]

Convert 1 channel image to 3 channels.

improutils.segmentation.segmentation.to_angle(hue_intensity)[source]

Convert hue intensity value of brightness image in opencv into hue angle in HUE definition.

For further info visit: https://www.docs.opencv.org/trunk/df/d9d/tutorial_py_colorspaces.html.

Parameters:

hue_intensity (int) – Intensity value of brightness image (0-179).

Return type:

Integer value that represents the HUE angle (0-359).

improutils.segmentation.segmentation.to_intensity(hue_angle)[source]

Convert color angle in HUE definition into intensity value of brightness image in opencv.

For further info visit: https://www.docs.opencv.org/trunk/df/d9d/tutorial_py_colorspaces.html.

Parameters:

hue_angle (int) – Angle in HUE definition (0-359).

Return type:

Integer value that represents the same HUE value but in opencv brightness image (0-179).

Module contents

improutils.segmentation.apply_mask(img, mask_bin)[source]

Apply binary mask on the image.

Parameters:
  • img (ndarray) – Input image.

  • mask_bin (ndarray) – Binary mask to be applied.

Return type:

Masked image.

improutils.segmentation.segmentation_adaptive_threshold(img, size, constant=0)[source]

Segment image into black & white using calculated adaptive threshold using Gaussian function in pixel neighbourhood.

Parameters:
  • img (ndarray) – Input image.

  • size (int) – Size of used gaussian. Lowest value is 3. Algorithm uses only odd numbers.

  • constant (int) – Value that is added to calculated threshlod. It could be negative as well as zero as well as positive number.

Returns:

img – Output binary image.

Return type:

ndarray

improutils.segmentation.segmentation_auto_threshold(img)[source]

Segment image into black & white using automatic threshold.

Parameters:

img (ndarray) – Input image.

Return type:

Output image.

improutils.segmentation.segmentation_one_threshold(img, threshold)[source]

Segment image into black & white using one threshold.

Parameters:
  • img (ndarray) – Input image.

  • threshold (int) – Pixels with value lower than threshold are considered black, the others white.

Return type:

Output image.

improutils.segmentation.segmentation_two_thresholds(img, lower, higher)[source]

Segment image into black & white using two thresholds.

Parameters:
  • img (ndarray) – Input image.

  • lower (int) – Pixels with value lower than threshold are considered black, the others white.

  • higher (int) – Pixels with value higher than threshold are considered black, the others white.

Return type:

Output image.

improutils.segmentation.to_3_channels(image)[source]

Convert 1 channel image to 3 channels.

improutils.segmentation.to_angle(hue_intensity)[source]

Convert hue intensity value of brightness image in opencv into hue angle in HUE definition.

For further info visit: https://www.docs.opencv.org/trunk/df/d9d/tutorial_py_colorspaces.html.

Parameters:

hue_intensity (int) – Intensity value of brightness image (0-179).

Return type:

Integer value that represents the HUE angle (0-359).

improutils.segmentation.to_intensity(hue_angle)[source]

Convert color angle in HUE definition into intensity value of brightness image in opencv.

For further info visit: https://www.docs.opencv.org/trunk/df/d9d/tutorial_py_colorspaces.html.

Parameters:

hue_angle (int) – Angle in HUE definition (0-359).

Return type:

Integer value that represents the same HUE value but in opencv brightness image (0-179).