Code
Contents
Show code cell content
import mmf_setup;mmf_setup.nbinit()
import logging;logging.getLogger('matplotlib').setLevel(logging.CRITICAL)
%matplotlib inline
import numpy as np, matplotlib.pyplot as plt
This cell adds /home/docs/checkouts/readthedocs.org/user_builds/iscimath-583-learning-from-signals/checkouts/latest/src to your path, and contains some definitions for equations and some CSS for styling the notebook. If things look a bit strange, please try the following:
- Choose "Trust Notebook" from the "File" menu.
- Re-execute this cell.
- Reload the notebook.
Code#
Here we describe the various tools implemented in the math_583 package.
math_583#
The module provides the following classes:
Math 583 - Learning from Signals
This package contains source code for the Spring 2023 offering of Math 583: iSciMath - Learning from Images and Signals: Theory and Computation at Washington State University (WSU).
math_583.denoise#
This module provides tools to denoise images based on the following model:
Minimizing is equivalent to solving:
A direct approach to the minimization procedure is given by Denoise.minimize()
which uses scipy.optimize.minimize() and the L-BFGS-B method). Minimization is not the fastest, but is quite
general, and be directly applied to more complicated methods.
Details about anti-symmetric derivatives \(\mat{D}^T = - \mat{D}\).
In order to obtain the expression for \(E'[u]\), we need to compute
which appears in the first integral after the chain rule is applied. Noting that \(\vect{\nabla}\) is a linear operator, we will have a matrix representation \(\vect{\mat{D}}_{ac}\) such that
When included in the integral with an additional factor \(f_{a} = \bigl(\abs{\vect{\nabla}u}^2 + ϵ_p\bigr)^{(p-2)/2}_{a}\) we end up with
iff the matrix representations of the derivatives are anti-symmetric
Alternatively, the outer derivative must be computed using the transpose of the original derivative matrix as in the explicit formula. Note: In the above, we have not consider complex values. Similar formulae apply with appropriate complex conjugations applied.
A faster approach is provided by Denoise.solve(), which directly solves the
minimization condition using Fourier Techniques.
Tools for exploring image denoising.
- subplots(cols=1, rows=1, height=3, aspect=1, **kw)[source]#
More convenient subplots that automatically sets the figsize.
- Parameters
cols (int) – Number of columns and rows in the figure.
rows (int) – Number of columns and rows in the figure.
height (float) – Height of an individual element. Unless specified, the figure size will be
figsize=(cols * height * aspect, rows * height).aspect (float) – Aspect ratio of each figure (width/height).
**kw (dict) – Other arguments are passed to
plt.subplot()
- class Image(data=None, **kw)[source]#
Class to load and process images.
- data#
If provided, then this is used as the image data. If the first dimension has length 3 or 4, then it is assumed to be RGB or RGBA data respectively. If the dtype is np.uint8, then it is unconverted, otherwise, it is normalized using the default colormap.
- Type
array_like | None
- dir#
Directory with images.
- Type
Path
- property rgb#
Return the RGB form of the image.
- class Denoise(image=None, **kw)[source]#
Class for denoising images.
- lam#
Parameter λ controlling the regularization. Larger values will produce an image closer to the target. Smaller values will produce smoother images.
- Type
- p, q
Powers in the regularization term and the data fidelity terms respectively.
- Type
- use_shortcuts#
If True, then use specialized shortcuts where applicable, otherwise use the general code.
- Type
- eps_p, eps_q
Regularization constants for the regularization term and the data fidelity terms respectively.
- Type
- derivative1d(input, axis=- 1, output=None, mode=None, cval=0.0, kind='forward', compute=False, transpose=False)[source]#
Return the difference of input along the specified axis.
This is intended to be used as the derivative function in various scipy.ndimage routines.
- Parameters
kind ('forward', 'backward', 'centered') –
transpose (Bool) – If True, then apply the negative transpose of the derivative operator.
- gradient(u, real=True)[source]#
Return the gradient of u.
- Parameters
real (bool) – If True, then return only the real part. It is important to set this to False if computing the Laplacian as divergence(gradient(u)) for example. Only applies for mode == “periodic”.