use of mcib3d.utils.ArrayUtil in project mcib3d-core by mcib3d.
the class Image3D method getNeighborhoodCross3D.
/**
* @param x
* @param y
* @param z
* @return
*/
public ArrayUtil getNeighborhoodCross3D(int x, int y, int z) {
ArrayUtil res = new ArrayUtil(7);
res.putValue(0, getPix(x, y, z));
int idx = 1;
if ((x + 1) < sizex) {
res.putValue(idx, getPix(x + 1, y, z));
idx++;
}
if ((x - 1) >= 0) {
res.putValue(idx, getPix(x - 1, y, z));
idx++;
}
if ((y + 1) < sizey) {
res.putValue(idx, getPix(x, y + 1, z));
idx++;
}
if ((y - 1) >= 0) {
res.putValue(idx, getPix(x, y - 1, z));
idx++;
}
if ((z + 1) < sizez) {
res.putValue(idx, getPix(x, y, z + 1));
idx++;
}
if ((z - 1) >= 0) {
res.putValue(idx, getPix(x, y, z - 1));
idx++;
}
res.setSize(idx);
return res;
}
use of mcib3d.utils.ArrayUtil in project mcib3d-core by mcib3d.
the class Image3D method getNeighborhoodGrayKernelMinus.
/**
* @param ker
* @param x
* @param y
* @param z
* @return
*/
public ArrayUtil getNeighborhoodGrayKernelMinus(IntImage3D ker, int x, int y, int z) {
ArrayUtil pix = new ArrayUtil(ker.getNbPixel());
int vx = ker.getSizex();
int vy = ker.getSizey();
int vz = ker.getSizez();
int index = 0;
int x0 = x - vx;
int x1 = x + vx;
int y0 = y - vy;
int y1 = y + vy;
int z0 = z - vz;
int z1 = z + vz;
float val;
for (int k = z0; k <= z1; k++) {
for (int j = y0; j <= y1; j++) {
for (int i = x0; i <= x1; i++) {
if (i >= 0 && j >= 0 && k >= 0 && i < sizex && j < sizey && k < sizez) {
val = (float) getPix(i, j, k) - (float) ker.getPixel(i - x0, j - y0, k - z0);
if (val < 0) {
val = 0;
}
pix.putValue(index, val);
index++;
}
}
}
}
pix.setSize(index);
return pix;
}
use of mcib3d.utils.ArrayUtil in project mcib3d-core by mcib3d.
the class Image3D method getNeighborhoodSphere.
/**
* Gets the neighboring of a pixel (sphere)
*
* @param x Coordinate x of the pixel
* @param y Coordinate y of the pixel
* @param z Coordinate z of the pixel
* @param radx Radius x of the neighboring
* @param rady Radius y of the neighboring
* @param radz Radius z of the neighboring
* @return The neigbor values in a array
*/
public ArrayUtil getNeighborhoodSphere(int x, int y, int z, float radx, float rady, float radz) {
int index = 0;
double rx2;
if (radx != 0) {
rx2 = radx * radx;
} else {
rx2 = 1;
}
double ry2;
if (rady != 0) {
ry2 = rady * rady;
} else {
ry2 = 1;
}
double rz2;
if (radz != 0) {
rz2 = radz * radz;
} else {
rz2 = 1;
}
double dist;
int vx = (int) Math.ceil(radx);
int vy = (int) Math.ceil(rady);
int vz = (int) Math.ceil(radz);
double[] pix = new double[(2 * vx + 1) * (2 * vy + 1) * (2 * vz + 1)];
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) {
dist = ((x - i) * (x - i)) / rx2 + ((y - j) * (y - j)) / ry2 + ((z - k) * (z - k)) / rz2;
if (dist <= 1.0) {
// t.putValue(index, );
pix[index] = getPix(i, j, k);
index++;
}
}
}
}
}
ArrayUtil t = new ArrayUtil(pix);
t.setSize(index);
return t;
}
use of mcib3d.utils.ArrayUtil in project mcib3d-core by mcib3d.
the class Image3D method getNeighborhoodSphere.
/**
* Gets the neighboring of a pixel (sphere)
*
* @param x Coordinate x of the pixel
* @param y Coordinate y of the pixel
* @param z Coordinate z of the pixel
* @param radx Radius x of the neighboring
* @param rady Radius y of the neighboring
* @param radz Radius z of the neighboring
* @param edm
* @return The neigbor values in a array
*/
public ArrayUtil getNeighborhoodSphere(int x, int y, int z, float radx, float rady, float radz, RealImage3D edm) {
int index = 0;
double rx2;
if (radx != 0) {
rx2 = radx * radx;
} else {
rx2 = 1;
}
double ry2;
if (rady != 0) {
ry2 = rady * rady;
} else {
ry2 = 1;
}
double rz2;
if (radz != 0) {
rz2 = radz * radz;
} else {
rz2 = 1;
}
double dist;
double edmvalue, edmtmp;
int vx = (int) Math.ceil(radx);
int vy = (int) Math.ceil(rady);
int vz = (int) Math.ceil(radz);
double[] pix = new double[(2 * vx + 1) * (2 * vy + 1) * (2 * vz + 1)];
edmvalue = edm.getPixel(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) {
dist = ((x - i) * (x - i)) / rx2 + ((y - j) * (y - j)) / ry2 + ((z - k) * (z - k)) / rz2;
edmtmp = edm.getPixel(i, j, k);
if ((dist <= 1.0) && (edmtmp > edmvalue)) {
// t.putValue(index, );
pix[index] = getPix(i, j, k);
index++;
}
}
}
}
}
ArrayUtil t = new ArrayUtil(pix);
t.setSize(index);
return t;
}
use of mcib3d.utils.ArrayUtil in project mcib3d-core by mcib3d.
the class Image3D method getNeighborhoodGrayKernelAdd.
/**
* @param ker
* @param x
* @param y
* @param z
* @return
*/
public ArrayUtil getNeighborhoodGrayKernelAdd(IntImage3D ker, int x, int y, int z) {
ArrayUtil pix = new ArrayUtil(ker.getNbPixel());
int vx = ker.getSizex();
int vy = ker.getSizey();
int vz = ker.getSizez();
int index = 0;
int x0 = x - vx;
int x1 = x + vx;
int y0 = y - vy;
int y1 = y + vy;
int z0 = z - vz;
int z1 = z + vz;
for (int k = z0; k <= z1; k++) {
for (int j = y0; j <= y1; j++) {
for (int i = x0; i <= x1; i++) {
if (i >= 0 && j >= 0 && k >= 0 && i < sizex && j < sizey && k < sizez) {
pix.putValue(index, (float) getPix(i, j, k) + (float) ker.getPixel(i - x0, j - y0, k - z0));
index++;
}
}
}
}
pix.setSize(index);
return pix;
}
Aggregations