use of mcib3d.image3d.ImageByte in project mcib3d-core by mcib3d.
the class BinaryMorpho method binaryDilateRad1diag.
private static ImageByte binaryDilateRad1diag(final ImageInt in_, final float thld, int nbCPUs) {
if (nbCPUs == 0) {
nbCPUs = ThreadUtil.getNbCpus();
}
final ImageInt in = (ImageInt) in_.resize(1, 1, 1);
final ImageByte max = new ImageByte("max", in.sizeX, in.sizeY, in.sizeZ);
final ThreadRunner tr = new ThreadRunner(0, in.sizeZ, nbCPUs);
for (int i = 0; i < tr.threads.length; i++) {
tr.threads[i] = new Thread(new Runnable() {
@Override
public void run() {
for (int z = tr.ai.getAndIncrement(); z < tr.end; z = tr.ai.getAndIncrement()) {
for (int y = 0; y < in.sizeY; y++) {
for (int x = 0; x < in.sizeX; x++) {
if (maxRad15(in, thld, x, y, z)) {
max.pixels[z][x + y * in.sizeX] = (byte) 255;
}
}
}
}
}
});
}
tr.startAndJoin();
max.setScale(in);
max.setOffset(in);
return max;
}
use of mcib3d.image3d.ImageByte in project mcib3d-core by mcib3d.
the class BinaryMorpho method binaryCloseMultilabel.
public static ImageInt binaryCloseMultilabel(ImageInt in, float radiusXY, float radiusZ, int nbCPUs) {
ImageByte[] ihs = in.crop3DBinary();
if (ihs != null) {
// ij.IJ.log("BinaryClose multilabel nb :"+ihs.length);
for (int idx = 0; idx < ihs.length; idx++) {
if (radiusXY < 1 && radiusZ < 1) {
ihs[idx] = binaryCloseRad1(ihs[idx], 1, nbCPUs);
} else if (radiusXY < 2 && radiusZ < 2) {
ihs[idx] = binaryCloseRad1diag(ihs[idx], 1, nbCPUs);
} else if (radiusZ == 0) {
ihs[idx] = binaryClose2D(ihs[idx], radiusXY);
} else {
ihs[idx] = binaryClose(ihs[idx], radiusXY, radiusZ, nbCPUs);
}
}
ImageInt temp = ImageShort.merge3DBinary(ihs, in.sizeX, in.sizeY, in.sizeZ);
temp.setScale(in);
temp.setOffset(in);
return temp;
}
return in;
}
Aggregations