use of mcib3d.image3d.Segment3DImage 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;
}
Aggregations