Search in sources :

Example 1 with Voxel3D

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

the class ImageHandler method getNeighborhoodLayerList.

/**
 * Get the neighborhood as a layer of pixels
 *
 * @param x     Coordinate x of the pixel
 * @param y     Coordinate y of the pixel
 * @param z     Coordinate z of the pixel
 * @param r0    Minimu radius value
 * @param r1    Maximum radius value
 * @param water Watershed image, can be null
 * @return arrayList ogf voxels3D
 */
public ArrayList<Voxel3D> getNeighborhoodLayerList(int x, int y, int z, float r0, float r1, ImageInt water) {
    int index = 0;
    double r02 = r0 * r0;
    double r12 = r1 * r1;
    ArrayList<Voxel3D> voxel3DS = new ArrayList<Voxel3D>();
    double dist;
    double ratio = getScaleZ() / getScaleXY();
    double ratio2 = ratio * ratio;
    int vx = (int) Math.ceil(r1);
    int vy = (int) Math.ceil(r1);
    int vz = (int) (Math.ceil(r1 / ratio));
    // double[] pix = new double[(2 * vx + 1) * (2 * vy + 1) * (2 * vz + 1)];
    int wat = 0;
    if (water != null) {
        wat = water.getPixelInt(x, y, z);
    }
    for (int k = z - vz; k <= z + vz; k++) {
        for (int j = y - vy; j <= y + vy; j++) {
            for (int i = x - vx; i <= x + vx; i++) {
                if (i >= 0 && j >= 0 && k >= 0 && i < sizeX && j < sizeY && k < sizeZ) {
                    if (((water != null) && (water.getPixel(i, j, k) == wat)) || (water == null)) {
                        dist = ((x - i) * (x - i)) + ((y - j) * (y - j)) + ((z - k) * (z - k) * ratio2);
                        if ((dist >= r02) && (dist < r12)) {
                            voxel3DS.add(new Voxel3D(i, j, k, getPixel(i, j, k)));
                        }
                    }
                }
            }
        }
    }
    // check if some values are set
    return voxel3DS;
}
Also used : ArrayList(java.util.ArrayList) Voxel3D(mcib3d.geom.Voxel3D)

Example 2 with Voxel3D

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

the class ImageHandler method createListVoxels.

public ArrayList<Voxel3D> createListVoxels(int thresh) {
    ArrayList<Voxel3D> voxelList = new ArrayList<Voxel3D>();
    for (int z = 0; z < sizeZ; z++) {
        for (int x = 0; x < sizeX; x++) {
            for (int y = 0; y < sizeY; y++) {
                if (getPixel(x, y, z) > thresh) {
                    Voxel3D v = new Voxel3D(x, y, z, getPixel(x, y, z));
                    voxelList.add(v);
                }
            }
        }
    }
    return voxelList;
}
Also used : ArrayList(java.util.ArrayList) Voxel3D(mcib3d.geom.Voxel3D)

Example 3 with Voxel3D

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

the class ImageLabeller method getObjects.

// classical default neighborhood for segmentation is 26
public ArrayList<Object3DVoxels> getObjects(ImageHandler mask, boolean connex6) {
    if ((spots == null) || (mask != currentMask)) {
        if (connex6) {
            this.labelSpots6(mask);
        } else {
            this.labelSpots26(mask);
        }
    }
    ArrayList<Object3DVoxels> objects = new ArrayList<Object3DVoxels>();
    int sizeX = mask.sizeX;
    short label = 1;
    for (Spot s : spots.values()) {
        ArrayList<Vox3D> a = s.voxels;
        // check size
        if ((a.size() >= minSize) && (a.size() <= maxsize)) {
            ArrayList voxels3D = new ArrayList();
            for (Vox3D vox : a) {
                voxels3D.add(new Voxel3D(vox.xy % sizeX, vox.xy / sizeX, vox.z, label));
            }
            ArrayList noDuplicate = new ArrayList(new HashSet(voxels3D));
            // set calibration
            Object3DVoxels object3DVoxels = new Object3DVoxels(noDuplicate);
            // Object3D_IJUtils.setCalibration(object3DVoxels, mask.getCalibration());
            object3DVoxels.setCalibration(mask.getScaleXY(), mask.getScaleZ(), mask.getUnit());
            objects.add(object3DVoxels);
            label++;
        }
    }
    return objects;
}
Also used : ArrayList(java.util.ArrayList) Object3DVoxels(mcib3d.geom.Object3DVoxels) Voxel3D(mcib3d.geom.Voxel3D) HashSet(java.util.HashSet)

Example 4 with Voxel3D

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

the class ImageShort method draw.

@Override
public void draw(Object3D o, int value) {
    Object3DVoxels ov;
    if (!(o instanceof Object3DVoxels)) {
        ov = o.getObject3DVoxels();
    } else {
        ov = (Object3DVoxels) o;
    }
    if (value > 65535) {
        value = 255;
    }
    if (value < 0) {
        value = 0;
    }
    short val = (short) value;
    for (Voxel3D v : ov.getVoxels()) {
        if (contains(v.getX(), v.getY(), v.getZ())) {
            pixels[v.getRoundZ()][v.getRoundX() + v.getRoundY() * sizeX] = val;
        }
    }
}
Also used : Object3DVoxels(mcib3d.geom.Object3DVoxels) Voxel3D(mcib3d.geom.Voxel3D)

Example 5 with Voxel3D

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

the class Align2DData method align2D.

/**
 *  Description of the Method
 *
 * @param  img1            Description of the Parameter
 * @param  index2          Description of the Parameter
 * @param  rangeangle      Description of the Parameter
 * @param  incrementangle  Description of the Parameter
 */
public void align2D(ImageProcessor img1, int index2, double rangeangle, double incrementangle) {
    double score = correlation(img1, getImage(index2, true), sizex, sizey);
    Voxel3D max = FHTImage3D.getMaxCorrelation(img1, getImage(index2, true));
    serie[index2].addTranslation(max.getX(), max.getY());
}
Also used : Voxel3D(mcib3d.geom.Voxel3D)

Aggregations

Voxel3D (mcib3d.geom.Voxel3D)28 ArrayList (java.util.ArrayList)11 Object3DVoxels (mcib3d.geom.Object3DVoxels)6 Iterator (java.util.Iterator)3 Voxel3DComparable (mcib3d.geom.Voxel3DComparable)3 ImagePlus (ij.ImagePlus)2 ImageProcessor (ij.process.ImageProcessor)2 Random (java.util.Random)2 Objects3DPopulation (mcib3d.geom.Objects3DPopulation)2 Point3D (mcib3d.geom.Point3D)2 ImageInt (mcib3d.image3d.ImageInt)2 ImageShort (mcib3d.image3d.ImageShort)2 FHTImage3D (mcib3d.image3d.legacy.FHTImage3D)2 ArrayUtil (mcib3d.utils.ArrayUtil)2 Point3d (com.github.quickhull3d.Point3d)1 QuickHull3D (com.github.quickhull3d.QuickHull3D)1 Roi (ij.gui.Roi)1 RoiManager (ij.plugin.frame.RoiManager)1 Rectangle (java.awt.Rectangle)1 Date (java.util.Date)1