xmcdpy.image_manipulation

xmcdpy.image_manipulation.img2pil(img)

Returns PIL version of the image. Useful for showing in notebooks.

xmcdpy.image_manipulation.mean_plane_subtraction(img, mask=None, subsample=10, order=1)

Substracts the mean plane of the masked region. If order = 1 just subtract mean plane. For order 2 try subtracting second order variation as well (experimental). Algorithm can take a long time to run while not all points on the images are important, so take only every subsample pixel.

Parameters
  • img (array) –

  • mask (array or None, optional) – Defaults to None.

  • subsample (int, optional) – Defaults to 10.

  • order (int, optional) – Defaults to 1.

Returns

image with mean plane substracted

Return type

array

xmcdpy.image_manipulation.normalise_image(img, norm_image)

Divides the image with normalisation image

xmcdpy.image_manipulation.normalise_mnmx(img)

Sets the image values between 0 and 1 by substracting the minimum and dividing by the difference

xmcdpy.image_manipulation.normalise_stack(stack, norm_image)

Runs normalise_image on every image in the stack and returns a stack of normalised images

xmcdpy.image_manipulation.normalise_stack_brightness(images, background_mask, threshold=0.15)

For every structure in the stack, gets the mean of the masked region and divides each image by the factor of difference from the first one. If the adjustment factor for brightness is larger than the threshold, drop that image.

Parameters
  • images (array) – Stack of images.

  • background_mask (bool array) – Boolean selecting the background of the image.

  • threshold (float, optional) – Brightness factor threshold for dropping an image. Defaults to 0.15.

Returns

Stack of images with normalized brightness.

Return type

array

xmcdpy.image_manipulation.select_rect_coord(img, rect_coord)

Selects the image cropped to rect_coord.

Parameters
  • img ((n, m), (n, m, k) array) – Image numpy array.

  • rect_coord ((4,) array, list) – Rectangular coordinates defining corners of the rectangle.

Returns

cropped image

Return type

array

xmcdpy.image_manipulation.stack_mps(images, mask=None, subsample=10)

Substracts the mean plane of the masked region for all images in the stack