Search in sources :

Example 6 with ImageShort

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

the class Watershed3D method createNeigList.

private void createNeigList() {
    voxels = new LinkedList<Voxel3DComparable>();
    int sx = rawImage.sizeX;
    int sy = rawImage.sizeY;
    int sz = rawImage.sizeZ;
    // watershed images
    watershedImage = new ImageShort("watershed", sx, sy, sz);
    labelQueueImage = new ImageShort("labelQ", sx, sy, sz);
    // okseeds = false;
    float pix;
    float se;
    // compute the seeds image
    // threshold, // TODO 32-bits seeds ?
    ImageHandler seedsLabel = seedsImage.duplicate();
    seedsLabel.thresholdCut(seedsThreshold, false, true);
    if ((labelSeeds)) {
        log.log("Labelling ");
        ImageLabeller labeller = new ImageLabeller();
        seedsLabel = labeller.getLabels(seedsLabel);
    }
    // since seeds Label starts at 1 and watershed at 2, replace values
    int max = (int) seedsLabel.getMax();
    if (seedsLabel.hasOneValue(QUEUE)) {
        seedsLabel.replacePixelsValue(QUEUE, max + 1);
        seedsValue.put(max + 1, QUEUE);
    }
    if (seedsLabel.hasOneValue(DAM)) {
        seedsLabel.replacePixelsValue(DAM, max + 2);
        seedsValue.put(max + 2, DAM);
    }
    if (!seedsValue.isEmpty())
        seedsLabel.resetStats(null);
    for (int z = sz - 1; z >= 0; z--) {
        IJ.showStatus("Processing watershed " + (z + 1));
        for (int y = sy - 1; y >= 0; y--) {
            for (int x = sx - 1; x >= 0; x--) {
                pix = rawImage.getPixel(x, y, z);
                se = seedsLabel.getPixel(x, y, z);
                if (pix > rawThreshold) {
                    if (se > 0) {
                        watershedImage.setPixel(x, y, z, se);
                        // okseeds = true;
                        ArrayList<Voxel3D> list = watershedImage.getNeighborhood3x3x3ListNoCenter(x, y, z);
                        Collections.shuffle(list);
                        for (Voxel3D N : list) {
                            int vx = (int) N.getX();
                            int vy = (int) N.getY();
                            int vz = (int) N.getZ();
                            float raw = rawImage.getPixel(vx, vy, vz);
                            if ((raw > rawThreshold) && (seedsLabel.getPixel(vx, vy, vz) == 0) && (watershedImage.getPixel(vx, vy, vz) != QUEUE)) {
                                voxels.add(new Voxel3DComparable(vx, vy, vz, raw, se));
                                watershedImage.setPixel(vx, vy, vz, QUEUE);
                                labelQueueImage.setPixel(vx, vy, vz, se);
                            }
                        }
                    }
                }
            }
        }
    }
    log.log("Watershed...");
}
Also used : ImageHandler(mcib3d.image3d.ImageHandler) ImageShort(mcib3d.image3d.ImageShort) ImageLabeller(mcib3d.image3d.ImageLabeller) Voxel3D(mcib3d.geom.Voxel3D) Voxel3DComparable(mcib3d.geom.Voxel3DComparable)

Example 7 with ImageShort

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

the class Watershed3D_old method createArrayList.

private void createArrayList() {
    voxels = new ArrayList();
    int sx = rawImage.sizeX;
    int sy = rawImage.sizeY;
    int sz = rawImage.sizeZ;
    // watershedImage
    this.watershedImage = new ImageShort("watershed", sx, sy, sz);
    okseeds = false;
    float pix;
    float se;
    // compute the labelled image (in case seeds are clustered)
    ImageLabeller labeller = new ImageLabeller();
    ImageInt seedsLabel = labeller.getLabels(seedsImage.thresholdAboveExclusive(seedsThreshold));
    // IJ.log("MAX SEEDS " + seedsLabel.getImageStats(null).getMax());
    // since seedsLabel starts at 1 and watershed at 2, replace values
    seedsLabel.replacePixelsValue(BORDER, (int) seedsLabel.getMax() + 1);
    seedsLabel.resetStats(null);
    // IJ.log("MAX SEEDS " + seedsLabel.getImageStats(null).getMax());
    if (computeVolumes) {
        for (int i = 0; i <= seedsLabel.getMax(); i++) {
            volumeLabels.add(0.0);
        }
    }
    for (int z = 0; z < sz; z++) {
        IJ.showStatus("Processing watershed " + (z + 1));
        for (int y = 0; y < sy; y++) {
            for (int x = 0; x < sx; x++) {
                pix = rawImage.getPixel(x, y, z);
                se = seedsLabel.getPixel(x, y, z);
                if (pix > rawThreshold) {
                    // IJ.log("seed found " + x + " " + y + " " + z+" : "+se);
                    if (se > 0) {
                        // IJ.log("seed found " + x + " " + y + " " + z);
                        watershedImage.setPixel(x, y, z, se);
                        voxels.add(new Voxel3DComparable(x, y, z, pix, se));
                        okseeds = true;
                    } else {
                        voxels.add(new Voxel3DComparable(x, y, z, pix, NO_LABEL));
                        watershedImage.setPixel(x, y, z, NO_LABEL);
                    }
                } else {
                    watershedImage.setPixel(x, y, z, NO_LABEL);
                }
                // compute volumes (warning if seeds are float values)
                if (computeVolumes) {
                    // volumeLabels.get((int) se)[1]++;
                    volumeLabels.set((int) se, volumeLabels.get((int) se) + 1);
                }
            }
        }
    }
}
Also used : ImageShort(mcib3d.image3d.ImageShort) ImageLabeller(mcib3d.image3d.ImageLabeller) ArrayList(java.util.ArrayList) ImageInt(mcib3d.image3d.ImageInt) Voxel3DComparable(mcib3d.geom.Voxel3DComparable)

Example 8 with ImageShort

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

the class SpatialShuffle method getSampleImage.

@Override
public ImageHandler getSampleImage() {
    Object3D mask = population.getMask();
    ImageHandler tmp = new ImageShort(getName(), mask.getXmax() + 1, mask.getYmax() + 1, mask.getZmax() + 1);
    getSample().draw(tmp);
    return tmp;
}
Also used : ImageHandler(mcib3d.image3d.ImageHandler) ImageShort(mcib3d.image3d.ImageShort) Object3D(mcib3d.geom.Object3D)

Example 9 with ImageShort

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

the class IntImage3D method binaryReconstructByObjects.

public ImageInt binaryReconstructByObjects(ImageInt base) {
    // System.out.println("max "+this.getMaximum());
    Segment3DImage seg = new Segment3DImage(new ImageShort(this.getStack()), 1, 65535);
    seg.segment();
    ImageInt label = seg.getLabelledObjectsImage3D();
    boolean[] ok = new boolean[(int) label.getMax() + 1];
    for (int i = 0; i < ok.length; i++) {
        ok[i] = false;
    }
    if (label.getMax() > 0) {
        for (int k = 0; k < sizez; k++) {
            for (int j = 0; j < sizey; j++) {
                for (int i = 0; i < sizex; i++) {
                    if (base.getPixel(i, j, k) != 0) {
                        ok[label.getPixelInt(i, j, k)] = true;
                    }
                }
            }
        }
        for (int k = 0; k < sizez; k++) {
            for (int j = 0; j < sizey; j++) {
                for (int i = 0; i < sizex; i++) {
                    int pix = label.getPixelInt(i, j, k);
                    if (pix > 0) {
                        if (ok[pix]) {
                            label.setPixel(i, j, k, 255);
                        } else {
                            label.setPixel(i, j, k, 0);
                        }
                    }
                }
            }
        }
    }
    return label;
}
Also used : ImageShort(mcib3d.image3d.ImageShort) ImageInt(mcib3d.image3d.ImageInt) Segment3DImage(mcib3d.image3d.Segment3DImage)

Example 10 with ImageShort

use of mcib3d.image3d.ImageShort 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)

Aggregations

ImageShort (mcib3d.image3d.ImageShort)10 ImageHandler (mcib3d.image3d.ImageHandler)5 ImageInt (mcib3d.image3d.ImageInt)4 Voxel3DComparable (mcib3d.geom.Voxel3DComparable)3 Voxel3D (mcib3d.geom.Voxel3D)2 ImageLabeller (mcib3d.image3d.ImageLabeller)2 ImagePlus (ij.ImagePlus)1 Volume (ij3d.Volume)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 IntCoord3D (mcib3d.geom.IntCoord3D)1 Object3D (mcib3d.geom.Object3D)1 ImageByte (mcib3d.image3d.ImageByte)1 Segment3DImage (mcib3d.image3d.Segment3DImage)1