Search in sources :

Example 6 with ImageInt

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

the class SpatialRandomHardCore method getSample.

@Override
public Objects3DPopulation getSample() {
    Point3D[] points = new Point3D[nbObjects];
    Objects3DPopulation pop = new Objects3DPopulation();
    pop.setMask(mask);
    Random ra = new Random();
    ImageInt maskImgTmp = maskimg.duplicate();
    ObjectCreator3D create = new ObjectCreator3D(maskImgTmp);
    for (int i = 0; i < nbObjects; i++) {
        Voxel3D vox = maskVox.getRandomvoxel(ra);
        while (maskImgTmp.getPixel(vox) == 0) {
            vox = maskVox.getRandomvoxel(ra);
        }
        points[i] = vox;
        create.createSphere(vox.getRoundX(), vox.getRoundY(), vox.getRoundZ(), distHardCore, 0, false);
    }
    pop.addPoints(points);
    return pop;
}
Also used : ObjectCreator3D(mcib3d.geom.ObjectCreator3D) Random(java.util.Random) Point3D(mcib3d.geom.Point3D) ImageInt(mcib3d.image3d.ImageInt) Voxel3D(mcib3d.geom.Voxel3D) Objects3DPopulation(mcib3d.geom.Objects3DPopulation)

Example 7 with ImageInt

use of mcib3d.image3d.ImageInt 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 8 with ImageInt

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

the class Objects3DPopulation method addImage.

/**
 * @param plus
 */
@Deprecated
public void addImage(ImagePlus plus) {
    Calibration calplus = plus.getCalibration();
    if (calplus == null) {
        calplus = new Calibration();
        calplus.pixelWidth = 1;
        calplus.pixelHeight = 1;
        calplus.pixelDepth = 1;
        calplus.setUnit("pix");
    }
    this.setCalibration(calplus);
    ImageInt seg = ImageInt.wrap(plus);
    addImage(seg, calplus);
}
Also used : ImageInt(mcib3d.image3d.ImageInt) Calibration(ij.measure.Calibration)

Example 9 with ImageInt

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

the class Viewer3D_Utils method computeMeshSurface.

public static List computeMeshSurface(Object3D object3D, boolean calibrated) {
    // IJ.showStatus("computing mesh");
    // use miniseg
    ImageInt miniseg = object3D.getLabelImage();
    ImageByte miniseg8 = ((ImageShort) (miniseg)).convertToByte(false);
    ImagePlus objectImage = miniseg8.getImagePlus();
    if (calibrated) {
        objectImage.setCalibration(getCalibration(object3D));
    }
    boolean[] bl = { true, true, true };
    Volume vol = new Volume(objectImage, bl);
    vol.setAverage(true);
    List l = MCCube.getTriangles(vol, 0);
    // needs to invert surface
    l = Object3DSurface.invertNormals(l);
    // translate object with units coordinates
    float tx, ty, tz;
    if (calibrated) {
        tx = (float) (miniseg.offsetX * object3D.getResXY());
        ty = (float) (miniseg.offsetY * object3D.getResXY());
        tz = (float) (miniseg.offsetZ * object3D.getResZ());
    } else {
        tx = (float) (miniseg.offsetX);
        ty = (float) (miniseg.offsetY);
        tz = (float) (miniseg.offsetZ);
    }
    l = Object3DSurface.translateTool(l, tx, ty, tz);
    return l;
}
Also used : ImageByte(mcib3d.image3d.ImageByte) ImageShort(mcib3d.image3d.ImageShort) Volume(ij3d.Volume) ImageInt(mcib3d.image3d.ImageInt) List(java.util.List) ImagePlus(ij.ImagePlus)

Example 10 with ImageInt

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

the class Object3DLabel method hasOneVoxelColoc.

@Override
public boolean hasOneVoxelColoc(Object3D obj) {
    if (this.disjointBox(obj)) {
        return false;
    }
    if ((labelImage == null) || (obj.getMaxLabelImage(obj.getValue()) == null)) {
        return false;
    }
    // taken from object3DLabel
    int xmin0;
    int ymin0;
    int zmin0;
    int xmax0;
    int ymax0;
    int zmax0;
    int val = obj.getValue();
    ImageInt otherseg = obj.getLabelImage();
    xmin0 = getXmin();
    ymin0 = getYmin();
    zmin0 = getZmin();
    xmax0 = getXmax();
    ymax0 = getYmax();
    zmax0 = getZmax();
    xmin0 = Math.max(xmin0, obj.getXmin());
    ymin0 = Math.max(ymin0, obj.getYmin());
    zmin0 = Math.max(zmin0, obj.getZmin());
    xmax0 = Math.min(xmax0, obj.getXmax());
    ymax0 = Math.min(ymax0, obj.getYmax());
    zmax0 = Math.min(zmax0, obj.getZmax());
    // IJ.log(""+xmin0+"-"+xmax0+" "+ymin0+"-"+ymax0+" "+zmin0+"-"+zmax0+" "+otherseg);
    // labelImage.show("this");
    // otherseg.show("other");
    int offX1 = otherseg.offsetX;
    int offY1 = otherseg.offsetY;
    int offZ1 = otherseg.offsetZ;
    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 - offX1, j - offY1, k - offZ1) == val)) {
                    return true;
                }
            }
        }
    }
    return false;
}
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