use of mcib3d.Jama.EigenvalueDecomposition in project mcib3d-core by mcib3d.
the class Object3D method computeEigen.
/**
* Constructor for the computeEigen object
*/
protected void computeEigen() {
if (eigen == null) {
Matrix mat = new Matrix(3, 3);
if (Double.isNaN(s200)) {
computeMoments2(true);
}
mat.set(0, 0, s200);
mat.set(0, 1, s110);
mat.set(0, 2, s101);
mat.set(1, 0, s110);
mat.set(1, 1, s020);
mat.set(1, 2, s011);
mat.set(2, 0, s101);
mat.set(2, 1, s011);
mat.set(2, 2, s002);
eigen = new EigenvalueDecomposition(mat);
}
}
use of mcib3d.Jama.EigenvalueDecomposition in project mcib3d-core by mcib3d.
the class IntImage3D method computeHessianDerivative.
/**
* compute the hessian derivative (to validate)
*
* @param value (0=energy 1=coherence)
* @return the hessian image
*/
public RealImage3D computeHessianDerivative(int value) {
RealImage3D res = new RealImage3D(getSizex(), getSizey(), getSizez());
IntImage3D gx = this.gradient(XAXIS);
IntImage3D gy = this.gradient(YAXIS);
IntImage3D gz = this.gradient(ZAXIS);
IntImage3D gxx = gx.gradient(XAXIS);
IntImage3D gxy = gx.gradient(YAXIS);
IntImage3D gxz = gx.gradient(ZAXIS);
IntImage3D gyy = gy.gradient(YAXIS);
IntImage3D gyz = gy.gradient(ZAXIS);
IntImage3D gzz = gz.gradient(ZAXIS);
Matrix mat = new Matrix(3, 3);
EigenvalueDecomposition eigen;
double[] lambda = new double[3];
double l1, l2, l3, lmin, lmax;
double C, E;
int pgxx, pgxy, pgxz, pgyy, pgyz, pgzz;
for (int z = 0; z < getSizez(); z++) {
for (int y = 0; y < getSizey(); y++) {
for (int x = 0; x < getSizex(); x++) {
pgxx = gxx.getPixel(x, y, z);
pgxy = gxy.getPixel(x, y, z);
pgxz = gxz.getPixel(x, y, z);
pgyy = gyy.getPixel(x, y, z);
pgyz = gyz.getPixel(x, y, z);
pgzz = gzz.getPixel(x, y, z);
mat.set(0, 0, pgxx);
mat.set(0, 1, pgxy);
mat.set(0, 2, pgxz);
mat.set(1, 0, pgxy);
mat.set(1, 1, pgyy);
mat.set(1, 2, pgyz);
mat.set(2, 0, pgxz);
mat.set(2, 1, pgyz);
mat.set(2, 2, pgzz);
eigen = new EigenvalueDecomposition(mat);
lambda = eigen.getRealEigenvalues();
l1 = lambda[0];
l2 = lambda[1];
l3 = lambda[2];
// energy L1+L2+L3
E = l1 + l2 + l3;
// coherence (Lmax-Lmin)/(Lmax+Lmin);
lmin = Math.min(l1, Math.min(l2, l3));
lmax = Math.max(l1, Math.max(l2, l3));
C = (lmax - lmin) / (lmax + lmin);
if (value == 0) {
res.putPixel(x, y, z, E);
} else {
res.putPixel(x, y, z, C);
}
}
}
}
return res;
}
use of mcib3d.Jama.EigenvalueDecomposition in project mcib3d-core by mcib3d.
the class MeasureEllipsoid method computeAll.
@Override
protected void computeAll() {
Matrix mat = new Matrix(3, 3);
MeasureCentroid centroid = new MeasureCentroid(object3DInt);
Double[] sums = computation3D.computeMoments2(centroid.getCentroidAsVoxel(), true);
// xx
mat.set(0, 0, sums[0]);
// xy
mat.set(0, 1, sums[3]);
// xz
mat.set(0, 2, sums[4]);
// xy
mat.set(1, 0, sums[3]);
// yy
mat.set(1, 1, sums[1]);
// yz
mat.set(1, 2, sums[5]);
// xz
mat.set(2, 0, sums[4]);
// yz
mat.set(2, 1, sums[5]);
// zz
mat.set(2, 2, sums[2]);
EigenvalueDecomposition eigen = new EigenvalueDecomposition(mat);
double[] eigenValues = eigen.getRealEigenvalues();
double R1 = Math.sqrt(5.0 * eigenValues[2]);
double R2 = Math.sqrt(5.0 * eigenValues[1]);
double R3 = Math.sqrt(5.0 * eigenValues[0]);
double volEll = (4.0 / 3.0) * Math.PI * R1 * R2 * R3;
MeasureVolume volume = new MeasureVolume(object3DInt);
keysValues.put(ELL_VOL_UNIT, volEll);
keysValues.put(ELL_SPARENESS, volume.getValueMeasurement(MeasureVolume.VOLUME_UNIT) / volEll);
keysValues.put(ELL_MAJOR_RADIUS_UNIT, R1);
keysValues.put(ELL_ELONGATION, R1 / R2);
keysValues.put(ELL_FLATNESS, R2 / R3);
radius1 = R1;
radius2 = R2;
radius3 = R3;
// vectors
Matrix eVectors = eigen.getV();
Axis1 = new Vector3D(eVectors.get(0, 2), eVectors.get(1, 2), eVectors.get(2, 2));
Axis2 = new Vector3D(eVectors.get(0, 1), eVectors.get(1, 1), eVectors.get(2, 1));
Axis3 = new Vector3D(eVectors.get(0, 0), eVectors.get(1, 0), eVectors.get(2, 0));
}
use of mcib3d.Jama.EigenvalueDecomposition in project mcib3d-core by mcib3d.
the class Object3DVoxels method computeEigenInertia.
/**
* Constructor for the computeEigenInertia object
*/
private void computeEigenInertia() {
if (eigen == null) {
Matrix mat = new Matrix(3, 3);
mat.set(0, 0, s200);
mat.set(0, 1, -s110);
mat.set(0, 2, -s101);
mat.set(1, 0, -s110);
mat.set(1, 1, s020);
mat.set(1, 2, -s011);
mat.set(2, 0, -s101);
mat.set(2, 1, -s011);
mat.set(2, 2, s002);
eigen = new EigenvalueDecomposition(mat);
}
}
Aggregations