xmcdpy.masking¶
- xmcdpy.masking.add_mask(img, mask, inverted=False)¶
Overlays the mask over the image. If inverted True, uses an inverse mask.
- xmcdpy.masking.create_circle_mask(img, radius=None, centre=None, is_bool=True)¶
Creates a mask the size of the image with circle displaced by centre from the centre of the image and with given radius. If radius and centre are not given, use the ones defined in the globals
- xmcdpy.masking.ensure_rect_in_circle(rect_coord)¶
Ensures that all coordinates of the given rectangle lie inside the cirle mask.
- xmcdpy.masking.find_structure_hull(img, mask=None)¶
Finds the convex hull on the structure
- xmcdpy.masking.get_alignment_rectangle_mask(structure_mask, padding=20, side=None)¶
Finds the alignment mask based on the structure mask. It is a rectangle with one point at the centroid of the structure mask. The other point is on top or bottom of the structure (depending on the side parameter). Also ensures that the rectangle is within the image circle
- xmcdpy.masking.get_background_from_rect(rect_coord)¶
Gets the background mask from rectangle coordinates
- xmcdpy.masking.get_background_mask(structure_mask, circle_mask=None, padding=50)¶
Gets the mask covering the whole structure and the ring given by the circle mask
- xmcdpy.masking.get_fine_background(img, erode_size=30, area_threshold=1000)¶
Tries to find a structure on an image using threshold yen and a combination of area closing and opening.
- Parameters
img ((n,m) array) –
erode_size (int, optional) – How much to erode. Defaults to 30.
area_threshold (int, optional) – How much to open and close. Defaults to 30.
- Returns
Mask with the background selected
- Return type
(n,m) bool array
- xmcdpy.masking.get_large_mask(structure_mask, padding=50)¶
Gets the mask covering the whole structure by padding the structure mask and making it rectangular.