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;
}
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);
}
}
}
}
}
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);
}
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;
}
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;
}
Aggregations