HAPPY.image_processing module
- HAPPY.image_processing.nan_gaussian(image, sigma)[source]
Apply a gaussian filter to an array with nans.
- Parameters
image (array) – an array with nans
sigma (float) – σ is the standard deviation of the Gaussian distribution
- Returns
gauss – The Gaussian-filtered input image, with nan entries ignored.
- Return type
array, same shape as image
- HAPPY.image_processing.minimize_grain_contrast(image, sigma)[source]
Minimise grain contrast or uneven lighting.
This is accomplished by dividing the original image by an image with a gaussian blur applied.
- Parameters
image (array) – Image to minimise grain contrast.
sigma (float) – Sigma value for gaussian blur.
- Returns
removed_grains – Output image.
- Return type
array, same shape as image
- HAPPY.image_processing.simple_threshold(image, scale_um, crop_threshold, threshold, small_obj=None)[source]
Threshold the image, accounting for crop and small features.
Hydrides are assumed to be dark (value below the threshold) in the input image, but are returned as bright (1.0) features in the output, and vice- -versa for the matrix.
- Parameters
removed_grains (array) – image to threshold.
crop_threshold (array of bool) – Thresholding is only performed within regions labeled False in this array. Values labeled True will be set to np.nan in the output
scale_um (int) – Scale bar value in microns
theshold (float) – threshold level.
small_obj (int, optional) – size of features to be removed and not thresholded in microns
- Returns
thres_disp – The thresholded image, with 1.0 in foreground pixels, 0.0 in background pixels, and np.nan in cropped pixels.
- Return type
array of float