use of mcib3d.geom.Voxel3D in project mcib3d-core by mcib3d.
the class ImageHandler method getNeighborhoodLayerList.
/**
* Get the neighborhood as a layer of pixels
*
* @param x Coordinate x of the pixel
* @param y Coordinate y of the pixel
* @param z Coordinate z of the pixel
* @param r0 Minimu radius value
* @param r1 Maximum radius value
* @param water Watershed image, can be null
* @return arrayList ogf voxels3D
*/
public ArrayList<Voxel3D> getNeighborhoodLayerList(int x, int y, int z, float r0, float r1, ImageInt water) {
int index = 0;
double r02 = r0 * r0;
double r12 = r1 * r1;
ArrayList<Voxel3D> voxel3DS = new ArrayList<Voxel3D>();
double dist;
double ratio = getScaleZ() / getScaleXY();
double ratio2 = ratio * ratio;
int vx = (int) Math.ceil(r1);
int vy = (int) Math.ceil(r1);
int vz = (int) (Math.ceil(r1 / ratio));
// double[] pix = new double[(2 * vx + 1) * (2 * vy + 1) * (2 * vz + 1)];
int wat = 0;
if (water != null) {
wat = water.getPixelInt(x, y, z);
}
for (int k = z - vz; k <= z + vz; k++) {
for (int j = y - vy; j <= y + vy; j++) {
for (int i = x - vx; i <= x + vx; i++) {
if (i >= 0 && j >= 0 && k >= 0 && i < sizeX && j < sizeY && k < sizeZ) {
if (((water != null) && (water.getPixel(i, j, k) == wat)) || (water == null)) {
dist = ((x - i) * (x - i)) + ((y - j) * (y - j)) + ((z - k) * (z - k) * ratio2);
if ((dist >= r02) && (dist < r12)) {
voxel3DS.add(new Voxel3D(i, j, k, getPixel(i, j, k)));
}
}
}
}
}
}
// check if some values are set
return voxel3DS;
}
use of mcib3d.geom.Voxel3D in project mcib3d-core by mcib3d.
the class ImageHandler method createListVoxels.
public ArrayList<Voxel3D> createListVoxels(int thresh) {
ArrayList<Voxel3D> voxelList = new ArrayList<Voxel3D>();
for (int z = 0; z < sizeZ; z++) {
for (int x = 0; x < sizeX; x++) {
for (int y = 0; y < sizeY; y++) {
if (getPixel(x, y, z) > thresh) {
Voxel3D v = new Voxel3D(x, y, z, getPixel(x, y, z));
voxelList.add(v);
}
}
}
}
return voxelList;
}
use of mcib3d.geom.Voxel3D in project mcib3d-core by mcib3d.
the class ImageLabeller method getObjects.
// classical default neighborhood for segmentation is 26
public ArrayList<Object3DVoxels> getObjects(ImageHandler mask, boolean connex6) {
if ((spots == null) || (mask != currentMask)) {
if (connex6) {
this.labelSpots6(mask);
} else {
this.labelSpots26(mask);
}
}
ArrayList<Object3DVoxels> objects = new ArrayList<Object3DVoxels>();
int sizeX = mask.sizeX;
short label = 1;
for (Spot s : spots.values()) {
ArrayList<Vox3D> a = s.voxels;
// check size
if ((a.size() >= minSize) && (a.size() <= maxsize)) {
ArrayList voxels3D = new ArrayList();
for (Vox3D vox : a) {
voxels3D.add(new Voxel3D(vox.xy % sizeX, vox.xy / sizeX, vox.z, label));
}
ArrayList noDuplicate = new ArrayList(new HashSet(voxels3D));
// set calibration
Object3DVoxels object3DVoxels = new Object3DVoxels(noDuplicate);
// Object3D_IJUtils.setCalibration(object3DVoxels, mask.getCalibration());
object3DVoxels.setCalibration(mask.getScaleXY(), mask.getScaleZ(), mask.getUnit());
objects.add(object3DVoxels);
label++;
}
}
return objects;
}
use of mcib3d.geom.Voxel3D in project mcib3d-core by mcib3d.
the class ImageShort method draw.
@Override
public void draw(Object3D o, int value) {
Object3DVoxels ov;
if (!(o instanceof Object3DVoxels)) {
ov = o.getObject3DVoxels();
} else {
ov = (Object3DVoxels) o;
}
if (value > 65535) {
value = 255;
}
if (value < 0) {
value = 0;
}
short val = (short) value;
for (Voxel3D v : ov.getVoxels()) {
if (contains(v.getX(), v.getY(), v.getZ())) {
pixels[v.getRoundZ()][v.getRoundX() + v.getRoundY() * sizeX] = val;
}
}
}
use of mcib3d.geom.Voxel3D in project mcib3d-core by mcib3d.
the class Align2DData method align2D.
/**
* Description of the Method
*
* @param img1 Description of the Parameter
* @param index2 Description of the Parameter
* @param rangeangle Description of the Parameter
* @param incrementangle Description of the Parameter
*/
public void align2D(ImageProcessor img1, int index2, double rangeangle, double incrementangle) {
double score = correlation(img1, getImage(index2, true), sizex, sizey);
Voxel3D max = FHTImage3D.getMaxCorrelation(img1, getImage(index2, true));
serie[index2].addTranslation(max.getX(), max.getY());
}
Aggregations