use of mcib3d.image3d.ImageInt 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;
}
use of mcib3d.image3d.ImageInt in project mcib3d-core by mcib3d.
the class Objects3DPopulation method shuffle.
public ArrayList<Object3D> shuffle() {
ArrayList<Object3D> shuObj = new ArrayList<Object3D>();
Random ra = new Random();
ImageInt maskImage = mask.getMaxLabelImage(1);
Object3DVoxels maskVox = mask.getObject3DVoxels();
// shuffle indices
ArrayUtil shuffleIndex = new ArrayUtil(getNbObjects());
shuffleIndex.fillRange(0, getNbObjects(), 1);
shuffleIndex.shuffle();
for (int i = 0; i < getNbObjects(); i++) {
Object3DVoxels obj = (Object3DVoxels) getObject(shuffleIndex.getValueInt(i));
Point3D center = obj.getCenterAsPoint();
boolean ok = false;
int it = 0;
int maxIt = 1000000;
while (!ok) {
// log.log("Shuffling " + getObject3D(i).getValue());
Voxel3D vox = maskVox.getRandomvoxel(ra);
obj.setNewCenter(vox.getX(), vox.getY(), vox.getZ());
ok = true;
it++;
obj.resetQuantifImage();
if (maskVox.includesBox(obj)) {
if (obj.getPixMinValue(maskImage) < 1) {
ok = false;
}
} else {
ok = false;
}
if (it >= maxIt) {
ok = true;
}
}
if (it == maxIt) {
if (log != null)
log.log("Could not shuffle " + obj);
obj.setNewCenter(center.x, center.y, center.z);
}
shuObj.add(obj);
// update mask
obj.draw(maskImage, 0);
}
return shuObj;
}
use of mcib3d.image3d.ImageInt in project mcib3d-core by mcib3d.
the class Objects3DPopulationColocalisation method computeColocalisation.
private void computeColocalisation() {
ImageInt image1 = population1.drawPopulation();
ImageInt image2 = population2.drawPopulation();
computeColocalisationImage(image1, image2);
}
use of mcib3d.image3d.ImageInt in project mcib3d-core by mcib3d.
the class Object3DLabel method getColoc.
@Override
public int getColoc(Object3D other) {
if (this.disjointBox(other)) {
return 0;
}
int count = 0;
int xmin0;
int ymin0;
int zmin0;
int xmax0;
int ymax0;
int zmax0;
int val = other.getValue();
ImageInt otherseg = other.getMaxLabelImage(val);
xmin0 = getXmin();
ymin0 = getYmin();
zmin0 = getZmin();
xmax0 = getXmax();
ymax0 = getYmax();
zmax0 = getZmax();
if (other != null) {
xmin0 = Math.max(xmin0, other.getXmin());
ymin0 = Math.max(ymin0, other.getYmin());
zmin0 = Math.max(zmin0, other.getZmin());
xmax0 = Math.min(xmax0, other.getXmax());
ymax0 = Math.min(ymax0, other.getYmax());
zmax0 = Math.min(zmax0, other.getZmax());
}
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, j, k) == val)) {
count++;
}
}
}
}
return count;
}
Aggregations