Search in sources :

Example 1 with KDTreeC

use of mcib3d.utils.KDTreeC in project mcib3d-core by mcib3d.

the class Object3D method getKdtreeContours.

private KDTreeC getKdtreeContours() {
    if (contours == null) {
        computeContours();
    }
    if (kdtreeContours == null) {
        if ((contours != null) && (!contours.isEmpty())) {
            kdtreeContours = new KDTreeC(3);
            kdtreeContours.setScale3(this.resXY, this.resXY, this.resZ);
            for (Voxel3D v : contours) {
                kdtreeContours.add(v.getArray(), v);
            }
        }
    }
    return kdtreeContours;
}
Also used : KDTreeC(mcib3d.utils.KDTreeC)

Example 2 with KDTreeC

use of mcib3d.utils.KDTreeC in project mcib3d-core by mcib3d.

the class Objects3DPopulation method createKDTreeCenters.

public void createKDTreeCenters() {
    kdtree = new KDTreeC(3, 64);
    double[] tmp = { scaleXY, scaleXY, scaleZ };
    kdtree.setScale(tmp);
    for (int i = 0; i < this.getNbObjects(); i++) {
        kdtree.add(this.getObject(i).getCenterAsArray(), this.getObject(i));
    }
}
Also used : KDTreeC(mcib3d.utils.KDTreeC)

Example 3 with KDTreeC

use of mcib3d.utils.KDTreeC in project mcib3d-core by mcib3d.

the class Object3D method VoxelsBorderBorder.

public Voxel3D[] VoxelsBorderBorder(Object3D other) {
    double distanceMinimum = Double.MAX_VALUE;
    Voxel3D otherBorder = null, thisBorder = null;
    KDTreeC tree = this.getKdtreeContours();
    for (Voxel3D otherVoxel : other.getContours()) {
        double[] pos = otherVoxel.getArray();
        Item item = tree.getNearestNeighbor(pos, 1)[0];
        if (item.distanceSq < distanceMinimum) {
            otherBorder = otherVoxel;
            thisBorder = (Voxel3D) item.obj;
            distanceMinimum = item.distanceSq;
        }
    }
    return new Voxel3D[] { thisBorder, otherBorder };
}
Also used : Item(mcib3d.utils.KDTreeC.Item) KDTreeC(mcib3d.utils.KDTreeC)

Example 4 with KDTreeC

use of mcib3d.utils.KDTreeC in project mcib3d-core by mcib3d.

the class Object3DLabel method computeContours.

public void computeContours() {
    boolean cont;
    contours = new ArrayList();
    kdtreeContours = new KDTreeC(3);
    kdtreeContours.setScale3(this.resXY, this.resXY, this.resZ);
    int pix0, pix1, pix2, pix3, pix4, pix5, pix6;
    int sx = labelImage.sizeX, sy = labelImage.sizeY, sz = labelImage.sizeZ;
    double XYZ = resXY * resZ;
    double XX = resXY * resXY;
    areaNbVoxels = 0;
    areaContactUnit = 0;
    areaContactVoxels = 0;
    for (int k = zmin; k <= zmax; k++) {
        for (int j = ymin; j <= ymax; j++) {
            for (int i = xmin; i <= xmax; i++) {
                cont = false;
                pix1 = pix2 = pix3 = pix4 = pix5 = pix6 = 0;
                pix0 = labelImage.getPixelInt(i, j, k);
                if (pix0 == value) {
                    if (i + 1 < sx) {
                        pix1 = labelImage.getPixelInt(i + 1, j, k);
                    }
                    if (i > 0) {
                        pix2 = labelImage.getPixelInt(i - 1, j, k);
                    }
                    if (j + 1 < sy) {
                        pix3 = labelImage.getPixelInt(i, j + 1, k);
                    }
                    if (j > 0) {
                        pix4 = labelImage.getPixelInt(i, j - 1, k);
                    }
                    if (k + 1 < sz) {
                        pix5 = labelImage.getPixelInt(i, j, k + 1);
                    }
                    if (k > 0) {
                        pix6 = labelImage.getPixelInt(i, j, k - 1);
                    }
                    if (pix1 != value) {
                        cont = true;
                        areaContactUnit += XYZ;
                        areaContactVoxels++;
                    }
                    if (pix2 != value) {
                        cont = true;
                        areaContactUnit += XYZ;
                        areaContactVoxels++;
                    }
                    if (pix3 != value) {
                        cont = true;
                        areaContactUnit += XYZ;
                        areaContactVoxels++;
                    }
                    if (pix4 != value) {
                        cont = true;
                        areaContactUnit += XYZ;
                        areaContactVoxels++;
                    }
                    if (pix5 != value) {
                        cont = true;
                        areaContactUnit += XX;
                        areaContactVoxels++;
                    }
                    if (pix6 != value) {
                        cont = true;
                        areaContactUnit += XX;
                        areaContactVoxels++;
                    }
                    if (cont) {
                        areaNbVoxels++;
                        Voxel3D vox = new Voxel3D(i, j, k, value);
                        contours.add(vox);
                        kdtreeContours.add(vox.getArray(), vox);
                    }
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) KDTreeC(mcib3d.utils.KDTreeC)

Example 5 with KDTreeC

use of mcib3d.utils.KDTreeC in project mcib3d-core by mcib3d.

the class Object3DSurface method computeContours.

@Override
public void computeContours() {
    // Contours pixels are same as surface vertices
    kdtreeContours = new KDTreeC(3);
    kdtreeContours.setScale3(this.resXY, this.resXY, this.resZ);
    contours = new ArrayList();
    Point3f P;
    // Value ?
    double val = 1;
    for (Point3f vertice : vertices) {
        P = vertice;
        Voxel3D vox = new Voxel3D(P, val);
        contours.add(vox);
        kdtreeContours.add(vox.getArray(), vox);
    }
    // needs to compute area since contours are used to compute areas in other classes
    this.computeSurfaceAreas();
}
Also used : Point3f(org.scijava.vecmath.Point3f) KDTreeC(mcib3d.utils.KDTreeC)

Aggregations

KDTreeC (mcib3d.utils.KDTreeC)6 ArrayList (java.util.ArrayList)1 Item (mcib3d.utils.KDTreeC.Item)1 Point3f (org.scijava.vecmath.Point3f)1