find_center module
- add_margin(pil_img, top, right, bottom, left, color)[source]
Add margins around the border of an image.
Authors: Weiqi Yue, Gabriel Ponon, Zhuldyz Ualikhankyzy, Nathaniel K. Tomczak Version: v0_1 (Jul 23 2022)
- Parameters:
pil_img (PIL.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:
The image with added margins.
- Return type:
PIL.Image
- create_circular_mask(h, w, outer_radius, inner_radius, center=None)[source]
Create a circular ring mask for specified radii.
Authors: Weiqi Yue, Gabriel Ponon, Zhuldyz Ualikhankyzy, Nathaniel K. Tomczak Version: v0_1 (Jul 23 2022)
- Parameters:
h (int) – Height of the mask.
w (int) – Width of the mask.
outer_radius (float) – Outer radius for the mask.
inner_radius (float) – Inner radius for the mask.
center (tuple, optional) – Coordinate tuple of the center of the mask. Uses the middle of the image if None.
- Returns:
The circular mask.
- Return type:
numpy.ndarray
- define_mask(h=2048, w=2048, inner_radius=40, white_width=8, black_width=10)[source]
Returns a multi-ring mask that can be used to filter an XRD image.
Authors: Weiqi Yue, Gabriel Ponon, Zhuldyz Ualikhankyzy, Nathaniel K. Tomczak Version: v0_1 (Jul 23 2022)
- Parameters:
h (int) – Height of the mask.
w (int) – Width of the mask.
inner_radius (int, optional) – Inner radius of the first ring.
white_width (int, optional) – Width of the transparent ring portions.
black_width (int, optional) – Width of the opaque ring portions.
- Returns:
The multi-ring mask.
- Return type:
numpy.ndarray
- find_center(img, mask=None)[source]
Apply a mask to the central region of interest on an XRD image and find the coordinates of maximum intensity.
Authors: Weiqi Yue, Gabriel Ponon, Zhuldyz Ualikhankyzy, Nathaniel K. Tomczak Version: v0_1 (Jul 23 2022)
- Parameters:
img (PIL.Image) – Input PIL XRD image to find the ring center.
mask (numpy.ndarray, optional) – The mask to use. If None, a mask will be generated through the define_mask function.
- Returns:
The coordinates of the maximum intensity.
- Return type:
tuple