Search in sources :

Example 1 with Objects3DPopulation

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

Example 2 with Objects3DPopulation

use of mcib3d.geom.Objects3DPopulation in project mcib3d-core by mcib3d.

the class SpatialRandomHardCore method getSample.

@Override
public Objects3DPopulation getSample() {
    Point3D[] points = new Point3D[nbObjects];
    Objects3DPopulation pop = new Objects3DPopulation();
    pop.setMask(mask);
    Random ra = new Random();
    ImageInt maskImgTmp = maskimg.duplicate();
    ObjectCreator3D create = new ObjectCreator3D(maskImgTmp);
    for (int i = 0; i < nbObjects; i++) {
        Voxel3D vox = maskVox.getRandomvoxel(ra);
        while (maskImgTmp.getPixel(vox) == 0) {
            vox = maskVox.getRandomvoxel(ra);
        }
        points[i] = vox;
        create.createSphere(vox.getRoundX(), vox.getRoundY(), vox.getRoundZ(), distHardCore, 0, false);
    }
    pop.addPoints(points);
    return pop;
}
Also used : ObjectCreator3D(mcib3d.geom.ObjectCreator3D) Random(java.util.Random) Point3D(mcib3d.geom.Point3D) ImageInt(mcib3d.image3d.ImageInt) Voxel3D(mcib3d.geom.Voxel3D) Objects3DPopulation(mcib3d.geom.Objects3DPopulation)

Aggregations

Random (java.util.Random)2 Objects3DPopulation (mcib3d.geom.Objects3DPopulation)2 Point3D (mcib3d.geom.Point3D)2 Voxel3D (mcib3d.geom.Voxel3D)2 ImageInt (mcib3d.image3d.ImageInt)2 ObjectCreator3D (mcib3d.geom.ObjectCreator3D)1