use of mcib3d.geom.Voxel3D in project mcib3d-core by mcib3d.
the class Segment3DSpots method segmentSpotTemplate.
/**
* @param xdep
* @param ydep
* @param zdep
* @param lcThreshold
* @param val
* @return
*/
private ArrayList<Voxel3D> segmentSpotTemplate(int xdep, int ydep, int zdep, int lcThreshold, int val) {
boolean changement = true;
int xfin = xdep + 1;
int yfin = ydep + 1;
int zfin = zdep + 1;
int sens = 1;
if (labelImage == null) {
this.createLabelImage();
}
// pixel already segmented ?
if (labelImage.getPixel(xdep, ydep, zdep) > 0) {
return null;
}
labelImage.setPixel(xdep, ydep, zdep, val);
ArrayList<Voxel3D> object = new ArrayList<Voxel3D>();
object.add(new Voxel3D(xdep, ydep, zdep, val));
int volume = 1;
int i;
int j;
int k;
int l;
int m;
int n;
ImageHandler original = rawImage;
ArrayList<Voxel3D> neigh;
Iterator it;
Voxel3D tmpneigh;
while (changement) {
changement = false;
for (k = sens == 1 ? zdep : zfin; ((sens == 1 && k <= zfin) || (sens == -1 && k >= zdep)); k += sens) {
for (j = sens == 1 ? ydep : yfin; ((sens == 1 && j <= yfin) || (sens == -1 && j >= ydep)); j += sens) {
for (i = sens == 1 ? xdep : xfin; ((sens == 1 && i <= xfin) || (sens == -1 && i >= xdep)); i += sens) {
if (labelImage.getPixel(i, j, k) == val) {
// create neighbors list
neigh = new ArrayList<Voxel3D>();
for (n = k - 1; n < k + 2; n++) {
for (m = j - 1; m < j + 2; m++) {
for (l = i - 1; l < i + 2; l++) {
if (labelImage.getPixel(l, m, n) == 0) {
neigh.add(new Voxel3D(l, m, n, original.getPixel(l, m, n)));
}
}
}
}
// analyse list
it = neigh.iterator();
while (it.hasNext()) {
tmpneigh = (Voxel3D) it.next();
// CLASSICAL
if (tmpneigh.getValue() >= lcThreshold) {
l = tmpneigh.getRoundX();
m = tmpneigh.getRoundY();
n = tmpneigh.getRoundZ();
labelImage.setPixel(l, m, n, val);
object.add(new Voxel3D(l, m, n, val));
volume++;
if (volume > volMax) {
if (show) {
IJ.log("VOL :" + volume);
}
return null;
}
// update min-max
if (l < xdep) {
xdep--;
}
if (l > xfin) {
xfin++;
}
if (m < ydep) {
ydep--;
}
if (m > yfin) {
yfin++;
}
if (n < zdep) {
zdep--;
}
if (n > zfin) {
zfin++;
}
changement = true;
}
}
}
}
}
}
sens *= -1;
}
return object;
}
use of mcib3d.geom.Voxel3D in project mcib3d-core by mcib3d.
the class FHTImage3D method getTranslation.
/**
* Gets the translation attribute of the FHTImage3D class
*
* @param xcorr Description of the Parameter
* @param RmaxX Description of the Parameter
* @param RmaxY Description of the Parameter
* @param RmaxZ Description of the Parameter
* @return The translation value
*/
public static Voxel3D getTranslation(FHTImage3D xcorr, int RmaxX, int RmaxY, int RmaxZ) {
int sizex = xcorr.sizex;
int sizey = xcorr.sizey;
int sizez = xcorr.sizez;
int centerx = (int) ((sizex) / 2.0F);
int centery = (int) ((sizey) / 2.0F);
int centerz = (int) ((sizez) / 2.0F);
if (xcorr.centered) {
centerx = 0;
centery = 0;
centerz = 0;
}
Voxel3D max = new Voxel3D(centerx, centery, centerz, xcorr.getPixel(centerx, centery, centerz));
for (int k = 0; k < sizez; k++) {
int dz = (k >= sizez - centerz) ? k - sizez : k;
for (int j = 0; j < sizey; j++) {
int dy = (j >= sizey - centery) ? j - sizey : j;
for (int i = 0; i < sizex; i++) {
int dx = (i >= sizex - centerx) ? i - sizex : i;
if (Math.abs(dx) <= RmaxX && Math.abs(dy) <= RmaxY && Math.abs(dz) <= RmaxZ) {
double val = xcorr.getPixel(i, j, k);
if (val > max.getValue()) {
max.setVoxel(dx, dy, dz, val);
}
}
}
}
}
return max;
}
use of mcib3d.geom.Voxel3D in project mcib3d-core by mcib3d.
the class Mesh method computeConvexHull3D.
public ArrayList<Point3f> computeConvexHull3D() {
QuickHull3D hull = new QuickHull3D();
System.out.println("Computing 3d convex hull...");
Object3DSurface o = new Object3DSurface(vertices);
ArrayList<Voxel3D> pointsList = o.getContours();
Point3d[] points = new Point3d[pointsList.size()];
for (int ve = 0; ve < points.length; ve++) {
points[ve] = new Point3d(pointsList.get(ve).getX(), pointsList.get(ve).getY(), pointsList.get(ve).getZ());
}
System.out.println("done 1st for");
hull.build(points);
hull.triangulate();
ArrayList<Point3f> convex = new ArrayList<Point3f>();
int[][] faceIndices = hull.getFaces();
Point3d[] verticesHull = hull.getVertices();
for (int k = 0; k < faceIndices.length; k++) {
for (int ve = 0; ve < 3; ve++) {
Point3d point = verticesHull[faceIndices[k][ve]];
convex.add(new Point3f((float) point.x, (float) point.y, (float) point.z));
}
}
return convex;
}
Aggregations