nanslice.slice_func module

slice_func.py

Functions for manipulating ‘slices’/images (or (X, Y, 3) arrays)

nanslice.slice_func.blend(img_under, img_over, img_alpha)[source]

Blend together two images using an alpha channel image

Parameters:

  • img_under – The base image (underneath the overlay)
  • img_over – The overlay image
  • img_alpha – Transparency/alpha value to use when blending
nanslice.slice_func.blur(img, sigma=1)[source]

Blur an image with a Gaussian kernel

Parameters:

  • img – The image to blur
  • sigma – The FWHM of the Gaussian kernel, in voxels
nanslice.slice_func.checkerboard(img1, img2, square_size=16)[source]

Combine two images in a checkerboard pattern, useful for checking image registration quality. Idea stolen from @ramaana_ on Twitter

nanslice.slice_func.colorize(data, cmap, clims=None)[source]

Apply a colormap to grayscale data. Takes an (X, Y) array and returns an (X, Y, 3) array

Parameters:

  • data – The 2D scalar (X, Y) array to colorize
  • cmap – Any valid matplotlib colormap or colormap name
  • clims – The limits for the colormap
nanslice.slice_func.mask(img, img_mask, back=array([0, 0, 0]))[source]

Mask out sections of one image using another

Parameters:

  • img – The image to be masked
  • img_mask – The mask image
  • back – Background value
nanslice.slice_func.scale_clip(data, lims)[source]

Scale an image to fill the range 0-1 and clip values that fall outside that range

Parameters:

  • data – The image data array
  • lims – The limits to scale betwee