use of mcib3d.geom.Point3D in project mcib3d-core by mcib3d.
the class ImageHandler method getMinAndMaxArray.
public double[] getMinAndMaxArray(ArrayList<? extends Point3D> mask) {
double min = Double.MAX_VALUE;
double max = -min;
for (Point3D p : mask) {
double v = getPixel(p);
if (v > max) {
max = v;
}
if (v < min) {
min = v;
}
}
return new double[] { min, max };
}
use of mcib3d.geom.Point3D in project mcib3d-core by mcib3d.
the class SpatialRandom method getSample.
@Override
public Objects3DPopulation getSample() {
Point3D[] points = new Point3D[nbObjects];
Objects3DPopulation pop = new Objects3DPopulation();
pop.setMask(mask);
ImageHandler maskimgTmp = maskimg.duplicate();
Random ra = new Random();
for (int i = 0; i < nbObjects; i++) {
Voxel3D vox = maskVox.getRandomVoxel(ra);
while (maskimgTmp.getPixel(vox) == 0) {
vox = maskVox.getRandomVoxel(ra);
}
points[i] = vox;
maskimgTmp.setPixel(vox, 0);
}
pop.addPoints(points);
pop.setCalibration(mask.getResXY(), mask.getResZ(), mask.getUnits());
return pop;
}
use of mcib3d.geom.Point3D in project mcib3d-core by mcib3d.
the class DeformableMesh method getGlobalScaling.
public double getGlobalScaling() {
Point3D center = this.getCenterAsVector();
double ratio = 0;
double r;
int cpt = 0;
for (int i = 0; i < forces.size(); i++) {
Point3D P0 = new Point3D(this.getUniqueVertex(i));
Point3D P1 = new Point3D(this.getUniqueVertex(i));
Vector3D force = forces.get(i);
// IJ.log("Force " + i + " " + force);
if (force != null) {
P1.translate(force);
Vector3D V0 = new Vector3D(center, P0);
Vector3D V1 = new Vector3D(center, P1);
r = V1.getLength() / V0.getLength();
ratio += r;
cpt++;
// IJ.log("scale " + i + " " + r + " " + V0 + " " + V1);
}
}
if (cpt > 1) {
ratio /= (double) cpt;
} else {
ratio = 1;
}
return ratio;
}
use of mcib3d.geom.Point3D in project mcib3d-core by mcib3d.
the class DeformableMesh method computeLine.
private double[] computeLine(int i, int dist, int border, boolean forward) {
int dir = forward ? 1 : -1;
// compute normals (normalized)
this.computeVerticesNormals();
// first point and last point
Point3D P0 = new Point3D(vertices.get(i));
P0.translate(verticesNormals.get(i).multiply(-dir * border));
Point3D P1 = new Point3D(vertices.get(i));
P1.translate(verticesNormals.get(i).multiply(dir * (dist + border)));
double[] line = image.extractLine(P0.getRoundX(), P0.getRoundY(), P0.getRoundZ(), P1.getRoundX(), P1.getRoundY(), P1.getRoundZ(), false);
return line;
}
use of mcib3d.geom.Point3D in project mcib3d-core by mcib3d.
the class ImageHandler method getHistogram.
public int[] getHistogram(ArrayList<? extends Point3D> mask, int nBins, double min, double max) {
int[] histo = new int[nBins];
double coeff = nBins / (max - min);
int idx;
for (Point3D p : mask) {
idx = (int) ((getPixel(p) - min) * coeff);
if (idx >= 255) {
histo[255]++;
} else {
histo[idx]++;
}
}
return histo;
}
Aggregations