Image_Analysis.Image_Processing

class Image_Analysis.Image_Processing(image, skeleton, spacing, viewer)

Bases: object

A class that will perform image processing operations.

image: ndarray

an image to be processed

skeleton: ndarray

the skeleton of the image to be processed

spacing: float

the z spacing of the image

viewer: napari.viewer

the viewer to be used to view the image layers in 3D

skeleton_dilation(dilation=10)

Dilates the skeleton of the image as many times as you indicate. Crops the image to only the region of interest

get_cropped()

returns the cropped image

median_filter(image, cube_width)

Performs the median filter operation from skimage on the image passed. Uses the cube width provided.

background_subtract(image, gauss_sigma)

Subtracts the background from the passed in image. Uses the gaussian filter from skimage on the image passed in.

sobel(image)

Performs the sobel transformation on the passed in image using the sobel filter from skimage

ahe_contrast(image)

Performs the adaptive histogram equalization on the passed in image using the equalize_adapthist from skimage. Multiplies the image to the image passed in to improve the contrast

rescaled_intensity(image, vmin, vmax)

Performs the rescale intensity operation on the passed in image using the operation from skimage

multiotsu_mask(image, classes)

Performs the multiotsu mask operation using threshold_multiots from skimage using the number of classes specified

otsu_mask(image)

Performs the otsu mask operation using threshold_otsu from skimage

li_mask(image)

Performs the li mask operation using threshold_li from skimage

yen_mask(image)

Performs the yen mask operation using threshold_yen from skimage

default_morphology(image)

Uses a default morphology operation consisting of closing and dilation morphological operations.

closing(image)

Performs the closing operation on the provided mask

opening(image)

Performs the opening operation on the provided mask

dilation(image)

Performs the dilation operation on the provided mask

erosion(image)

Performs the erosion operation on the provided mask

labels(image)

Generates labels based on the mask created

region_props(labels, intensity_image, properties)

Generates the region properties from the labels depending on the properties selected

__init__(image, skeleton, spacing, viewer)
imagendarray

The image to use for analysis

skeletonndarray

The binary image used to identify the area of interest of the image

spacingfloat

The z spacing of the images being passed

viewernapari viewer

The viewer to use for visualization of the images

Methods

__init__(image, skeleton, spacing, viewer)

Parameters image ndarray The image to use for analysis skeleton ndarray The binary image used to identify the area of interest of the image spacing float The z spacing of the images being passed viewer napari viewer The viewer to use for visualization of the images

ahe_contrast([image])

Performs the adaptive histogram equalization operation and multiplies the provided image and the AHE image

background_subtract([image, gauss_sigma])

Subtracts the background from the image provided

closing([mask])

Performs the closing morphology operation from skimage

default_morphology()

Performs the default morphology operations: Binary Dilation and Binary Closing from skimage

dilation([mask])

Performs the dilation morphology operation from skimage

erosion([mask])

Performs the erosion morphology operation from skimage

get_cropped()

Returns the cropped image used in the analysis.

labels([mask])

Generates labels based on the provided mask

li_mask([image])

Performs the li mask operation from skimage

median_filter([image, cube_width])

Performs the median filter operation from skimage on the image passed.

multiotsu_mask([image, classes])

Performs the multiotsu mask operation from skimage

opening([mask])

Performs the opening morphology operation from skimage

otsu_mask([image])

Performs the otsu mask operation from skimage

region_props(labels, intensity_image, properties)

Generates a dictionary of properties requested for the labels provided

rescaled_intensity([image, vmin, vmax])

Rescales the intensity of the image using the intensities provided

skeleton_dilation([dilation])

Dilates the skeleton provide.

sobel([image, mask])

Performs the sobel transformation on a given image

yen_mask([image])

Performs the yen mask operation

ahe_contrast(image=None)

Performs the adaptive histogram equalization operation and multiplies the provided image and the AHE image

imagendarray

The image to apply the operation to

final_contrast

An ndarray of of the same size as the input after the AHE and multiplication operations have been applied

background_subtract(image=None, gauss_sigma=7)

Subtracts the background from the image provided

If the argument gauss_sigma isn’t provided, the default value of 7 is passed.

imagendarray

The image to apply the operation to

gauss_sigmaint, optional

The sigma used for the gaussian operation (default is 7)

subtract

The image with the same shape as the input image after the subtraction has been applied

closing(mask=None)

Performs the closing morphology operation from skimage

maskndarray

The mask to perform the morph operation on

mask_morph

The final mask of type ndarray after the morphology operation is performed

default_morphology()

Performs the default morphology operations: Binary Dilation and Binary Closing from skimage

mask_closing

an array of the same shape as the input image. The final mask after the morphology operations are performed

final_mask

an array of the same shape as the input image. The final mask isolated only to the area within the skeleton

dilation(mask=None)

Performs the dilation morphology operation from skimage

maskndarray

The mask to perform the morph operation on

mask_morph

The final mask of type ndarray after the morphology operation is performed

erosion(mask=None)

Performs the erosion morphology operation from skimage

maskndarray

The mask to perform the morph operation on

mask_morph

The final mask of type ndarray after the morphology operation is performed

get_cropped()

Returns the cropped image used in the analysis.

labels(mask=None)

Generates labels based on the provided mask

maskndarray

The mask to perform the morph operation on

boundaries

an array of the same shape as the input

label_image

an array with labels of the same shape as the input. All connected areas are under one label

li_mask(image=None)

Performs the li mask operation from skimage

imagendarray

The image to apply the operation to

mask_morph

an array with the same shaqpe as the input after the mask has been applied

median_filter(image=None, cube_width=3)

Performs the median filter operation from skimage on the image passed.

If the argument cube_width isn’t provided, the default value of 3 is passed.

imagendarray

The image to apply the operation to

cube_widthint, optional

The width of the cube used as the footprint for the filter (default is 3)

median

The image after the median filter has been applied

multiotsu_mask(image=None, classes=2)

Performs the multiotsu mask operation from skimage

If the argument classes isn’t provided, the default value of 2 is passed.

imagendarray

The image to apply the operation to

classesint, optional

The number of classes in the image (default is 2)

mask_morph

an array with the same shaqpe as the input after the mask has been applied

opening(mask=None)

Performs the opening morphology operation from skimage

maskndarray

The mask to perform the morph operation on

mask_morph

The final mask of type ndarray after the morphology operation is performed

otsu_mask(image=None)

Performs the otsu mask operation from skimage

imagendarray

The image to apply the operation to

mask_morph

an array with the same shaqpe as the input after the mask has been applied

region_props(labels, intensity_image, properties)

Generates a dictionary of properties requested for the labels provided

labelsndarray

The labeled image to generate the properties for

intensity_imagendarray

The image to reference intensity values for

propertieslist

A list of strings with the properties desired

props

a dictionary with the properties generated for each label

rescaled_intensity(image=None, vmin=0.5, vmax=99.5)

Rescales the intensity of the image using the intensities provided

If the arguments vmin and vmax aren’t provided, the default values of 0 and 255 are passed.

imagendarray

The image to apply the operation to

vminint, optional

The minimum intensity value allowed for the image (default is 0)

vmaxint, optional

The maximum intensity value allowed for the image (default is 255)

final_contrast

An ndarray of of the same size as the input after the rescaled intensity operation has been applied

skeleton_dilation(dilation=10)

Dilates the skeleton provide.

If the argument dilation isn’t passed in, the default dilation value is used. Crops the image to be analyzed to keep the image size small.

dilationint, optional

The amount of dilation applied to the skeleton (default is 10)

ROI

An array for the cropped image with the dimensions of the skeleton

cropped_skeleton

An array for the cropped skeleton with the size of the skeleton

sobel(image=None, mask=None)

Performs the sobel transformation on a given image

If the argument mask isn’t provided, the mask will not be used.

imagendarray

The image to apply the operation to

maskndarray, optional

mask to isolate the sobel filter to (default is None)

sobel

The image of same shape as the input after the sobel filter has been applied

yen_mask(image=None)

Performs the yen mask operation

imagendarray

The image to apply the operation to

mask_morph

an array with the same shaqpe as the input after the mask has been applied