improutils.visualisation package

Submodules

improutils.visualisation.visualisation module

improutils.visualisation.visualisation.color_picker(img)[source]

Interactive tool to pick colors from an image.

Displays the input image in a window and allows the user to click on points to sample their colors. Each selected color is printed in the console and annotated on the image. Press ‘q’, ‘Q’, or ‘Esc’ to exit.

Parameters:

img (ndarray) – Input image in which colors will be sampled. Can be grayscale or color (BGR) image.

Returns:

This function does not return a value. Selected colors are printed to the console and annotated on the displayed image.

Return type:

None

improutils.visualisation.visualisation.draw_lines(img, lines)[source]

Draw lines coming from HoughLines procedure into image.

Parameters:
  • img (ndarray) – Input image.

  • lines (ndarray) – array of lines - output of cv2.HoughLines.

Return type:

Output image.

improutils.visualisation.visualisation.draw_real_sizes(img, rect, width_text, height_text, lbl_size_scale=2, lbl_color=(0, 0, 255), lbl_thickness=8)[source]

Draw real sizes of rotated rectangle into the image.

Parameters:
  • img (ndarray) – Input image.

  • rect (tuple) – Rotated rectangle.

  • width_text (string) – Width of the rectangle in the form of string.

  • height_text (string) – Height of the rectangle in the form of string.

  • lbl_size_scale (double) – Scale of text.

  • lbl_color (tuple) – Color of text.

  • lbl_thickness (int) – Thickness of text.

Return type:

Output image.

improutils.visualisation.visualisation.draw_rotated_rect(img, cnt)[source]

Draw rotated rectangle with minimum area into the image, around the contour.

Input image is not modified.

Parameters:
  • img (ndarray) – Input image.

  • cnt (ndarray) – Contour around which the rectangle will be drawn

Returns:

  • res (ndarray) – Image with drawn rectangle on it.

  • rect (ndarray) – rectangle from cv2.minAreaRect

improutils.visualisation.visualisation.draw_text(img, text, point, text_scale, text_color, text_thickness)[source]

Draw rotated text into the image.

Parameters:
  • img (ndarray) – Input image.

  • text (string) – Text to be drawn.

  • point (tuple) – Point where text is drawn.

  • text_scale (double) – Scale of text.

  • text_color (tuple) – Color of text.

  • text_thickness (int) – Thickness of text.

Return type:

Output image.

improutils.visualisation.visualisation.plot_images(*imgs, titles=[], channels='bgr', normalize=False, ticks_off=True, title_size=32)[source]

Plot multiple images in one figure.

Parameters:
  • *imgs (list) – Arbitrary number of images to be shown.

  • titles (list) – Titles for each image.

  • channels (string) – Colour channels. Possible values are “bgr”, “rgb” or “mono”.

  • normalize (bool) – If True, image will be normalized.

  • ticks_off (bool) – If True, axis decorations will be hidden.

  • title_size (int) – Size of the title.

Return type:

None

improutils.visualisation.visualisation.show_camera_window(*imgs, scale=1)[source]

Open input images in separate windows.

Parameters:
  • *imgs (list) – Arbitrary number of images to be shown.

  • scale (double) – Scale of shown image window.

Return type:

None

improutils.visualisation.visualisation.show_images(*imgs, scale=1, window_name='Image preview')[source]

Display multiple images in separate resizable windows.

Each image in the input list is shown in its own window. The user can click on the images to print the (x, y) coordinates of mouse clicks. The preview is terminated by pressing the ‘q’, ‘Q’, or ‘Esc’ key.

Parameters:
  • *imgs (ndarray) – One or more images to display. Each image can be grayscale or color (BGR).

  • scale (float, optional) – Scaling factor for the displayed image windows. Default is 1.

  • window_name (str, optional) – Base name for the displayed windows. Default is “Image preview”.

Return type:

None

Notes

Known bug for Mac users: see https://gitlab.fit.cvut.cz/bi-svz/bi-svz/issues/13

Module contents

improutils.visualisation.color_picker(img)[source]

Interactive tool to pick colors from an image.

Displays the input image in a window and allows the user to click on points to sample their colors. Each selected color is printed in the console and annotated on the image. Press ‘q’, ‘Q’, or ‘Esc’ to exit.

Parameters:

img (ndarray) – Input image in which colors will be sampled. Can be grayscale or color (BGR) image.

Returns:

This function does not return a value. Selected colors are printed to the console and annotated on the displayed image.

Return type:

None

improutils.visualisation.draw_lines(img, lines)[source]

Draw lines coming from HoughLines procedure into image.

Parameters:
  • img (ndarray) – Input image.

  • lines (ndarray) – array of lines - output of cv2.HoughLines.

Return type:

Output image.

improutils.visualisation.draw_real_sizes(img, rect, width_text, height_text, lbl_size_scale=2, lbl_color=(0, 0, 255), lbl_thickness=8)[source]

Draw real sizes of rotated rectangle into the image.

Parameters:
  • img (ndarray) – Input image.

  • rect (tuple) – Rotated rectangle.

  • width_text (string) – Width of the rectangle in the form of string.

  • height_text (string) – Height of the rectangle in the form of string.

  • lbl_size_scale (double) – Scale of text.

  • lbl_color (tuple) – Color of text.

  • lbl_thickness (int) – Thickness of text.

Return type:

Output image.

improutils.visualisation.draw_text(img, text, point, text_scale, text_color, text_thickness)[source]

Draw rotated text into the image.

Parameters:
  • img (ndarray) – Input image.

  • text (string) – Text to be drawn.

  • point (tuple) – Point where text is drawn.

  • text_scale (double) – Scale of text.

  • text_color (tuple) – Color of text.

  • text_thickness (int) – Thickness of text.

Return type:

Output image.

improutils.visualisation.plot_images(*imgs, titles=[], channels='bgr', normalize=False, ticks_off=True, title_size=32)[source]

Plot multiple images in one figure.

Parameters:
  • *imgs (list) – Arbitrary number of images to be shown.

  • titles (list) – Titles for each image.

  • channels (string) – Colour channels. Possible values are “bgr”, “rgb” or “mono”.

  • normalize (bool) – If True, image will be normalized.

  • ticks_off (bool) – If True, axis decorations will be hidden.

  • title_size (int) – Size of the title.

Return type:

None

improutils.visualisation.show_camera_window(*imgs, scale=1)[source]

Open input images in separate windows.

Parameters:
  • *imgs (list) – Arbitrary number of images to be shown.

  • scale (double) – Scale of shown image window.

Return type:

None

improutils.visualisation.show_images(*imgs, scale=1, window_name='Image preview')[source]

Display multiple images in separate resizable windows.

Each image in the input list is shown in its own window. The user can click on the images to print the (x, y) coordinates of mouse clicks. The preview is terminated by pressing the ‘q’, ‘Q’, or ‘Esc’ key.

Parameters:
  • *imgs (ndarray) – One or more images to display. Each image can be grayscale or color (BGR).

  • scale (float, optional) – Scaling factor for the displayed image windows. Default is 1.

  • window_name (str, optional) – Base name for the displayed windows. Default is “Image preview”.

Return type:

None

Notes

Known bug for Mac users: see https://gitlab.fit.cvut.cz/bi-svz/bi-svz/issues/13