Search in sources :

Example 1 with Object3D

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

the class Segment3DSpots method segmentAll.

/**
 */
public void segmentAll() {
    segmentedObjects = new ArrayList<Object3D>();
    LinkedList<Voxel3D> obj;
    int o = 1;
    int localThreshold = localValue;
    if (labelImage == null) {
        this.createLabelImage();
    }
    // locate seeds
    for (int z = 0; z < seedsImage.sizeZ; z++) {
        IJ.showStatus("Segmenting slice " + (z + 1));
        // IJ.log("Segmenting slice " + (z + 1));
        for (int y = 0; y < seedsImage.sizeY; y++) {
            for (int x = 0; x < seedsImage.sizeX; x++) {
                if (seedsImage.getPixel(x, y, z) > seedsThreshold) {
                    // LOCAL THRESHOLD
                    if (localMethod == LOCAL_MEAN) {
                        localThreshold = (int) localMean(x, y, z);
                    } else if (localMethod == LOCAL_GAUSS) {
                        double[] gauss;
                        gauss = this.gaussianFit(x, y, z, false);
                        if (gauss != null) {
                            double thresh = CurveFitter.f(CurveFitter.GAUSSIAN, gauss, GAUSS_PC * gauss[3]);
                            // IJ.log("gauss sigma : " + gauss[3] + " thresh=" + thresh);
                            localThreshold = (int) thresh;
                        }
                    } else if (localMethod == LOCAL_DIFF) {
                        localThreshold = (int) Math.max(1, seedsImage.getPixel(x, y, z) - diff);
                    }
                    if (localThreshold > 0) {
                        if (show) {
                            IJ.log("segmenting spot at : " + x + " " + y + " " + " " + z + " lc=" + localThreshold);
                        }
                    }
                    switch(methodSeg) {
                        case SEG_CLASSICAL:
                            obj = this.segmentSpotClassical(x, y, z, localThreshold, o);
                            break;
                        case SEG_MAX:
                            obj = this.segmentSpotMax(x, y, z, localThreshold, o);
                            break;
                        case SEG_BLOCK:
                            obj = this.segmentSpotBlock(x, y, z, localThreshold, o);
                            break;
                        default:
                            obj = this.segmentSpotClassical(x, y, z, localThreshold, o);
                            break;
                    }
                    if ((obj != null) && (obj.size() >= volMin) && (obj.size() <= volMax)) {
                        segmentedObjects.add(new Object3DVoxels(obj));
                        // IJ.log("obj size: "+obj.size());
                        o++;
                    } else if (obj != null) {
                        // erase from label image
                        for (Voxel3D vo : obj) {
                            labelImage.setPixel(vo.getRoundX(), vo.getRoundY(), vo.getRoundZ(), 0);
                        }
                        if (show) {
                            IJ.log("object volume outside range : " + obj.size());
                        }
                    }
                }
            }
        }
    }
}
Also used : Object3DVoxels(mcib3d.geom.Object3DVoxels) Voxel3D(mcib3d.geom.Voxel3D) Object3D(mcib3d.geom.Object3D)

Example 2 with Object3D

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

the class TrackingAssociation method computeTracking.

private void computeTracking() {
    Objects3DPopulation population1 = new Objects3DPopulation(this.img1);
    Objects3DPopulation population2 = new Objects3DPopulation(this.img2);
    Association association = new Association(population1, population2, new CostColocalisation(population1, population2, 10));
    association.verbose = false;
    association.computeAssociation();
    MitosisDetector mitosisDetector = new MitosisDetector(this.img1, this.img2, association);
    // compute merging
    if (this.merge) {
        this.img2 = mitosisDetector.detectAndMergeSplit();
        population2 = new Objects3DPopulation(this.img2);
        association = new Association(population1, population2, new CostColocalisation(population1, population2, 10));
        association.computeAssociation();
        mitosisDetector = new MitosisDetector(this.img1, this.img2, association);
    }
    // final associations
    finalAssociations = association.getAssociationPairs();
    finalOrphan1 = association.getOrphan1Population().getObjectsList();
    finalOrphan2 = association.getOrphan2Population().getObjectsList();
    finalMitosis = new LinkedList<>();
    // MITOSIS DETECTION
    if (mitosis) {
        TreeSet<Mitosis> treeSet = mitosisDetector.detectMitosis();
        List<Object3D> mito = new LinkedList<>();
        for (Mitosis mitosis : treeSet) {
            Object3D d1 = mitosis.getDaughter1();
            Object3D d2 = mitosis.getDaughter2();
            Object3D mo = mitosis.getMother();
            double coloc = mitosis.getColocMitosis();
            int valPath = (int) mo.getPixMeanValue(this.path);
            if (!mito.contains(d1) && !mito.contains(d2) && coloc > mitosisDetector.getMinColocMitosis()) {
                IJ.log("MITOSIS : " + d1.getValue() + " " + d2.getValue() + " " + mo.getValue() + " " + coloc + " " + valPath);
                // FIXME
                finalMitosis.add(mitosis);
                mito.add(d1);
                mito.add(d2);
                if (this.path != null) {
                    d1.draw(this.pathed, valPath);
                    d2.draw(this.pathed, valPath);
                }
            }
        }
    }
}
Also used : Objects3DPopulation(mcib3d.geom.Objects3DPopulation) LinkedList(java.util.LinkedList) Object3D(mcib3d.geom.Object3D)

Example 3 with Object3D

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

the class Association method drawOrphan1.

@Deprecated
public void drawOrphan1(ImageHandler draw) {
    if (CostsAll == null)
        computeAssociation();
    // orphan1
    for (String orphan : Orphan1) {
        int val = Integer.parseInt(orphan);
        Object3D object3D1 = population1.getObjectByValue(val);
        object3D1.draw(draw);
    }
}
Also used : Object3D(mcib3d.geom.Object3D)

Example 4 with Object3D

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

the class Association method getOrphan2Population.

public Objects3DPopulation getOrphan2Population() {
    Objects3DPopulation pop = new Objects3DPopulation();
    for (String orphanS : getOrphan2()) {
        int val = Integer.parseInt(orphanS);
        Object3D object3D2 = population2.getObjectByValue(val);
        pop.addObject(object3D2);
    }
    return pop;
}
Also used : Objects3DPopulation(mcib3d.geom.Objects3DPopulation) Object3D(mcib3d.geom.Object3D)

Example 5 with Object3D

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

the class Association method drawAssociation.

@Deprecated
public void drawAssociation(ImageHandler draw) {
    if (CostsAll == null)
        computeAssociation();
    int max = 0;
    for (String a : CostsOK.keySet()) {
        int[] vals = Association.getValues(a);
        int val1 = vals[0];
        int val2 = vals[1];
        Object3D object3D2 = population2.getObjectByValue(val2);
        // object3D2.setValue(val1);
        object3D2.draw(draw, val1);
        if (val1 > max)
            max = val1;
    }
    // orphan2
    for (String orphan : Orphan2) {
        int val = Integer.parseInt(orphan);
        max++;
        Object3D object3D2 = population2.getObjectByValue(val);
        // object3D2.setValue(max);
        object3D2.draw(draw, max);
    }
}
Also used : Object3D(mcib3d.geom.Object3D)

Aggregations

Object3D (mcib3d.geom.Object3D)18 Objects3DPopulation (mcib3d.geom.Objects3DPopulation)6 ArrayUtil (mcib3d.utils.ArrayUtil)4 Voxel3D (mcib3d.geom.Voxel3D)3 ResultsTable (ij.measure.ResultsTable)2 Object3DVoxels (mcib3d.geom.Object3DVoxels)2 LinkedList (java.util.LinkedList)1 Vector3D (mcib3d.geom.Vector3D)1 ImageHandler (mcib3d.image3d.ImageHandler)1 ImageShort (mcib3d.image3d.ImageShort)1