colourlab.image_core module¶
image_core: Colour image core operations, part of the colourlab package
For image processing operations that are applied directly to ndarrays. To be used by the colour-space-specific methods in colour.image.Image.
Copyright (C) 2017-2021 Ivar Farup
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
-
colourlab.image_core.correlate(im, filter)[source]¶ Correlation filter for multi-channel image with symmetric boundaries.
- im : ndarray
- M x N x C image
filter : ndarray
-
colourlab.image_core.diffusion_tensor_from_structure(s_tuple, dpsi_dlambda1=None, dpsi_dlambda2=None)[source]¶ Compute the diffusion tensor coefficients from the structure tensor parameters
Parameters: - s_tuple (tuple) – The resulting tuple from a call to image.structure_tensor
- dpsi_dlambda1 (func) – The diffusion supression function for the first eigenvalue of the structure tensor. If None, use Perona and Malik’s inverse square with default value from image_core.
- dpsi_dlambda2 (func) – Same for the second eigenvalue. If None use dpsi_dlambda1
Returns: - d11 (ndarray) – The d11 component of the structure tensor of the image data.
- d12 (ndarray) – The d12 component of the structure tensor of the image data.
- d22 (ndarray) – The d22 component of the structure tensor of the image data.
-
colourlab.image_core.divergence(imi, imj, diff=(array([[ 0. , -0.5, 0. ], [ 0. , 0. , 0. ], [ 0. , 0.5, 0. ]]), array([[ 0. , 0. , 0. ], [-0.5, 0. , 0.5], [ 0. , 0. , 0. ]])))[source]¶ Compute the divergence of the image components with the given filters.
Parameters: - imi (ndarray) – M x N x C image
- imj (ndarray) – M x N x C image
- diff (tuple) – Tuple with the two gradient filters
Returns: ndarray
Return type: div(imi, imj)
-
colourlab.image_core.dpdl_perona_exp(lambd, kappa=0.01)[source]¶ Perona and Malik’s exponential diffusion supression
Name suggest dpsi/dlambda
Parameters: - lambd (ndimage) – Eigenvalue of the structure tensor (single channelimage)
- kappa (float) – Paramter
Returns: ndimage
Return type: dpsi / dlambda
-
colourlab.image_core.dpdl_perona_invsq(lambd, kappa=0.01)[source]¶ Perona and Malik’s inverse square diffusion supression
Name suggest dpsi/dlambda = 1 / (1 + lambd / kappa^2)
Parameters: - lambd (ndimage) – Eigenvalue of the structure tensor (single channelimage)
- kappa (float) – Paramter
- = 1 / (1 + lambd / kappa**2) (Returns) –
- ------- –
- ndimage (dpsi / dlambda) –
-
colourlab.image_core.dpdl_tv(lambd, epsilon=0.0001)[source]¶ Total variation diffusion supression
Name suggest dpsi/dlambda = 1 / sqrt(lambd + epsilon)
Parameters: - lambd (ndimage) – Eigenvalue of the structure tensor (single channelimage)
- epsilon (float) – Regularisation paramter
Returns: ndimage
Return type: dpsi / dlambda
-
colourlab.image_core.gradient(im, diff=(array([[ 0. , -0.5, 0. ], [ 0. , 0. , 0. ], [ 0. , 0.5, 0. ]]), array([[ 0. , 0. , 0. ], [-0.5, 0. , 0.5], [ 0. , 0. , 0. ]])))[source]¶ Compute the gradient of the image with the given filters.
Parameters: - im (ndarray) – M x N x C image
- diff (tuple) – Tuple with the two gradient filters
Returns: - ndarray (d im / di)
- ndarray (d im / dj)
-
colourlab.image_core.stress(im, ns=3, nit=5, R=0)[source]¶ Compute the stress image and range for a multi-channel image.
Parameters: - im (ndarray) – Multi-channel image
- ns (int) – Number of sample points
- nit (int) – Number of iterations
- R (int) – Maximum radius. If R=0, the diagonal of the image is used.
Returns: - stress_im (ndarray) – The result of stress
- range_im (ndarray) – The range image (see paper)