public class EigenTensors2 extends java.lang.Object implements Tensors2
A = |a11 a12|
|a12 a22|
Such tensors can be used to parameterize anisotropic image processing.
The eigen-decomposition of the matrix A is
A = au*u*u' + av*v*v'
= (au-av)*u*u' + av*I
where u and v are orthogonal unit eigenvectors of A. (The notation u'
denotes the transpose of u.) The outer products of eigenvectors are
scaled by the non-negative eigenvalues au and av. The second equation
exploits the identity u*u' + v*v' = I, and makes apparent the redundancy
of the vector v.Constructor and Description |
---|
EigenTensors2(EigenTensors2 t)
Constructs tensors from the specified tensors.
|
EigenTensors2(float[][] u1,
float[][] u2,
float[][] au,
float[][] av)
Constructs tensors for specified array dimensions and eigenvalues.
|
EigenTensors2(int n1,
int n2)
Constructs tensors for specified array dimensions.
|
Modifier and Type | Method and Description |
---|---|
void |
getEigenvalues(float[][] au,
float[][] av)
Gets eigenvalues for all tensors.
|
float[] |
getEigenvalues(int i1,
int i2)
Gets eigenvalues for the tensor with specified indices.
|
void |
getEigenvalues(int i1,
int i2,
float[] a)
Gets eigenvalues for the tensor with specified indices.
|
float[] |
getEigenvectorU(int i1,
int i2)
Gets the eigenvector u for the tensor with specified indices.
|
void |
getEigenvectorU(int i1,
int i2,
float[] u)
Gets the eigenvector u for the tensor with specified indices.
|
float[] |
getEigenvectorV(int i1,
int i2)
Gets the eigenvector v for the tensor with specified indices.
|
void |
getEigenvectorV(int i1,
int i2,
float[] v)
Gets the eigenvector v for the tensor with specified indices.
|
int |
getN1()
Gets the number of tensors in the 1st dimension.
|
int |
getN2()
Gets the number of tensors in the 2nd dimension.
|
float[] |
getTensor(int i1,
int i2)
Gets tensor elements for specified indices.
|
void |
getTensor(int i1,
int i2,
float[] a)
Gets tensor elements for specified indices.
|
void |
invert()
Inverts these tensors by inverting their eigenvalues.
|
void |
invertStructure(double p0,
double p1)
Inverts these tensors, assumed to be structure tensors.
|
void |
scale(float[][] s)
Scales eigenvalues of these tensors by specified factors.
|
void |
setEigenvalues(float[][] au,
float[][] av)
Sets eigenvalues for all tensors.
|
void |
setEigenvalues(float au,
float av)
Sets eigenvalues for all tensors.
|
void |
setEigenvalues(int i1,
int i2,
float[] a)
Sets eigenvalues for the tensor with specified indices.
|
void |
setEigenvalues(int i1,
int i2,
float au,
float av)
Sets eigenvalues for the tensor with specified indices.
|
void |
setEigenvectorU(int i1,
int i2,
float[] u)
Sets the eigenvector u for the tensor with specified indices.
|
void |
setEigenvectorU(int i1,
int i2,
float u1,
float u2)
Sets the eigenvector u for the tensor with specified indices.
|
void |
setTensor(int i1,
int i2,
float[] a)
Sets tensor elements for specified indices.
|
void |
setTensor(int i1,
int i2,
float a11,
float a12,
float a22)
Sets tensor elements for specified indices.
|
public EigenTensors2(int n1, int n2)
n1
- number of tensors in 1st dimension.n2
- number of tensors in 2nd dimension.public EigenTensors2(float[][] u1, float[][] u2, float[][] au, float[][] av)
u1
- array of 1st components of u.u2
- array of 2nd components of u.au
- array of 1D eigenvalues.av
- array of 2D eigenvalues.public EigenTensors2(EigenTensors2 t)
t
- the tensors from which to copy eigenvectors and eigenvalues.public int getN1()
public int getN2()
public void getTensor(int i1, int i2, float[] a)
public float[] getTensor(int i1, int i2)
i1
- index for 1st dimension.i2
- index for 2nd dimension.public void getEigenvalues(int i1, int i2, float[] a)
i1
- index for 1st dimension.i2
- index for 2nd dimension.a
- array {au,av} of eigenvalues.public float[] getEigenvalues(int i1, int i2)
i1
- index for 1st dimension.i2
- index for 2nd dimension.public void getEigenvalues(float[][] au, float[][] av)
au
- array of eigenvalues au.av
- array of eigenvalues av.public void getEigenvectorU(int i1, int i2, float[] u)
i1
- index for 1st dimension.i2
- index for 2nd dimension.u
- array {u1,u2} of eigenvector components.public float[] getEigenvectorU(int i1, int i2)
i1
- index for 1st dimension.i2
- index for 2nd dimension.public void getEigenvectorV(int i1, int i2, float[] v)
i1
- index for 1st dimension.i2
- index for 2nd dimension.v
- array {v1,v2} of eigenvector components.public float[] getEigenvectorV(int i1, int i2)
i1
- index for 1st dimension.i2
- index for 2nd dimension.public void setTensor(int i1, int i2, float[] a)
i1
- index for 1st dimension.i2
- index for 2nd dimension.a
- array {a11,a12,a22} of tensor elements.public void setTensor(int i1, int i2, float a11, float a12, float a22)
i1
- index for 1st dimension.i2
- index for 2nd dimension.a11
- tensor element a11.a12
- tensor element a12.a22
- tensor element a22.public void setEigenvalues(float au, float av)
au
- eigenvalue au.av
- eigenvalue av.public void setEigenvalues(int i1, int i2, float au, float av)
i1
- index for 1st dimension.i2
- index for 2nd dimension.au
- eigenvalue au.av
- eigenvalue av.public void setEigenvalues(int i1, int i2, float[] a)
i1
- index for 1st dimension.i2
- index for 2nd dimension.a
- array {au,av} of eigenvalues.public void setEigenvalues(float[][] au, float[][] av)
au
- array of eigenvalues au.av
- array of eigenvalues av.public void setEigenvectorU(int i1, int i2, float u1, float u2)
i1
- index for 1st dimension.i2
- index for 2nd dimension.u1
- 1st component of u.u2
- 2nd component of u.public void setEigenvectorU(int i1, int i2, float[] u)
i1
- index for 1st dimension.i2
- index for 2nd dimension.u
- {u1,u2} of eigenvector components.public void scale(float[][] s)
s
- array of scale factors.public void invert()
public void invertStructure(double p0, double p1)
Before inversion, tensors are assumed to be structure tensors,
for which eigenvalues au are not less than their corresponding
eigenvalues av. (Any eigenvalues au for which this condition is
not satisfied are set equal to the corresponding eigenvalue av.)
Structure tensors can, for example, be computed using
LocalOrientFilter
.
Then, if any eigenvalues are equal to zero, this method adds a small fraction of the largest eigenvalue au to all eigenvalues. If am is the minimum of the eigenvalues av after this perturbation, then the parameter p0 is used to compute a0 = pow(am/av,p0) and the parameter p1 is used to compute a1 = pow(av/au,p1). Inverted eigenvalues are then au = a0*a1 and av = a0.
In this way, p0 emphasizes overall amplitude and p1 emphasizes linearity. For amplitude-independent tensors with all eigenvalues av equal to one, set p0 = 0.0. To enhance linearity, set p1 > 1.0. To simply invert (and normalize) these tensors, set p0 = p1 = 1.0.
p0
- power for amplitude.p1
- power for linearity.