use of mcib3d.utils.KDTreeC.Item in project mcib3d-core by mcib3d.
the class Object3D method getPixelBorder.
public Voxel3D getPixelBorder(double x, double y, double z) {
// USE KDTREE
double[] pos = { x, y, z };
Item item = getKdtreeContours().getNearestNeighbor(pos, 1)[0];
return (Voxel3D) item.obj;
}
use of mcib3d.utils.KDTreeC.Item in project mcib3d-core by mcib3d.
the class Objects3DPopulation method kClosestCenter.
// kth closest (k=1 to N), with exclude list, if object in same population,
// the object should be in the exclude list
public Object3D kClosestCenter(Object3D ob, int k, ArrayList<Object3D> exclude) {
if (kdtree == null) {
this.createKDTreeCenters();
}
int nbClosest = 0;
Item kClosest = null;
Item[] items = kdtree.getNearestNeighbor(ob.getCenterAsArray(), getNbObjects());
for (Item item : items) {
if (!exclude.contains(item)) {
nbClosest++;
kClosest = item;
}
if (nbClosest == k)
break;
}
return (Object3D) kClosest.obj;
}
use of mcib3d.utils.KDTreeC.Item 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 };
}
use of mcib3d.utils.KDTreeC.Item in project mcib3d-core by mcib3d.
the class Objects3DPopulation method closestCenter.
/**
* @param x x coordinate in pixel
* @param y y coordinate in pixel
* @param z z coordinate in pixel
* @return closest object (using calibrated distance)
*/
public Object3D closestCenter(double x, double y, double z) {
if (kdtree == null) {
this.createKDTreeCenters();
}
double[] pos = { x, y, z };
Item clo = (kdtree.getNearestNeighbor(pos, 1))[0];
return (Object3D) clo.obj;
}