Search in sources :

Example 1 with Point3D

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 };
}
Also used : Point3D(mcib3d.geom.Point3D)

Example 2 with Point3D

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;
}
Also used : ImageHandler(mcib3d.image3d.ImageHandler) Random(java.util.Random) Point3D(mcib3d.geom.Point3D) Voxel3D(mcib3d.geom.Voxel3D) Objects3DPopulation(mcib3d.geom.Objects3DPopulation)

Example 3 with Point3D

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;
}
Also used : Vector3D(mcib3d.geom.Vector3D) Point3D(mcib3d.geom.Point3D)

Example 4 with Point3D

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;
}
Also used : Point3D(mcib3d.geom.Point3D)

Example 5 with Point3D

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;
}
Also used : Point3D(mcib3d.geom.Point3D)

Aggregations

Point3D (mcib3d.geom.Point3D)9 Vector3D (mcib3d.geom.Vector3D)4 ImageHandler (mcib3d.image3d.ImageHandler)2 Random (java.util.Random)1 Objects3DPopulation (mcib3d.geom.Objects3DPopulation)1 Voxel3D (mcib3d.geom.Voxel3D)1 ImageFloat (mcib3d.image3d.ImageFloat)1 ArrayUtil (mcib3d.utils.ArrayUtil)1