sksurgeryimage.utilities.utilities module

Various utilities, like preparing overlay text.

sksurgeryimage.utilities.utilities.are_similar(image0, image1, threshold=0.995, metric=5, mean_threshold=0.005)[source]

Compares two images to see if they are similar.

Parameters:
  • image0 (image0,) – The images
  • threshold – The numerical threshold to use, default 0.995
  • method – The comparison metric, default normalised cross correlation, cv2.TM_CCOEFF_NORMED
  • mean_threshold – Also compare the mean values of each array, return false if absolute difference of image means divided by the average of both images is greater than the mean_threshold, if less than zero this test will be skipped
Returns:

True if the metric is greater than the threshols, false otherwise or if the images are not the same dimensions or type

sksurgeryimage.utilities.utilities.image_means_are_similar(image0, image1, threshold=0.005)[source]

Compares two images to see if they have similar mean pixel values

Parameters:
  • image0 (image0,) – The images
  • threshold – The mean value threshold to use. return false if absolute difference of image means divided by the average of both images is greater than the mean_threshold.
Returns:

false if absolute difference of image means divided by the average of both images is greater than the mean_threshold, true otherwise or if threshold is less than zero.

sksurgeryimage.utilities.utilities.noisy_image(image, mean=0, stddev=(50, 5, 5))[source]

Creates a noise image, based on the dimensions of the passed image. param: the image to define size and channels of output returns: a noisy image

sksurgeryimage.utilities.utilities.prepare_cv2_text_overlay(overlay_text, frame, text_scale=1)[source]

Return settings for text overlay on a cv2 frame.