Skip to main content
Version: v1.0.0

ml.images.conversion

module ml.images.conversion

The conversion module allows users to transform images freely


function to_blackwhite#

to_blackwhite(    image_list: <built-in function array>,    threshold=128,    keep_3d_shape=False) โ†’ <built-in function array>

Transforms an image to a black & white image

Args:

  • `image_list` (np.array): A numpy array that contains all selected images represented as np.array
  • `threshold` (int): The threshold (between 0 and 255) that decides a pixel will be 0 or 255 (W/B)

Returns:

  • `np.array`: A numpy array that contains all black & white images represented as np.array

function prepare#

prepare(    image: <built-in function array>,    image_size=None,    convert_to_grey: bool = False,    keep_3d_shape=False) โ†’ <built-in function array>

Takes an image and applies preformatting

Args:

  • `image` (np.array): The array representation of the image to process
  • `image_size` (tuple): The image size can be passed as tuple (W, H) or as int (W=H)
  • `convert_to_grey` (bool): This would reduce the size (and shape) of the image in making it a greyscale
  • `keep_3d_shape` (bool): Only used when convert_to_grey is true. Will keep the images in shape (H,W,1) in that case

Returns:

  • `np.array`: A numpy array that represents the preprocessed image

function crop#

crop(    image: <built-in function array>,    x: int,    y: int,    width: int,    height: int) โ†’ <built-in function array>

Crops an image based on the specified size

Args:

  • `image` (np.array): The array representation of the image to crop
  • `x` (int): The x coordinate of the rectangle to keep (horizontal position from the left)
  • `y` (int): The y coordinate of the rectangle to keep (vertical position from the top)
  • `width` (int): The width of the cropped image
  • `height` (int): The height of the cropped image

Returns:

  • `np.array`: A numpy array that represents the cropped part of the image

function get_fragments#

get_fragments(    image: <built-in function array>,    stride: tuple = (1, 1),    fragment_size: tuple = (1, 1),    rectangle=None)

Scans an image and return the resulted parts as a list of image sections

Args:

  • `image` (np.array): The array representation of the image to scan
  • `stride` (tuple): The steps to move over the image
  • `fragment_size` (tuple): The size of the fragments to take from the image
  • `rectangle` (np.array): The rectangle in the image to scan (if only a part of the image should be scanned. Form: (x, y, width, height)

Returns:

  • `np.array`: A numpy array that contains all fragments as images

This file was automatically generated via lazydocs.