Search in sources :

Example 6 with ImageHandler

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

the class Object3D_IJUtils method drawIntersectionLabel.

public static void drawIntersectionLabel(Object3DLabel object3DLabel, Object3DLabel other, ImageStack mask, int red, int green, int blue) {
    ImageProcessor tmp;
    ImageHandler otherSeg = other.getLabelImage();
    int otherValue = other.getValue();
    Color col = new Color(red, green, blue);
    int zmin = object3DLabel.getZmin();
    int zmax = object3DLabel.getZmax();
    int ymin = object3DLabel.getYmin();
    int ymax = object3DLabel.getYmax();
    int xmin = object3DLabel.getXmin();
    int xmax = object3DLabel.getXmax();
    ImageInt labelImage = object3DLabel.getLabelImage();
    int value = object3DLabel.getValue();
    for (int z = zmin; z <= zmax; z++) {
        tmp = mask.getProcessor(z + 1);
        tmp.setColor(col);
        for (int x = xmin; x <= xmax; x++) {
            for (int y = ymin; y <= ymax; y++) {
                if ((labelImage.getPixel(x, y, z) == value) && (otherSeg.getPixel(x, y, z) == otherValue)) {
                    tmp.drawPixel(x, y);
                }
            }
        }
    }
}
Also used : ImageHandler(mcib3d.image3d.ImageHandler) ImageProcessor(ij.process.ImageProcessor) ImageInt(mcib3d.image3d.ImageInt)

Example 7 with ImageHandler

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

the class GeomTransform3D method getImageTransformed.

private void getImageTransformed(ImageHandler img, ImageHandler out, int minZ, int maxZ) {
    minZ = Math.max(0, minZ);
    maxZ = Math.min(img.sizeZ, maxZ);
    ImageHandler res = img.createSameDimensions();
    for (int k = minZ; k < maxZ; k++) {
        for (int j = 0; j < img.sizeY; j++) {
            for (int i = 0; i < img.sizeX; i++) {
                out.setPixel(i, j, k, this.getPixelTransformedI(img, i, j, k));
            }
        }
    }
}
Also used : ImageHandler(mcib3d.image3d.ImageHandler)

Example 8 with ImageHandler

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

the class SymmetryFilter method computeBins.

private void computeBins() {
    ImageHandler img = edges[0];
    bin1 = new ImageFloat("bin1", img.sizeX, img.sizeY, img.sizeZ);
    bin2 = new ImageFloat("bin2", img.sizeX, img.sizeY, img.sizeZ);
    for (int z = 0; z < img.sizeZ; z++) {
        IJ.showStatus("Symmetry " + z + "/" + img.sizeZ);
        for (int x = 0; x < img.sizeX; x++) {
            for (int y = 0; y < img.sizeY; y++) {
                double ex = edges[0].getPixel(x, y, z);
                double ey = edges[1].getPixel(x, y, z);
                double ez = edges[2].getPixel(x, y, z);
                double ee = Math.sqrt(ex * ex + ey * ey + ez * ez);
                // bin
                Vector3D grad = new Vector3D(ex, ey, ez);
                grad.normalize();
                if (grad.getLength() == 0) {
                    continue;
                }
                Point3D pos = new Vector3D(x, y, z);
                for (int d = 0; d < radius; d++) {
                    pos.translate(grad);
                    if ((d > 0) && (img.contains(pos.getRoundX(), pos.getRoundY(), pos.getRoundZ()))) {
                        bin1.setPixelIncrement(pos, 1);
                        if (improved) {
                            bin2.setPixelIncrement(pos, (float) (d * ee));
                        } else {
                            bin2.setPixelIncrement(pos, (float) (ee));
                        }
                    }
                }
            }
        }
    }
}
Also used : ImageHandler(mcib3d.image3d.ImageHandler) Vector3D(mcib3d.geom.Vector3D) Point3D(mcib3d.geom.Point3D) ImageFloat(mcib3d.image3d.ImageFloat)

Example 9 with ImageHandler

use of mcib3d.image3d.ImageHandler 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 10 with ImageHandler

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

Aggregations

ImageHandler (mcib3d.image3d.ImageHandler)11 ImageShort (mcib3d.image3d.ImageShort)5 ImageProcessor (ij.process.ImageProcessor)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Object3D (mcib3d.geom.Object3D)1 Point3D (mcib3d.geom.Point3D)1 Vector3D (mcib3d.geom.Vector3D)1 Voxel3D (mcib3d.geom.Voxel3D)1 Voxel3DComparable (mcib3d.geom.Voxel3DComparable)1 ImageFloat (mcib3d.image3d.ImageFloat)1 ImageInt (mcib3d.image3d.ImageInt)1 ImageLabeller (mcib3d.image3d.ImageLabeller)1