temperature_independent module

add_margin(pil_img, top, right, bottom, left, color)[source]

Image padding script, to add 300 pixels around the border of an XRD image so the images become 2048 plus 600 square matrices.

Authors: Weiqi Yue, Gabriel Ponon, Zhuldyz Ualikhankyzy, Nathaniel K. Tomczak Version: v0_1 (Jul 23 2022)

Parameters:
  • pil_img (PIL.Image.Image) – Input PIL image to which margins are added.

  • top (int) – Size of the top margin.

  • right (int) – Size of the right margin.

  • bottom (int) – Size of the bottom margin.

  • left (int) – Size of the left margin.

  • color (int or tuple) – Color to overlay for margins.

Returns:

Resulting image with added margins.

Return type:

PIL.Image.Image

reshape(input_img)[source]

Change image array shape to fit resize operation.

Authors: Weiqi Yue, Gabriel Ponon, Zhuldyz Ualikhankyzy, Nathaniel K. Tomczak Version: v0_1 (Jul 23 2022)

Parameters:

input_img (PIL.Image.Image) – The input PIL image to reshape.

Returns:

Reshaped image array.

Return type:

numpy.ndarray

resize_image(img, ref_path, r_only=False, img_only=False, fixed_ratio=None)[source]

Resize image to desired 2048 x 2048 size by finding optimum ratio. The optimum is determined by minimizing a correlation coefficient between the input image and a reference image.

Authors: Weiqi Yue, Gabriel Ponon, Zhuldyz Ualikhankyzy, Nathaniel K. Tomczak Version: v0_1 (Jul 23 2022)

Parameters:
  • img (PIL.Image.Image) – Input PIL image to resize.

  • ref_path (str) – Full path to the reference image.

  • r_only (bool) – True when the output is the ratio number only. (default: False)

  • img_only (bool) – True when the output is the PIL image only. (default: False)

  • fixed_ratio (float or None) – The value to fix the ratio for computation. Set to None to retrieve the ratio value automatically. (default: None)

Returns:

Resized image or ratio value, depending on the parameters.

Return type:

PIL.Image.Image or float