images_alignment.alignment module

Class dedicated to images alignment

class images_alignment.alignment.ImagesAlign(fnames_fixed=None, fnames_moving=None, rois=None, thresholds=None, bin_inversions=None, terminal=None)

Bases: object

Class dedicated to images alignment

Parameters:
  • fnames_fixed, fnames_moving (iterables of str, optional) – Images pathnames related to fixed and moving images resp. to handle

  • rois (list of 2 iterables, optional) –

    rois (regions of interest) attached to the fixed and moving images, each defining as:

    [xmin, xmax, ymin, ymax]

  • thresholds (iterable of 2 floats, optional) – Thresholds used to binarize the images. Default values are [0.5, 0.5]

  • bin_inversions (iterable of 2 bools, optional) – Activation keywords to reverse the image binarization

  • terminal (object, optional) – object with an associated write() class function to write messages

fnames_tot

Images pathnames related to fixed and moving images resp.

Type:

list of 2 list

fnames

List of the current fixed and moving images filenames

Type:

list of 2 str

imgs, imgs_bin

Arrays related to the current fixed and moving images, in their raw or binarized states resp.

Type:

list of 2 arrays

dtype

Datatypes associated to the current fixed and moving images

Type:

list of 2 dtype

rois
rois (regions of interest) attached to the fixed and moving images, each defining as:

[xmin, xmax, ymin, ymax]

Type:

list of 2 iterables, optional

thresholds

Thresholds used to binarize the images. Default values are [0.5, 0.5]

Type:

iterable of 2 floats

angles

angles to apply resp to the fixed and moving images before registration. (each angle to be chosen among [0, 90, 180, 270])

Type:

list of 2 int

bin_inversions

Activation keywords to reverse the image binarization

Type:

iterable of 2 bools

terminal

object with an associated write() class function to write messages

Type:

object

registration_model

Registration model to be considered among [‘StackReg’, ‘SIFT’, ‘SIFT + StackReg’, ‘User-Driven’]. Default is ‘StackReg’.

Type:

str

points

Coordinates of the matching points between the fixed and moving images (filled by all registration models except ‘StackReg’).

Type:

list of 2 list of floats

max_size_reg

Maximum image size considered when performing the registration. Default value is 512.

Type:

int

inv_reg

Activation key to reverse ‘fixed’ and ‘moving’ images during the registration calculation. Default is False.

Type:

bool

tmat

Transformation matrice returned by the registration.

Type:

numpy.ndarray((3, 3))

img_reg, img_reg_bin

Arrays issued from the moving registrated image in its raw or binarized state resp.

Type:

arrays

mask

Array (dtype=bool) associated with the overlapping area issued from the registration.

Type:

numpy.ndarray

tmat_options

Dictionary composed of options to build the ‘tmat’ transformation matrice (translation, rotation, scaling, shearing). Default values are True.

Type:

dictionary of bool, optional

order

The order of interpolation. See: https://scikit-image.org/docs/stable/api/skimage.transform.html#skimage.transform.warp

Type:

int, optional

fixed_reg

Activation key to perform the worflow calculation with a fixed ‘tmat’. Default is False.

Type:

bool

results

Dictionary that contains the workflow score and tmat of each alignment

Type:

dict

dirname_res

Filenames associated with the ‘fixed_images’ and ‘moving_images’ resulting images sub-folders

Type:

list of 2 str

binarized

Activation key to display images according to their binarized values

Type:

bool

resolution

relative resolution parameter (between [0., 1.]). Default value is 0.

Type:

float

min_img_res

Minimum image resolution associated to ‘resolution’=0. Default value is 256.

Type:

int

rfactors_plotting

Rescaling factors used for images displaying (each one between [0., 1.]). Default values are [1., 1.].

Type:

list of 2 floats

juxt_alignment

Mode of images juxtapostion (‘horizontal’ or ‘vertical’). Default value is ‘horizontal’.

Type:

str

apply_mask

Activation keyword to limit the combined image to the overlapping area. Default is True.

Type:

bool

ax

Axes associated to the image alignment application to display the different images. Default is a 4 horizontal axes to respectively display the ‘fixed’ and ‘moving’ image, the ‘juxtaposed image’ and the ‘combined image’.

Type:

matplotlib.axes.Axes object

reinit()

Reinitialize ‘points’, ‘img_reg’, ‘img_reg_bin’ and ‘results’

load_files(k, fnames)

Load the k-th image files

load_image(k, fname)

Load the k-th image

get_shapes()

Return the shapes related to the cropped (or not cropped) images

update_rfactors_plotting()

Update the ‘rfactors_plotting’ wrt ‘resolution’ and ‘imgs’ sizes

binarization_k(k)

Binarize the k-th image

binarization()

Binarize the images

crop_and_resize(imgs, verbosity=True)

Crop and Resize the images

registration(registration_model=None, show_score=True)

Calculate the transformation matrix ‘tmat’ and apply it

registration_calc(registration_model=None)

Calculate the transformation matrix ‘tmat’

registration_apply(show_score=True)

Apply the transformation matrix ‘tmat’ to the moving image

save_images(fnames_save)

Save the fixed and moving images in their final states

set_dirname_res(dirname_res=None)

Set dirname results ‘dirname_res’

apply_to_all(dirname_res=None)

Apply the transformations to a set of images

save_params(fname_json=None)

Save parameters in a .json file

static reload_params(fname_json=None, obj=None)

Reload parameters from a .json file and Return an ImagesAlign() object

plot_all(ax=None)

Plot all the axis

plot_k(k)

Plot the k-th axis

plot_fixed_or_moving_image(k)

Plot the fixed (k=0) or the moving (k=1) image

plot_juxtaposed_images(nmax=10)

Plot the juxtaposed images

plot_combined_images()

Plot the combined images