2.1.2.1.1. sf_tools.image.convolve module¶
CONVOLUTION ROUTINES
This module contains methods for convolution.
Author: | Samuel Farrens <samuel.farrens@gmail.com> |
---|---|
Version: | 1.2 |
Date: | 23/10/2017 |
-
sf_tools.image.convolve.
convolve_np
(image, kernel)[source]¶ Convolve with Numpy FFT
This method convolves the input image with the input kernel
Parameters: - image (np.ndarray) – 2D image array
- kernel (np.ndarray) – 2D kernel array
Returns: Return type: np.ndarray 2D convolved image array
-
sf_tools.image.convolve.
deconvolve_np
(image, kernel)[source]¶ Deconvolve with Numpy FFT
This method deconvolves the input image with the input kernel
Parameters: - image (np.ndarray) – 2D image array
- kernel (np.ndarray) – 2D kernel array
Returns: Return type: np.ndarray 2D deconvolved image array
-
sf_tools.image.convolve.
convolve
(data, kernel, method='astropy')[source]¶ Convolve data with kernel
This method convolves the input data with a given kernel using FFT and is the default convolution used for all routines
Parameters: - data (np.ndarray) – Input data array, normally a 2D image
- kernel (np.ndarray) – Input kernel array, normally a 2D kernel
- method (str {'astropy', 'scipy'}, optional) –
Convolution method (default is ‘astropy’)
- ’astropy’:
- Uses the astropy.convolution.convolve_fft method provided in Astropy (http://www.astropy.org/)
- ’scipy’:
- Uses the scipy.signal.fftconvolve method provided in SciPy (https://www.scipy.org/)
Returns: Return type: np.ndarray convolved data
Raises: ValueError
– If data and kernel do not have the same number of dimensionsValueError
– If method is not ‘astropy’ or ‘scipy’
-
sf_tools.image.convolve.
convolve_stack
(data, kernel, rot_kernel=False, method='astropy')[source]¶ Convolve stack of data with stack of kernels
This method convolves the input data with a given kernel using FFT and is the default convolution used for all routines
Parameters: - data (np.ndarray) – Input data array, normally a 2D image
- kernel (np.ndarray) – Input kernel array, normally a 2D kernel
- rot_kernel (bool) – Option to rotate kernels by 180 degrees
- method (str {'astropy', 'scipy'}, optional) – Convolution method (default is ‘astropy’)
Returns: Return type: np.ndarray convolved data
-
sf_tools.image.convolve.
psf_convolve
(data, psf, psf_rot=False, psf_type='fixed', method='astropy')[source]¶ Convolve data with PSF
This method convolves an image with a PSF
Parameters: - data (np.ndarray) – Input data array, normally an array of 2D images
- psf (np.ndarray) – Input PSF array, normally either a single 2D PSF or an array of 2D PSFs
- psf_rot (bool) – Option to rotate PSF by 180 degrees
- psf_type (str {'fixed', 'obj_var'}, optional) – PSF type (default is ‘fixed’)
- method (str {'astropy', 'scipy'}, optional) –
Convolution method (default is ‘astropy’)
- ’fixed’:
- The PSF is fixed, i.e. it is the same for each image
- ’obj_var’:
- The PSF is object variant, i.e. it is different for each image
Returns: Return type: np.ndarray convolved data
Raises: ValueError
– If psf_type is not ‘fixed’ or ‘obj_var’
-
sf_tools.image.convolve.
pseudo_inverse
(image, kernel, weight=None)[source]¶ Pseudo inverse
This method calculates the pseudo inverse of the input image for the given kernel using FFT
Parameters: - image (np.ndarray) – Input image, 2D array
- kernel (np.ndarray) – Input kernel, 2D array
- weight (np.ndarray, optional) – Optional weights, 2D array
Returns: Return type: np.ndarray result of the pseudo inverse