Search in sources :

Example 21 with ImageInt

use of mcib3d.image3d.ImageInt in project mcib3d-core by mcib3d.

the class Objects3DPopulation method drawPopulation.

public ImageInt drawPopulation() {
    int[] sizes = this.getMaxSizeAllObjects();
    ImageInt drawImage = new ImageShort("population", sizes[0], sizes[1], sizes[2]);
    for (Object3D object3DVoxels : getObjectsList()) {
        object3DVoxels.draw(drawImage);
    }
    return drawImage;
}
Also used : ImageShort(mcib3d.image3d.ImageShort) ImageInt(mcib3d.image3d.ImageInt)

Example 22 with ImageInt

use of mcib3d.image3d.ImageInt in project mcib3d-core by mcib3d.

the class Objects3DPopulation method shuffle.

public ArrayList<Object3D> shuffle() {
    ArrayList<Object3D> shuObj = new ArrayList<Object3D>();
    Random ra = new Random();
    ImageInt maskImage = mask.getMaxLabelImage(1);
    Object3DVoxels maskVox = mask.getObject3DVoxels();
    // shuffle indices
    ArrayUtil shuffleIndex = new ArrayUtil(getNbObjects());
    shuffleIndex.fillRange(0, getNbObjects(), 1);
    shuffleIndex.shuffle();
    for (int i = 0; i < getNbObjects(); i++) {
        Object3DVoxels obj = (Object3DVoxels) getObject(shuffleIndex.getValueInt(i));
        Point3D center = obj.getCenterAsPoint();
        boolean ok = false;
        int it = 0;
        int maxIt = 1000000;
        while (!ok) {
            // log.log("Shuffling " + getObject3D(i).getValue());
            Voxel3D vox = maskVox.getRandomvoxel(ra);
            obj.setNewCenter(vox.getX(), vox.getY(), vox.getZ());
            ok = true;
            it++;
            obj.resetQuantifImage();
            if (maskVox.includesBox(obj)) {
                if (obj.getPixMinValue(maskImage) < 1) {
                    ok = false;
                }
            } else {
                ok = false;
            }
            if (it >= maxIt) {
                ok = true;
            }
        }
        if (it == maxIt) {
            if (log != null)
                log.log("Could not shuffle " + obj);
            obj.setNewCenter(center.x, center.y, center.z);
        }
        shuObj.add(obj);
        // update mask
        obj.draw(maskImage, 0);
    }
    return shuObj;
}
Also used : Random(java.util.Random) ArrayList(java.util.ArrayList) ImageInt(mcib3d.image3d.ImageInt) ArrayUtil(mcib3d.utils.ArrayUtil)

Example 23 with ImageInt

use of mcib3d.image3d.ImageInt in project mcib3d-core by mcib3d.

the class Objects3DPopulationColocalisation method computeColocalisation.

private void computeColocalisation() {
    ImageInt image1 = population1.drawPopulation();
    ImageInt image2 = population2.drawPopulation();
    computeColocalisationImage(image1, image2);
}
Also used : ImageInt(mcib3d.image3d.ImageInt)

Example 24 with ImageInt

use of mcib3d.image3d.ImageInt in project mcib3d-core by mcib3d.

the class Object3DLabel method getColoc.

@Override
public int getColoc(Object3D other) {
    if (this.disjointBox(other)) {
        return 0;
    }
    int count = 0;
    int xmin0;
    int ymin0;
    int zmin0;
    int xmax0;
    int ymax0;
    int zmax0;
    int val = other.getValue();
    ImageInt otherseg = other.getMaxLabelImage(val);
    xmin0 = getXmin();
    ymin0 = getYmin();
    zmin0 = getZmin();
    xmax0 = getXmax();
    ymax0 = getYmax();
    zmax0 = getZmax();
    if (other != null) {
        xmin0 = Math.max(xmin0, other.getXmin());
        ymin0 = Math.max(ymin0, other.getYmin());
        zmin0 = Math.max(zmin0, other.getZmin());
        xmax0 = Math.min(xmax0, other.getXmax());
        ymax0 = Math.min(ymax0, other.getYmax());
        zmax0 = Math.min(zmax0, other.getZmax());
    }
    for (int k = zmin0; k <= zmax0; k++) {
        for (int j = ymin0; j <= ymax0; j++) {
            for (int i = xmin0; i <= xmax0; i++) {
                if ((labelImage.getPixel(i, j, k) == value) && (otherseg.getPixel(i, j, k) == val)) {
                    count++;
                }
            }
        }
    }
    return count;
}
Also used : ImageInt(mcib3d.image3d.ImageInt)

Aggregations

ImageInt (mcib3d.image3d.ImageInt)24 ImageByte (mcib3d.image3d.ImageByte)13 ImageShort (mcib3d.image3d.ImageShort)4 ThreadRunner (mcib3d.utils.ThreadRunner)4 Random (java.util.Random)3 ArrayList (java.util.ArrayList)2 Objects3DPopulation (mcib3d.geom.Objects3DPopulation)2 Point3D (mcib3d.geom.Point3D)2 Voxel3D (mcib3d.geom.Voxel3D)2 ImagePlus (ij.ImagePlus)1 Calibration (ij.measure.Calibration)1 ImageProcessor (ij.process.ImageProcessor)1 Volume (ij3d.Volume)1 List (java.util.List)1 ObjectCreator3D (mcib3d.geom.ObjectCreator3D)1 Voxel3DComparable (mcib3d.geom.Voxel3DComparable)1 ImageFloat (mcib3d.image3d.ImageFloat)1 ImageHandler (mcib3d.image3d.ImageHandler)1 ImageLabeller (mcib3d.image3d.ImageLabeller)1 Segment3DImage (mcib3d.image3d.Segment3DImage)1