esmraldi.imageutils

Module Contents

Functions

center_images(images, size)

Center 2D images w.r.t. to the center of the image size,

resize(image, size)

Resize the image to a given size.

max_area_slices(image)

Get largest area

relative_area(image)

Get area relative to largest area

enforce_continuity_values(sequence)

Enforce monotonic distribution of sequence

slice_correspondences(reference, target, sigma[, ...])

Find slice correspondences with Dynamic Time Warping

slice_correspondences_manual(reference, target, ...[, ...])

Find slice correspondences manually

compute_DT(image_itk[, invert])

Compute DT

estimate_noise(I)

Estimates the noise in an image

variance_image(image[, size])

Variance image

stddev_image(image[, size])

Standard deviation image

mse_numpy(fixed_array, moving_array)

Mean squared error on numpy arrays

mse(fixed, moving)

Mean squared error on ITK Images

dt_mse(fixed, moving)

Mean squared error on distance transformed

mse_stddev(fixed, moving)

Mean squared error on stddev

radius_maximal_balls(image)

Computes an image which maps each point to the radius of its enclosing

normalized_dt(image)

Normalized distance transformation

local_max_dt(image)

Identify local maxima in the distance

export_figure_matplotlib(f_name, arr[, arr2, dpi, ...])

Export array as figure in original resolution

voronoi_diagram(points, shape)

Computes simple Voronoi diagram

simple_vcm(voronoi, point, r)

Basic and Simplified Voronoi Covariance Measure

estimate_plane(obj, voronoi, point[, max_r])

Normal plane estimation with VCM

local_radius(image)

Local radius from VCM plane estimation

pseudo_flat_field_correction(image, sigma)

get_norm_image(images, norm, mzs)

normalize_image(current_image, norm_img)

distance_point_to_set(point, point_set)

rectangle_coordinates(lower_left, upper_right)

esmraldi.imageutils.center_images(images, size)

Center 2D images w.r.t. to the center of the image size, and superimpose them to create a 3D volume

Parameters
images: list

list of 2D images

size: tuple

desired image size

Returns
np.ndarray

superimposed 2D images

esmraldi.imageutils.resize(image, size)

Resize the image to a given size.

Parameters
image: sitk.Image

input image

size: tuple

new size of the image

Returns
sitk.Image

new resized image

esmraldi.imageutils.max_area_slices(image)

Get largest area

esmraldi.imageutils.relative_area(image)

Get area relative to largest area

esmraldi.imageutils.enforce_continuity_values(sequence)

Enforce monotonic distribution of sequence

esmraldi.imageutils.slice_correspondences(reference, target, sigma, is_reversed=False, is_continuity=True)

Find slice correspondences with Dynamic Time Warping

Parameters
reference: np.ndarray

reference image

target: np.ndarray

target

sigma: float

gaussian standard deviation

is_reversed: bool

whether the images are reversed in the z-axis

is_continuity: bool

whether to enforce continuity (slice numbers are monotonically increasing)

Returns
np.ndarray

correspondence indices

esmraldi.imageutils.slice_correspondences_manual(reference, target, resolution_reference, resolution_target, slices_reference, slices_target, is_reversed=False)

Find slice correspondences manually

Parameters
reference: np.ndarray

reference image

target: np.ndarray

target

resolution_reference: float

interslice resolution reference

resolution_target: float

interslice resolution target

slices_reference: list

slice numbers reference

slices_target: list

slice numbers target

is_reversed: bool

whether the images are reversed in the z-axis

Returns
np.ndarray

correspondence indices

esmraldi.imageutils.compute_DT(image_itk, invert=False)

Compute DT

Parameters
image_itk: sitk.Image

ITK Image

Returns
sitk.Image

DT Image

esmraldi.imageutils.estimate_noise(I)

Estimates the noise in an image by convolution with a kernel.

See: Fast Noise Variance Estimation, Immerkaear et al.

Parameters
I: np.ndarray

image

Returns
float

the noise standard deviation

esmraldi.imageutils.variance_image(image, size=3)

Variance image

Parameters
image: np.ndarray

the image

size: int

neighborhood size

Returns
np.ndarray

variance image

esmraldi.imageutils.stddev_image(image, size=3)

Standard deviation image

Parameters
image: np.ndarray

the image

size: int

neighborhood size

Returns
np.ndarray

stddev image

esmraldi.imageutils.mse_numpy(fixed_array, moving_array)

Mean squared error on numpy arrays

Parameters
fixed_array: np.ndarray

image 1

moving_array: np.ndarray

image 2

Returns
float

Mean squared error between images

esmraldi.imageutils.mse(fixed, moving)

Mean squared error on ITK Images

Parameters
fixed: sitk.Image

image 1

moving: sitk.Image

image 2

Returns
float

Mean squared error between images

esmraldi.imageutils.dt_mse(fixed, moving)

Mean squared error on distance transformed ITK images

Parameters
fixed: sitk.Image

image 1

moving: sitk.Image

image 2

Returns
float

Mean squared error between DT images

esmraldi.imageutils.mse_stddev(fixed, moving)

Mean squared error on stddev ITK images

Parameters
fixed: sitk.Image

image 1

moving: sitk.Image

image 2

Returns
float

Mean squared error between stddev images

esmraldi.imageutils.radius_maximal_balls(image)

Computes an image which maps each point to the radius of its enclosing maximal ball

Parameters
image: np.ndarray

the image

Returns
np.ndarray

maximal ball radii map

esmraldi.imageutils.normalized_dt(image)

Normalized distance transformation by the maximal ball radii

Parameters
image: np.ndarray

input image

Returns
np.ndarray

normalized dt

esmraldi.imageutils.local_max_dt(image)

Identify local maxima in the distance transformed ITK image

Parameters
image: sitk.Image

input image

Returns
np.ndarray

local maxima map, where local maxima = 1

esmraldi.imageutils.export_figure_matplotlib(f_name, arr, arr2=None, dpi=200, resize_fact=1, cmaps=['gray', 'Reds'], alpha=0.5, plt_show=False, vmin=None, vmax=None)

Export array as figure in original resolution :param arr: array of image to save in original resolution :param f_name: name of file where to save figure :param resize_fact: resize facter wrt shape of arr, in (0, np.infty) :param dpi: dpi of your screen :param plt_show: show plot or not

esmraldi.imageutils.voronoi_diagram(points, shape)

Computes simple Voronoi diagram

Parameters
points: np.ndarray

sites

shape: tuple

shape of image

Returns
np.ndarray

Voronoi diagram as union of Voronoi cells

esmraldi.imageutils.simple_vcm(voronoi, point, r)

Basic and Simplified Voronoi Covariance Measure

Parameters
voronoi: tuple

sites and associated Voronoi cells

point: tuple

point where to estimate VCM

r: radius

local radius for VCM

Returns
tuple

Eigenvectors associated to the Voronoi cell shape + max distance in cells

esmraldi.imageutils.estimate_plane(obj, voronoi, point, max_r=np.inf)

Normal plane estimation with VCM

Parameters
obj: np.ndarray

object

voronoi: tuple

sites, and associated Voronoi cells

point: tuple

point where to estimate plane

max_r: int

maximum bounding radius for Voronoi cells (big R)

esmraldi.imageutils.local_radius(image)

Local radius from VCM plane estimation

Parameters
image: np.ndarray

image

Returns
np.ndarray

Local radius map

esmraldi.imageutils.pseudo_flat_field_correction(image, sigma)
esmraldi.imageutils.get_norm_image(images, norm, mzs)
esmraldi.imageutils.normalize_image(current_image, norm_img)
esmraldi.imageutils.distance_point_to_set(point, point_set)
esmraldi.imageutils.rectangle_coordinates(lower_left, upper_right)