improutils.filtration package
Submodules
improutils.filtration.filtration module
- improutils.filtration.filtration.apply_fft(image)[source]
Apply FFT on the image.
- Parameters:
image (2D array) – Image to perform FFT on.
- Returns:
mag_spec (2D array) – Normalized magnitude spectrum.
fftcls_shift (2D array) – Centered product of FFT.
- improutils.filtration.filtration.create_filter_mask(size, rows, columns)[source]
Create a filter mask specified by rows and columns.
Specified rows and columns are set to 255, others 0.
- Parameters:
size (tuple of int) – Tuple of two integers (height, width) defining the dimensions of the output mask.
rows (array-like of int) – Indices of rows to set to 255.
columns (array-like of int) – Indices of columns to set to 255.
- Returns:
filter_mask – 2D array mask containing 255 and 0 values.
- Return type:
2D array
- Raises:
TypeError – If size is not a tuple with 2 int values.
- improutils.filtration.filtration.filter_mag_spec(mag_spec, filter_mask)[source]
Filter input spectrum using filter_mask image.
- Parameters:
mag_spec (2D ndarray) – Image with magnitude spectrum.
filter_mask (2D array) – Filter binary mask image containing values to keep (255) and filter out (0).
- Returns:
result – Vizualization of spectrum after filtering.
- Return type:
2D ndarray
- improutils.filtration.filtration.filtration_box(img, filter_size)[source]
Filter image noise using box blur algorithm.
- Parameters:
img (numpy.ndarray) – Input image.
filter_size (int) – Size of box blur filter.
- Return type:
Output image.
- improutils.filtration.filtration.filtration_gauss(img, filter_size, sigma_x)[source]
Filter image noise using Gaussian blur algorithm.
- Parameters:
img (numpy.ndarray) – Input image.
filter_size (int) – Size of Gaussian filter.
sigma_x (float) – Gaussian kernel standard deviation in the X direction.
- Return type:
Output image.
Module contents
- improutils.filtration.apply_fft(image)[source]
Apply FFT on the image.
- Parameters:
image (2D array) – Image to perform FFT on.
- Returns:
mag_spec (2D array) – Normalized magnitude spectrum.
fftcls_shift (2D array) – Centered product of FFT.
- improutils.filtration.create_filter_mask(size, rows, columns)[source]
Create a filter mask specified by rows and columns.
Specified rows and columns are set to 255, others 0.
- Parameters:
size (tuple of int) – Tuple of two integers (height, width) defining the dimensions of the output mask.
rows (array-like of int) – Indices of rows to set to 255.
columns (array-like of int) – Indices of columns to set to 255.
- Returns:
filter_mask – 2D array mask containing 255 and 0 values.
- Return type:
2D array
- Raises:
TypeError – If size is not a tuple with 2 int values.
- improutils.filtration.filter_mag_spec(mag_spec, filter_mask)[source]
Filter input spectrum using filter_mask image.
- Parameters:
mag_spec (2D ndarray) – Image with magnitude spectrum.
filter_mask (2D array) – Filter binary mask image containing values to keep (255) and filter out (0).
- Returns:
result – Vizualization of spectrum after filtering.
- Return type:
2D ndarray
- improutils.filtration.filtration_box(img, filter_size)[source]
Filter image noise using box blur algorithm.
- Parameters:
img (numpy.ndarray) – Input image.
filter_size (int) – Size of box blur filter.
- Return type:
Output image.
- improutils.filtration.filtration_gauss(img, filter_size, sigma_x)[source]
Filter image noise using Gaussian blur algorithm.
- Parameters:
img (numpy.ndarray) – Input image.
filter_size (int) – Size of Gaussian filter.
sigma_x (float) – Gaussian kernel standard deviation in the X direction.
- Return type:
Output image.
- improutils.filtration.filtration_median(img, filter_size)[source]
Filter image noise using median blur algorithm.
- Parameters:
img (numpy.ndarray) – Input image.
filter_size (int) – Odd number - size of median filter.
- Return type:
Output image.
- improutils.filtration.inverse_fft(fft_shift, filter_mask=None)[source]
Apply inverse FFT.
- Parameters:
fft_shift (2D array) – Shifted computed FFT
filter_mask (2D array) – 2D array mask containing 255 and 0 values.
- Returns:
img_back – Image made by inverse FFT.
- Return type:
2D array