affine.image2d¶
Module: affine.image2d
¶
Inheritance diagram for regreg.affine.image2d
:
Class¶
image2d_differences
¶
-
class
regreg.affine.image2d.
image2d_differences
(image_shape, affine_offset=None)¶ Bases:
regreg.affine.affine_transform
-
__init__
(image_shape, affine_offset=None)¶ Create affine transform
- Parameters
linear_operator : None or ndarray or sparse array or affine_transform
Linear part of affine transform implemented as array or as affine_transform. None results in no linear component.
affine_offset : None or ndarray
offset component of affine. Only one of linear_operator and affine_offset can be None, because we need an input array to define the shape of the transform.
diag : {False, True}, optional
If True, interpret 1D linear_operator as the main diagonal of the a diagonal array, so that
linear_operator = np.diag(linear_operator)
-
property
T
¶
-
adjoint_map
(u, copy=True)¶ Apply adjioint of transform to u
Return \(D^Tu\)
- Parameters
u : ndarray
array to which to apply transform. Can be 1D or 2D
copy : {True, False}, optional
If True, in situations where return is identical to ``, ensure returned value is a copy.
- Returns
D.T*u : ndarray
u transformed with linear component
-
affine_map
(x, copy=True)¶ Apply linear part of transform to x
Return \(Dx+\alpha\)
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
copy : {True, False}, optional
If True, in situations where return is identical to x, ensure returned value is a copy.
- Returns
Dx + offset: ndarray
x transformed with linear component + offset
-
dot
(x)¶ Apply linear part of transform to x. Returns self.linear_map(x) unless x is a transform, in which case it returns the composition.
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
- Returns
Dx : ndarray
x transformed with linear component
-
linear_map
(x, copy=True)¶ Apply linear part of transform to x
Return \(Dx\)
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
copy : {True, False}, optional
If True, in situations where return is identical to x, ensure returned value is a copy.
- Returns
Dx : ndarray
x transformed with linear component
-
property
ndim
¶
-
property
shape
¶
-
Functions¶
-
regreg.affine.image2d.
formD
(m, n)¶ Generate a sparse matrix that computes the difference across all edges in a 2D lattice of shape (m,n).
- Parameters
m: int
n: int
- Returns
D: scipy.csr_matrix
A matrix with 2*(m*n-1) and m*n columns representing each edge exactly once in the 2D lattice and including some zero rows.
This shape is used because it associates exactly two edges to each vertex except the top right. Hence, the differences can be formed into a matrix with two rows to which the l1_l2 proximal function can be applied.
The first (m-1)*(n-1) rows represent interior vertices, then the right hand edges and finally the top edges with the origin in the bottom left. This forms the first row of this two row matrix described above.
The second row of the matrix has exactly the same structure.
-
regreg.affine.image2d.
formD_smaller
(m, n)¶ Generate a sparse matrix that computes the difference across all edges in a 2D lattice of shape (m,n).
- Parameters
m: int
n: int
- Returns
D: scipy.csr_matrix
A matrix with 2*(m-1)*(n-1)+(m-1)+(n-1) rows and m*n columns representing each edge exactly once in the 2D lattice.
The first 2*(m-1)*(n-1) rows represent interior vertices, then the right hand edges and finally the top edges with the origin in the bottom left.