imageutils
imageutils ¶
Module for image utilization
Functions¶
binarize_multichannel_image ¶
Binarize (0,1) a multichannel image holding prediction information based on a threshold. Returns one binarized image per class and an overall mask with prediction scores above the threshold.
Parameters:
-
image_index
(ndarray
) –np.ndarray numpy array with the shape (image.height, image.width) filled with the predicted class index of each pixel
-
image_scores
(ndarray
) –np.ndarray numpy array with the shape (image.height, image.width) filled with a prediction score (0.0-1.0) of each pixel
-
threshold
(float
) –float threshold to create a mask with a prediction score > threshold
Returns:
-
binary_multichannel_images
(Dict[str, ndarray]
) –Dict[str, np.array] Dictionary of binarized images per class
-
scores_mask
(ndarray
) –np.ndarray mask including information where the prediction is above threshold
Source code in niceml/utilities/imageutils.py
calc_diff_mask ¶
Calculates the difference of an orig_img
and an obfuscated_img
Source code in niceml/utilities/imageutils.py
calc_heatmap ¶
Creates a heatmap based on a predicted image and an input image
Source code in niceml/utilities/imageutils.py
find_contours_in_binary_image ¶
Find the Contours in a binary Image
Parameters:
-
binary_image
(ndarray
) –image to search for contours on
-
min_area
(int
) –minimum area of relevant contours
-
max_area
(int
) –maximum area of relevant contours
Returns:
-
List
–Found contours within the relevant area range
Source code in niceml/utilities/imageutils.py
get_font ¶
Returns a randomly selected FreeTypeFont
from ten predefined font names
Source code in niceml/utilities/imageutils.py
stich_images ¶
Arranges a list of PIL Images in a grid view with a given tile_size.
image_list: List of images to be arranged horizontal_count: Number of images that will be placed horizontally in the stiched image vertical_count: Number of images that will be placed vertically in the stiched image tile_size: Size of each image tile (width, height)
Returns:
-
Image
–All images stitched together in a grid view as one image