From 2a54e482cbf287eb78122a160717ceec771e2f84 Mon Sep 17 00:00:00 2001
From: Daniel Sage
Date: Thu, 23 Dec 2010 16:43:01 +0100
Subject: [PATCH 1/5] Add a generic wavelet library
Signed-off-by: Johannes Schindelin
---
.gitignore | 1 +
Fakefile | 3 +-
.../wavelets/wavelets/ComplexWaveFilter.java | 268 ++++
.../wavelets/wavelets/ComplexWavelet.java | 490 +++++++
.../wavelets/wavelets/ImageAccess.java | 1277 +++++++++++++++++
src-plugins/wavelets/wavelets/WaveSpline.java | 384 +++++
.../wavelets/wavelets/WaveSplineFilter.java | 257 ++++
7 files changed, 2679 insertions(+), 1 deletion(-)
create mode 100644 src-plugins/wavelets/wavelets/ComplexWaveFilter.java
create mode 100644 src-plugins/wavelets/wavelets/ComplexWavelet.java
create mode 100644 src-plugins/wavelets/wavelets/ImageAccess.java
create mode 100644 src-plugins/wavelets/wavelets/WaveSpline.java
create mode 100644 src-plugins/wavelets/wavelets/WaveSplineFilter.java
diff --git a/.gitignore b/.gitignore
index 247da198e3..4b3e3e93fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -209,3 +209,4 @@
/jars/mij.jar
/plugins/Temporal_Color_Coder.jar
/plugins/Samples_.jar
+/jars/wavelets.jar
diff --git a/Fakefile b/Fakefile
index a01e6466bb..a621901d3b 100644
--- a/Fakefile
+++ b/Fakefile
@@ -203,7 +203,8 @@ PLUGIN_TARGETS=plugins/Jython_Interpreter.jar \
plugins/Jython_Scripts.jar \
plugins/Temporal_Color_Coder.jar \
plugins/Samples_.jar \
- jars/mij.jar
+ jars/mij.jar \
+ jars/wavelets.jar
all <- fiji $SUBMODULE_TARGETS $PLUGIN_TARGETS
diff --git a/src-plugins/wavelets/wavelets/ComplexWaveFilter.java b/src-plugins/wavelets/wavelets/ComplexWaveFilter.java
new file mode 100644
index 0000000000..0d714c9832
--- /dev/null
+++ b/src-plugins/wavelets/wavelets/ComplexWaveFilter.java
@@ -0,0 +1,268 @@
+package wavelets;
+
+/**
+ * This class generates the Complex wavelets filters.
+ *
+ * @author
+ *
+ * Daniel Sage
+ * Biomedical Imaging Group (BIG),
+ * Ecole Polytechnique Federale de Lausanne (EPFL), Lausanne, Switzerland
+ * More information: http://bigwww.epfl.ch/
+ * You'll be free to use this software for research purposes, but you should
+ * not redistribute it without our consent. In addition, we expect you to
+ * include a citation or acknowledgement whenever you present or publish
+ * results that are based on it.
+ *
+ * @version
+ * 11 July 2009
+ */
+
+public class ComplexWaveFilter {
+
+ /**
+ * real lowpass filter.
+ */
+ public double h[];
+
+ /**
+ * real highpass filter.
+ */
+ public double g[];
+
+ /**
+ * imaginary lowpass filter.
+ */
+ public double hi[];
+ /**
+ * imaginary highpass filter.
+ */
+ public double gi[];
+
+ /**
+ * The constructor generates the 4 filters for a giving length.
+ * @param length length of the filter, 6, 14 or 22
+ */
+ ComplexWaveFilter(int length) {
+ switch (length) {
+
+ case 6:
+ // Complex Daubechies
+ // Real lowpass filter
+ h = new double [6];
+ h[0] = -0.0662912607;
+ h[1] = 0.1104854346;
+ h[2] = 0.6629126074;
+ h[3] = 0.6629126074;
+ h[4] = 0.1104854346;
+ h[5] = -0.0662912607;
+
+ // Real highpass filter
+ g = new double [6];
+ g[5] = 0.0662912607;
+ g[4] = 0.1104854346;
+ g[3] = -0.6629126074;
+ g[2] = 0.6629126074;
+ g[1] = -0.1104854346;
+ g[0] = -0.0662912607;
+
+ // imaginary lowpass filter
+ hi = new double [6];
+ hi[0] = -0.0855816496;
+ hi[1] = -0.0855816496;
+ hi[2] = 0.1711632992;
+ hi[3] = 0.1711632992;
+ hi[4] = -0.0855816496;
+ hi[5] = -0.0855816496;
+
+ // Imaginary highpass filter
+ gi = new double [6];
+ gi[5] = -0.0855816496;
+ gi[4] = 0.0855816496;
+ gi[3] = 0.1711632992;
+ gi[2] = -0.1711632992;
+ gi[1] = -0.0855816496;
+ gi[0] = 0.0855816496;
+ break;
+
+ case 14:
+ // Complex Daubechies
+ // Real lowpass filter
+ h = new double [14];
+ h[0 ] = 0.0049120149;
+ h[1 ] = -0.0054111299;
+ h[2 ] = -0.0701089996;
+ h[3 ] = -0.0564377788;
+ h[4 ] = 0.1872348173;
+ h[5 ] = 0.3676385056;
+ h[6 ] = 0.2792793518;
+ h[7 ] = 0.2792793518;
+ h[8 ] = 0.3676385056;
+ h[9 ] = 0.1872348173;
+ h[10] = -0.0564377788;
+ h[11] = -0.0701089996;
+ h[12] = -0.0054111299;
+ h[13] = 0.0049120149;
+
+ // Real highpass filter
+ g = new double [14];
+ g[13] = -0.0049120149;
+ g[12] = -0.0054111299;
+ g[11] = 0.0701089996;
+ g[10] = -0.0564377788;
+ g[9] = -0.1872348173;
+ g[8] = 0.3676385056;
+ g[7] = -0.2792793518;
+ g[6] = 0.2792793518;
+ g[5] = -0.3676385056;
+ g[4] = 0.1872348173;
+ g[3] = 0.0564377788;
+ g[2] = -0.0701089996;
+ g[1] = 0.0054111299;
+ g[0] = 0.0049120149;
+
+ // imaginary lowpass filter
+ hi = new double [14];
+ hi[0 ] = 0.0018464710;
+ hi[1 ] = 0.0143947836;
+ hi[2 ] = 0.0079040001;
+ hi[3 ] = -0.1169376946;
+ hi[4 ] = -0.2596312614;
+ hi[5 ] = -0.0475928095;
+ hi[6 ] = 0.4000165107;
+ hi[7 ] = 0.4000165107;
+ hi[8 ] = -0.0475928095;
+ hi[9 ] = -0.2596312614;
+ hi[10] = -0.1169376946;
+ hi[11] = 0.0079040001;
+ hi[12] = 0.0143947836;
+ hi[13] = 0.0018464710;
+
+ // Imaginary highpass filter
+ gi = new double [14];
+ gi[13] = 0.0018464710;
+ gi[12] = -0.0143947836;
+ gi[11] = 0.0079040001;
+ gi[10] = 0.1169376946;
+ gi[9 ] = -0.2596312614;
+ gi[8 ] = 0.0475928095;
+ gi[7 ] = 0.4000165107;
+ gi[6 ] = -0.4000165107;
+ gi[5 ] = -0.0475928095;
+ gi[4 ] = 0.2596312614;
+ gi[3 ] = -0.1169376946;
+ gi[2 ] = -0.0079040001;
+ gi[1 ] = 0.0143947836;
+ gi[0 ] = -0.0018464710;
+ break;
+
+ case 22:
+ // Complex Daubechies
+ // Real lowpass filter
+ h = new double [22];
+ h[0 ] = -0.0002890832;
+ h[1 ] = -0.0000935982;
+ h[2 ] = 0.0059961342;
+ h[3 ] = 0.0122232015;
+ h[4 ] = -0.0243700791;
+ h[5 ] = -0.1092940542;
+ h[6 ] = -0.0918847036;
+ h[7 ] = 0.1540094645;
+ h[8 ] = 0.4014277015;
+ h[9 ] = 0.3153022916;
+ h[10] = 0.0440795062;
+ h[11] = 0.0440795062;
+ h[12] = 0.3153022916;
+ h[13] = 0.4014277015;
+ h[14] = 0.1540094645;
+ h[15] = -0.0918847036;
+ h[16] = -0.1092940542;
+ h[17] = -0.0243700791;
+ h[18] = 0.0122232015;
+ h[19] = 0.0059961342;
+ h[20] = -0.0000935982;
+ h[21] = -0.0002890832;
+
+ // Real highpass filter
+ g = new double [22];
+ g[21] = 0.0002890832;
+ g[20] = -0.0000935982;
+ g[19] = -0.0059961342;
+ g[18] = 0.0122232015;
+ g[17] = 0.0243700791;
+ g[16] = -0.1092940542;
+ g[15] = 0.0918847036;
+ g[14] = 0.1540094645;
+ g[13] = -0.4014277015;
+ g[12] = 0.3153022916;
+ g[11] = -0.0440795062;
+ g[10] = 0.0440795062;
+ g[9] = -0.3153022916;
+ g[8] = 0.4014277015;
+ g[7] = -0.1540094645;
+ g[6] = -0.0918847036;
+ g[5] = 0.1092940542;
+ g[4] = -0.0243700791;
+ g[3] = -0.0122232015;
+ g[2] = 0.0059961342;
+ g[1] = 0.0000935982;
+ g[0] = -0.0002890832;
+
+ // imaginary lowpass filter
+ hi = new double [22];
+ hi[0 ] = 0.0000211708;
+ hi[1 ] = -0.0012780664;
+ hi[2 ] = -0.0029648612;
+ hi[3 ] = 0.0144283733;
+ hi[4 ] = 0.0503067404;
+ hi[5 ] = -0.0044659104;
+ hi[6 ] = -0.1999654035;
+ hi[7 ] = -0.2603015239;
+ hi[8 ] = 0.0013800055;
+ hi[9 ] = 0.2232934469;
+ hi[10] = 0.1795460286;
+ hi[11] = 0.1795460286;
+ hi[12] = 0.2232934469;
+ hi[13] = 0.0013800055;
+ hi[14] = -0.2603015239;
+ hi[15] = -0.1999654035;
+ hi[16] = -0.0044659104;
+ hi[17] = 0.0503067404;
+ hi[18] = 0.0144283733;
+ hi[19] = -0.0029648612;
+ hi[20] = -0.0012780664;
+ hi[21] = 0.0000211708;
+
+ // Imaginary highpass filter
+ gi = new double [22];
+ gi[21] = 0.0000211708;
+ gi[20] = 0.0012780664;
+ gi[19] = -0.0029648612;
+ gi[18] = -0.0144283733;
+ gi[17] = 0.0503067404;
+ gi[16] = 0.0044659104;
+ gi[15] = -0.1999654035;
+ gi[14] = 0.2603015239;
+ gi[13] = 0.0013800055;
+ gi[12] = -0.2232934469;
+ gi[11] = 0.1795460286;
+ gi[10] = -0.1795460286;
+ gi[9] = 0.2232934469;
+ gi[8] = -0.0013800055;
+ gi[7] = -0.2603015239;
+ gi[6] = 0.1999654035;
+ gi[5] = -0.0044659104;
+ gi[4] = -0.0503067404;
+ gi[3] = 0.0144283733;
+ gi[2] = 0.0029648612;
+ gi[1] = -0.0012780664;
+ gi[0] = -0.0000211708;
+ break;
+
+ default:
+ throw(new RuntimeException("Invalid length"));
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/src-plugins/wavelets/wavelets/ComplexWavelet.java b/src-plugins/wavelets/wavelets/ComplexWavelet.java
new file mode 100644
index 0000000000..aaa6476662
--- /dev/null
+++ b/src-plugins/wavelets/wavelets/ComplexWavelet.java
@@ -0,0 +1,490 @@
+package wavelets;
+
+/**
+ * This class make the Complex wavelets transformation ans its inverse.
+ *
+ * @author
+ *
+ * @author
+ *
+ * Daniel Sage
+ * Biomedical Imaging Group (BIG),
+ * Ecole Polytechnique Federale de Lausanne (EPFL), Lausanne, Switzerland
+ * More information: http://bigwww.epfl.ch/
+ * You'll be free to use this software for research purposes, but you should
+ * not redistribute it without our consent. In addition, we expect you to
+ * include a citation or acknowledgement whenever you present or publish
+ * results that are based on it.
+ *
+ * @version
+ * 11 July 2009
+ */
+
+ public class ComplexWavelet {
+
+ /**
+ * This public method computes the complex wavelets transform of a given image
+ * and a given number of scale.
+ *
+ * @param in input image
+ * @param n number of scale
+ * @param length
+ * @return the wavelets coefficients
+ */
+ static public ImageAccess[] analysis(ImageAccess in, int n, int length) {
+
+ // Compute the size to the fine and coarse levels
+ int nxfine = in.getWidth();
+ int nyfine = in.getHeight();
+
+ // Declare the object image
+ ImageAccess sub1;
+ ImageAccess sub2;
+ ImageAccess sub3;
+ ImageAccess sub4;
+ ImageAccess subre;
+ ImageAccess subim;
+ ImageAccess outRe;
+ ImageAccess outIm;
+
+ // Initialization
+ int nx = nxfine;
+ int ny = nyfine;
+ outRe = in.duplicate();
+ outIm = in.duplicate();
+
+ int re = 0;
+ int im = 1;
+
+ // From fine to coarse main loop
+ // first iteration
+
+ subre = new ImageAccess(nx, ny);
+ sub1 = new ImageAccess(nx, ny);
+ sub2 = new ImageAccess(nx, ny);
+
+
+ // Copy in[] into image[]
+ outRe.getSubImage(0,0,subre);
+
+
+ // Apply the Wavelet splitting
+ sub1 = split(subre, re, re, length);
+ sub2 = split(subre, im, im, length);
+
+ sub1.subtract(sub1, sub2);
+
+ // Put the result image[] into in[]
+ outRe.putSubImage(0,0,sub1);
+
+ // Apply the Wavelet splitting
+ sub1 = split(subre, re, im, length);
+ sub2 = split(subre, im, re, length);
+
+ sub1.add(sub1, sub2);
+
+ outIm.putSubImage(0,0,sub1);
+
+ // Reduce the size by a factor of 2
+ nx = nx / 2;
+ ny = ny / 2;
+
+ for ( int i=1; i= 1 ) {
+ double rowin[] = new double[nx];
+ double rowout[] = new double[nx];
+ for (int y=0; y 1 ) {
+ double colin[] = new double[ny];
+ double colout[] = new double[ny];
+ for (int x=0; x=n) { // Periodic conditions
+ j1 = (j1) % n;
+ }
+ pix = pix + h[k]*vin[j1];
+ }
+ voutL[i] = pix;
+ }
+
+ for (int i=0; i=n) { // Periodic conditions
+ j1 = (j1) % n;
+ }
+ pix = pix + g[k]*vin[j1];
+ }
+ voutH[i] = pix;
+ }
+
+ for (int k=0; k= 1 ) {
+ double rowin[] = new double[nx];
+ double rowout[] = new double[nx];
+ for (int y=0; y 1 ) {
+ double colin[] = new double[ny];
+ double colout[] = new double[ny];
+ for (int x=0; x=n) { // Periodic conditions
+ j1 = (j1) % n;
+ }
+ pix = pix + h[k]*vinL[j1];
+ }
+ vout[i] = pix;
+ }
+
+
+ for (int i=0; i=n) { // Periodic conditions
+ j1 = (j1) % n;
+ }
+ pix = pix + g[k]*vinH[j1];
+ }
+ vout[i] = vout[i] + pix;
+ }
+ }
+
+ /**
+ * This method computes the modulus from a real ImageAccess and a
+ * imaginary ImageAccess objects.
+ *
+ * @param inRe
+ * @param inIm
+ * @return modulus
+ */
+ static public ImageAccess modulus(ImageAccess inRe, ImageAccess inIm) {
+ int nx = inRe.getWidth();
+ int ny = inRe.getHeight();
+ double m,r,i;
+ ImageAccess modulus = new ImageAccess(nx,ny);
+ int x,y;
+ for (x=0; x
+ * Daniel Sage
+ * Biomedical Imaging Group (BIG),
+ * Ecole Polytechnique Federale de Lausanne (EPFL), Lausanne, Switzerland
+ * More information: http://bigwww.epfl.ch/teaching/iplabsite/
+ * Reference: D. Sage, M. Unser,
+ * "
+ * Teaching Image-Processing Programming in Java," IEEE Signal
+ * Processing Magazine, vol. 20, no. 6, pp. 43-52, November 2003.
+ *
+ * You'll be free to use this software for research purposes, but you should
+ * not redistribute it without our consent. In addition, we expect you to
+ * include a citation or acknowledgement whenever you present or publish
+ * results that are based on it.
+ *
+ * @version
+ * 11 July 2009
+ */
+
+public class ImageAccess {
+ public static final int PATTERN_SQUARE_3x3 = 0;
+ public static final int PATTERN_CROSS_3x3 = 1;
+
+ private double pixels[] = null; // store the pixel data
+ private int nx = 0; // size in X axis
+ private int ny = 0; // size in Y axis
+ private int size = 0; // size = nx*ny
+
+ /**
+ * Creates a new ImageAccess object from a 2D double array of pixels.
+ * The size of the array determines the size of the image.
+ *
+ * @param array an array of pixel (2D)
+ */
+ public ImageAccess(double[][] array) {
+ if (array == null)
+ throw new
+ ArrayStoreException("Constructor: array == null.");
+ this.ny = array[0].length;
+ this.nx = array.length;
+ this.size = nx*ny;
+ pixels = new double[size];
+ int k = 0;
+ for (int j=0; j 2)
+ throw new
+ ArrayStoreException("Constructor: colorPlane > 2.");
+ nx = cp.getWidth();
+ ny = cp.getHeight();
+ size = nx*ny;
+ pixels = new double[size];
+ byte[] r = new byte[size];
+ byte[] g = new byte[size];
+ byte[] b = new byte[size];
+ cp.getRGB(r, g, b);
+ if (colorPlane == 0)
+ for (int k=0; k maxi)
+ maxi = pixels[i];
+ return maxi;
+ }
+
+ /**
+ * Return the minimum value of ImageAccess.
+ *
+ * @return the minimum value
+ */
+ public double getMinimum() {
+ double mini = pixels[0];
+ for (int i=1; i 255.0)
+ p = 255.0;
+ bsrc[k] = (byte)p;
+ }
+ bp.setPixels(bsrc);
+ return bp;
+ }
+
+ /**
+ * Create a new ImageAccess object by duplication of the current the
+ * ImageAccess object.
+ *
+ * @return a new ImageAccess object
+ **/
+ public ImageAccess duplicate() {
+ ImageAccess ia = new ImageAccess(nx, ny);
+ for (int i=0; i= nx) x = periodx - x; // Symmetrize
+ }
+ else if (x>=nx) {
+ while (x>=nx) x -= periodx; // Periodize
+ if (x < 0) x = -x; // Symmetrize
+ }
+
+ if (y<0) {
+ while (y<0) y += periody; // Periodize
+ if (y>=ny) y = periody - y; // Symmetrize
+ }
+ else if (y>=ny) {
+ while (y>=ny) y -= periody; // Periodize
+ if (y < 0) y = -y; // Symmetrize
+ }
+ return pixels[x+y*nx];
+ }
+
+ /**
+ * An ImageAccess object calls this method for getting
+ * the gray level of a selected pixel using a bilinear interpolation.
+ * The coordinates can be given in double and the
+ * bilinear interpolation is applied the find the gray level.
+ *
+ * Mirror border conditions are applied.
+ *
+ * @param x input, the double x-coordinate of a pixel
+ * @param y input, the double y-coordinate of a pixel
+ * @return the gray level of the pixel (double)
+ */
+ public double getInterpolatedPixel(double x, double y) {
+ if (Double.isNaN(x))
+ return 0;
+ if (Double.isNaN(y))
+ return 0;
+
+ if ( x < 0) {
+ int periodx = 2*nx - 2;
+ while (x < 0) x += periodx; // Periodize
+ if (x >= nx) x = periodx - x; // Symmetrize
+ }
+ else if ( x >= nx) {
+ int periodx = 2*nx - 2;
+ while (x >= nx) x -= periodx; // Periodize
+ if (x < 0) x = - x; // Symmetrize
+ }
+
+ if ( y < 0) {
+ int periody = 2*ny - 2;
+ while (y < 0) y += periody; // Periodize
+ if (y >= ny) y = periody - y; // Symmetrize
+ }
+ else if ( y >= ny) {
+ int periody = 2*ny - 2;
+ while (y >= ny) y -= periody; // Periodize
+ if (y < 0) y = - y; // Symmetrize
+ }
+ int i;
+ if (x >= 0.0)
+ i = (int)x;
+ else {
+ final int iAdd = (int)x - 1;
+ i = ((int)(x - (double)iAdd) + iAdd);
+ }
+ int j;
+ if (y >= 0.0)
+ j = (int)y;
+ else {
+ final int iAdd = (int)y - 1;
+ j = ((int)(y - (double)iAdd) + iAdd);
+ }
+
+ double dx = x - (double)i;
+ double dy = y - (double)j;
+ int di;
+ if(i >= nx-1)
+ di = -1;
+ else
+ di = 1;
+ int index = i+j*nx;
+ double v00 = pixels[index];
+ double v10 = pixels[index+di];
+ if(j>=ny-1)
+ index -= nx;
+ else
+ index += nx;
+ double v01 = pixels[index];
+ double v11 = pixels[index+di];
+ return (dx*(v11*dy-v10*(dy-1.0)) - (dx-1.0)*(v01*dy-v00*(dy-1.0)));
+ }
+
+ /**
+ * An ImageAccess object calls this method for getting a
+ * whole column of the image.
+ *
+ * The column should already created with the correct size [ny].
+ *
+ * @param x input, the integer x-coordinate of a column
+ * @param column output, an array of the type double
+ */
+ public void getColumn(int x, double[] column) {
+ if (x < 0)
+ throw new IndexOutOfBoundsException("getColumn: x < 0.");
+ if (x >= nx)
+ throw new IndexOutOfBoundsException("getColumn: x >= nx.");
+ if (column == null)
+ throw new
+ ArrayStoreException("getColumn: column == null.");
+ if (column.length != ny)
+ throw new
+ ArrayStoreException("getColumn: column.length != ny.");
+ for (int i=0; i= nx)
+ throw new IndexOutOfBoundsException("getColumn: x >= nx.");
+ if (column == null)
+ throw new ArrayStoreException("getColumn: column == null.");
+ int by = column.length;
+ if (y >= 0)
+ if (y < ny-by-1) {
+ int index = y*nx + x;
+ for (int i = 0; i < by; i++) {
+ column[i] = pixels[index];
+ index+=nx;
+ }
+ return;
+ }
+ // Getting information outside of the image
+ int yt[] = new int[by];
+ for (int k = 0; k < by; k++) {
+ int ya = y + k;
+ int periody = 2*ny - 2;
+ while (ya < 0) ya += periody; // Periodize
+ while (ya >= ny) {
+ ya = periody - ya; // Symmetrize
+ if (ya < 0) ya = - ya;
+ }
+ yt[k] = ya;
+ }
+ int index = 0;
+ for (int i = 0; i < by; i++) {
+ index = yt[i]*nx+x;
+ column[i] = pixels[index];
+ }
+ }
+
+ /**
+ * An ImageAccess object calls this method for getting a
+ * whole row of the image.
+ *
+ * The row should already created with the correct size [nx].
+ *
+ * @param y input, the integer y-coordinate of a row
+ * @param row output, an array of the type double
+ */
+ public void getRow(int y, double[] row) {
+ if ( y < 0)
+ throw new IndexOutOfBoundsException("getRow: y < 0.");
+ if (y >= ny)
+ throw new IndexOutOfBoundsException("getRow: y >= ny.");
+ if (row == null)
+ throw new
+ ArrayStoreException("getColumn: row == null.");
+ if (row.length != nx)
+ throw new
+ ArrayStoreException("getColumn: row.length != nx.");
+ y *= nx;
+ for (int i=0; i= ny)
+ throw new IndexOutOfBoundsException("getRow: y >= ny.");
+ if (row == null)
+ throw new ArrayStoreException("getRow: row == null.");
+ int bx = row.length;
+ if (x >=0)
+ if (x < nx-bx-1){
+ int index = y*nx + x;
+ for (int i = 0; i < bx; i++) {
+ row[i] = pixels[index++];
+ }
+ return;
+ }
+ int periodx = 2*nx - 2;
+ int xt[] = new int[bx];
+ for (int k = 0; k < bx; k++) {
+ int xa = x + k;
+ while (xa < 0) xa += periodx; // Periodize
+ while (xa >= nx) {
+ xa = periodx - xa; // Symmetrize
+ if (xa < 0) xa = - xa;
+ }
+ xt[k] = xa;
+ }
+ int somme = 0;
+ int index = y*nx;
+ for (int i = 0; i < bx; i++) {
+ somme =index+xt[i];
+ row[i] = pixels[somme];
+ }
+ }
+
+ /**
+ * An ImageAccess object calls this method for getting a neighborhood
+ * arround a pixel position.
+ *
+ * The neigh parameter should already created. The size of the array
+ * determines the neighborhood block.
+ *
+ *
Mirror border conditions are applied.
+ *
+ *
The pixel value of (x-n/2, y-n/2) is put into neigh[0][0]
+ *
...
+ *
The pixel value of (x+n/2, y+n/2) is put into neigh[n-1][n-1]
+ *
+ *
For example if neigh is a double[4][4]:
+ *
The pixel value of (x-1, y-1) is put into neigh[0][0]
+ *
The pixel value of (x , y ) is put into neigh[1][1]
+ *
The pixel value of (x, y+1) is put into neigh[1][2]
+ *
The pixel value of (x+1, y-2) is put into neigh[2][0]
+ *
...
+ *
For example if neigh is a double[5][5]:
+ *
The pixel value of (x-2, y-2) is put into neigh[0][0]
+ *
The pixel value of (x-1, y-1) is put into neigh[1][1]
+ *
The pixel value of (x , y ) is put into neigh[2][2]
+ *
The pixel value of (x, y+1) is put into neigh[2][3]
+ *
The pixel value of (x+2, y-2) is put into neigh[4][0]
+
+ * @param x the integer x-coordinate of a selected central pixel
+ * @param y the integer y-coordinate of a selected central pixel
+ * @param neigh output, a 2D array s
+ */
+ public void getNeighborhood(int x, int y, double neigh[][]) {
+ int bx=neigh.length;
+ int by=neigh[0].length;
+ int bx2 = (bx-1)/2;
+ int by2 = (by-1)/2;
+ if (x >= bx2)
+ if (y >= by2)
+ if (x < nx-bx2-1)
+ if (y < ny-by2-1) {
+ int index = (y-by2)*nx + (x-bx2);
+ for (int j = 0; j < by; j++) {
+ for (int i = 0; i < bx; i++) {
+ neigh[i][j] = pixels[index++];
+ }
+ index += (nx - bx);
+ }
+ return;
+ }
+ int xt[] = new int[bx];
+ for (int k = 0; k < bx; k++) {
+ int xa = x + k - bx2;
+ int periodx = 2*nx - 2;
+ while (xa < 0)
+ xa += periodx; // Periodize
+ while (xa >= nx) {
+ xa = periodx - xa; // Symmetrize
+ if (xa < 0) xa = - xa;
+ }
+ xt[k] = xa;
+ }
+ int yt[] = new int[by];
+ for (int k = 0; k < by; k++) {
+ int ya = y + k - by2;
+ int periody = 2*ny - 2;
+ while (ya < 0) ya += periody; // Periodize
+ while (ya >= ny) {
+ ya = periody - ya; // Symmetrize
+ if (ya < 0) ya = - ya;
+ }
+ yt[k] = ya;
+ }
+ int sum=0;
+ for (int j = 0; j < by; j++) {
+ int index = yt[j]*nx;
+ for (int i = 0; i < bx; i++) {
+ sum =index+xt[i];
+ neigh[i][j] = pixels[sum];
+ }
+ }
+ }
+
+ /**
+ * An ImageAccess object calls this method for getting a
+ * neighborhood of a predefined pattern around a selected pixel (x,y).
+ *
The available patterns are:
+ *
- a 3*3 block: PATTERN_SQUARE_3x3 (8-connect)
+ *
- a 3*3 cross: PATTERN_CROSS_3x3 (4-connect)
+ *
+ *
Mirror border conditions are applied.
+ *
The pixel is arranged in a 1D array according the following rules:
+ *
+ *
If the pattern is PATTERN_SQUARE_3x3 (8-connect)
+ *
The pixel value of (x-1, y-1) are put into neigh[0]
+ *
The pixel value of (x , y-1) are put into neigh[1]
+ *
The pixel value of (x+1, y-1) are put into neigh[2]
+ *
The pixel value of (x-1, y ) are put into neigh[3]
+ *
The pixel value of (x , y ) are put into neigh[4]
+ *
The pixel value of (x+1, y ) are put into neigh[5]
+ *
The pixel value of (x-1, y+1) are put into neigh[6]
+ *
The pixel value of (x , y+1) are put into neigh[7]
+ *
The pixel value of (x+1, y+1) are put into neigh[8]
+ *
+ *
If the pattern is PATTERN_CROSS_3x3 (4-connect)
+ *
The pixel value of (x , y-1) are put into neigh[0]
+ *
The pixel value of (x-1, y ) are put into neigh[1]
+ *
The pixel value of (x , y ) are put into neigh[2]
+ *
The pixel value of (x+1, y ) are put into neigh[3]
+ *
The pixel value of (x , y+1) are put into neigh[4]
+ *
+ *
The neigh should already created as a double array of 9 elements
+ * for the PATTERN_SQUARE_3x3 or 5 elements for the PATTERN_CROSS_3x3.
+ *
+ * @param x x-coordinate of a selected central pixel
+ * @param y y-coordinate of a selected central pixel
+ * @param neigh output, an array consisting of 9 or 5 elements
+ * @param pattern PATTERN_SQUARE_3x3 or PATTERN_CROSS_3x3.
+ */
+ public void getPattern(int x, int y, double neigh[], int pattern) {
+ if (neigh == null)
+ throw new ArrayStoreException("getPattern: neigh == null.");
+ switch(pattern) {
+ case PATTERN_SQUARE_3x3:
+ if (neigh.length != 9)
+ throw new
+ ArrayStoreException("getPattern: neigh.length != 9.");
+ getPatternSquare3x3(x, y, neigh);
+ break;
+ case PATTERN_CROSS_3x3:
+ if (neigh.length != 5)
+ throw new
+ ArrayStoreException("getPattern: neigh.length != 5");
+ getPatternCross3x3(x, y, neigh);
+ break;
+ default:
+ throw new ArrayStoreException("getPattern: unexpected pattern.");
+ }
+ }
+ /**
+ * An ImageAccess object calls this method for getting
+ * a 3x3 neighborhood of 8-connected pixels around a selected pixel.
+ *
+ * @param x input, the integer x-coordinate of a selected central pixel
+ * @param y input, the integer y-coordinate of a selected central pixel
+ * @param neigh output, an array consisting of 9 elements of the type double
+ */
+ private void getPatternSquare3x3(int x, int y, double neigh[]) {
+ if (x >= 1)
+ if (y >= 1)
+ if (x < nx-1)
+ if (y < ny-1) {
+ int index = (y-1)*nx + (x-1);
+ neigh[0] = pixels[index++];
+ neigh[1] = pixels[index++];
+ neigh[2] = pixels[index];
+ index += (nx - 2);
+ neigh[3] = pixels[index++];
+ neigh[4] = pixels[index++];
+ neigh[5] = pixels[index];
+ index += (nx - 2);
+ neigh[6] = pixels[index++];
+ neigh[7] = pixels[index++];
+ neigh[8] = pixels[index];
+ return;
+ }
+ int x1 = x - 1;
+ int x2 = x;
+ int x3 = x + 1;
+ int y1 = y - 1;
+ int y2 = y;
+ int y3 = y + 1;
+ if ( x == 0)
+ x1 = x3;
+ if ( y == 0)
+ y1 = y3;
+ if ( x == nx-1)
+ x3 = x1;
+ if ( y == ny-1)
+ y3 = y1;
+ int offset = y1*nx;
+ neigh[0] = pixels[offset+x1];
+ neigh[1] = pixels[offset+x2];
+ neigh[2] = pixels[offset+x3];
+ offset = y2*nx;
+ neigh[3] = pixels[offset+x1];
+ neigh[4] = pixels[offset+x2];
+ neigh[5] = pixels[offset+x3];
+ offset = y3*nx;
+ neigh[6] = pixels[offset+x1];
+ neigh[7] = pixels[offset+x2];
+ neigh[8] = pixels[offset+x3];
+ }
+
+ /**
+ * An ImageAccess object calls this method for getting
+ * a 3x3 neighborhood of 4-connected pixels around a selected pixel.
+ *
+ * @param x input, the integer x-coordinate of a selected central pixel
+ * @param y input, the integer y-coordinate of a selected central pixel
+ * @param neigh output, an array consisting of 5 elements of the type double
+ */
+ private void getPatternCross3x3(int x, int y, double neigh[]) {
+ if (x >= 1)
+ if (y >= 1)
+ if (x < nx-1)
+ if (y < ny-1) {
+ int index = (y-1)*nx + x;
+ neigh[0] = pixels[index];
+ index += (nx - 1);
+ neigh[1] = pixels[index++];
+ neigh[2] = pixels[index++];
+ neigh[3] = pixels[index];
+ index += (nx - 1);
+ neigh[4] = pixels[index];
+ return;
+ }
+ int x1 = x - 1;
+ int x2 = x;
+ int x3 = x + 1;
+ int y1 = y - 1;
+ int y2 = y;
+ int y3 = y + 1;
+ if ( x == 0)
+ x1 = x3;
+ if ( y == 0)
+ y1 = y3;
+ if ( x == nx-1)
+ x3 = x1;
+ if ( y == ny-1)
+ y3 = y1;
+ int offset = y1*nx;
+ neigh[0] = pixels[offset+x2];
+ offset = y2*nx;
+ neigh[1] = pixels[offset+x1];
+ neigh[2] = pixels[offset+x2];
+ neigh[3] = pixels[offset+x3];
+ offset = y3*nx;
+ neigh[4] = pixels[offset+x2];
+ }
+
+ /**
+ * An ImageAccess object calls this method to get a sub-image
+ * with the upper left corner in the coordinate (x,y).
+ *
+ * The sub-image ouptut should be already created.
+ *
+ * @param x x-coordinate in the source image
+ * @param y y-coordinate in the source image
+ * @param output an ImageAccess object with the sub-image;
+ */
+ public void getSubImage(int x, int y, ImageAccess output) {
+ if (output == null)
+ throw new ArrayStoreException("getSubImage: output == null.");
+ if (x<0)
+ throw new ArrayStoreException("getSubImage: Incompatible image size");
+ if (y<0)
+ throw new ArrayStoreException("getSubImage: Incompatible image size");
+ if (x>=nx)
+ throw new ArrayStoreException("getSubImage: Incompatible image size");
+ if (y>=ny)
+ throw new ArrayStoreException("getSubImage: Incompatible image size");
+ int nxcopy = output.getWidth();
+ int nycopy = output.getHeight();
+ double[][] neigh = new double[nxcopy][nycopy];
+ int nx2 = (nxcopy-1)/2;
+ int ny2 = (nycopy-1)/2;
+ this.getNeighborhood(x+nx2, y+ny2, neigh);
+ output.putArrayPixels(neigh);
+ }
+
+ /**
+ * An ImageAccess object calls this method in order a value
+ * of the gray level to be put to a position inside it
+ * given by the coordinates.
+ *
+ * @param x input, the integer x-coordinate of a pixel
+ * @param y input, the integer y-coordinate of a pixel
+ * @param value input, a value of the gray level of the type double
+ */
+ public void putPixel(int x, int y, double value) {
+ if (x < 0)
+ return;
+ if (x >= nx)
+ return;
+ if (y < 0)
+ return;
+ if (y >= ny)
+ return;
+ pixels[x+y*nx] = value;
+ }
+
+ /**
+ * An ImageAccess object calls this method to put a whole
+ * column in a specified position into the image.
+ *
+ * @param x input, the integer x-coordinate of a column
+ * @param column input, an array of the type double
+ */
+ public void putColumn (int x, double[] column) {
+ if (x < 0)
+ throw new IndexOutOfBoundsException("putColumn: x < 0.");
+ if (x >= nx)
+ throw new IndexOutOfBoundsException("putColumn: x >= nx.");
+ if (column == null)
+ throw new ArrayStoreException("putColumn: column == null.");
+ if (column.length != ny)
+ throw new ArrayStoreException("putColumn: column.length != ny.");
+ for (int i=0; i= nx)
+ throw new IndexOutOfBoundsException("putColumn: x >= nx.");
+ if (column == null)
+ throw new ArrayStoreException("putColumn: column == null.");
+ int by = column.length;
+ int index = y*nx+x;
+ int top=0;
+ int bottom=0;
+ if (y >=0) {
+ if (y < ny-by)
+ bottom = by;
+ else
+ bottom = -y+ny;
+ for (int i=top ; i= ny)
+ throw new IndexOutOfBoundsException("putRow: y >= ny.");
+ if (row == null)
+ throw new ArrayStoreException("putRow: row == null.");
+ if (row.length != nx)
+ throw new ArrayStoreException("putRow: row.length != nx.");
+ y *= nx;
+ for (int i=0; i= ny)
+ throw new IndexOutOfBoundsException("putRow: y >= ny.");
+ if (row == null)
+ throw new ArrayStoreException("putRow: row == null.");
+ int bx = row.length;
+ int index = y*nx+x;
+ int left=0;
+ int right=0;
+ if (x >=0){
+ if (x < nx-bx)
+ right=bx;
+ else
+ right=-x+nx;
+
+ for (int i = left; i < right; i++) {
+ pixels[index++] = row[i];
+ }
+ return;
+ }
+ else {
+ index = y*nx;
+ left=-x;
+
+ if (x < nx-bx)
+ right=bx;
+ else
+ right=-x+nx;
+
+ for (int i = left; i < right; i++) {
+ pixels[index++] = row[i];
+ }
+ }
+ }
+
+ /**
+ * An ImageAccess object calls this method in order to put
+ * an 2D array of double in an ImageAccess.
+ *
+ * @param array input, the double array
+ */
+ public void putArrayPixels(double[][] array) {
+ if (array == null)
+ throw new IndexOutOfBoundsException("putArrayPixels: array == null.");
+ int bx = array.length;
+ int by = array[0].length;
+ if (bx*by != size)
+ throw new IndexOutOfBoundsException("putArrayPixels: imcompatible size.");
+ int k = 0;
+ for (int j=0; j= nx)
+ throw new IndexOutOfBoundsException("putSubImage: x >= nx.");
+ if (y >= ny)
+ throw new IndexOutOfBoundsException("putSubImage: y >= ny.");
+ int nxcopy=input.getWidth();
+ int nycopy=input.getHeight();
+ // Reduces the size of the area to copy if it is too large
+ if (x+nxcopy>nx)
+ nxcopy = nx-x;
+ if (y+nycopy>ny)
+ nycopy = ny-y;
+ // Copies lines per lines
+ double[] dsrc = input.getPixels();
+ for ( int j=0; j
+ * Daniel Sage
+ * Biomedical Imaging Group (BIG),
+ * Ecole Polytechnique Federale de Lausanne (EPFL), Lausanne, Switzerland
+ * More information: http://bigwww.epfl.ch/
+ * You'll be free to use this software for research purposes, but you should
+ * not redistribute it without our consent. In addition, we expect you to
+ * include a citation or acknowledgement whenever you present or publish
+ * results that are based on it.
+ *
+ * @version
+ * 11 July 2009
+ */
+
+public class WaveSpline {
+
+ /**
+ * Perform an wavelet transformation of the ImageObject
+ * calling this method with n scale. The size of image should
+ * be a interger factor of 2 at the power n.
+ * The input is an image.
+ * The result is the wavelet coefficients. It is put in the ImageObject
+ * calling this method.
+ *
+ * @param in an ImageAcess object provided by ImageJ
+ * @param n a integer value giving the number of scale
+ */
+ static public ImageAccess analysis(ImageAccess in, int order, int n) {
+
+ // Compute the size to the fine and coarse levels
+ int nxfine = in.getWidth();
+ int nyfine = in.getHeight();
+
+ // Declare the object image
+ ImageAccess sub;
+
+ // Initialization
+ int nx = nxfine;
+ int ny = nyfine;
+ ImageAccess out = in.duplicate();
+
+ // From fine to coarse main loop
+ for ( int i=0; i= 1 ) {
+ double rowin[] = new double[nx];
+ double rowout[] = new double[nx];
+ for (int y=0; y 1 ) {
+ double colin[] = new double[ny];
+ double colout[] = new double[ny];
+ for (int x=0; x Haar Transform
+ /////////////////////////////////////////////
+ if ((nh<=1) || (ng<=1)) {
+ double sqrt2 = Math.sqrt(2);
+ int j;
+ for(int i=0; i= n) j1 = period - j1; // Symmetrize
+ }
+ j2 = j + k;
+ if (j2>=n) { // Mirror conditions
+ while (j2>=n) j2 -= period; // Periodize
+ if (j2 < 0) j2 = -j2; // Symmetrize
+ }
+ pix = pix + h[k]*(vin[j1]+vin[j2]);
+ }
+ vout[i] = pix;
+
+ j=j+1;
+ pix = vin[j] * g[0]; // High pass part
+ for (k=1;k= n) j1 = period - j1; // Symmetrize
+ }
+ j2 = j + k;
+ if (j2>=n) { // Mirror conditions
+ while (j2>=n) j2 -= period; // Periodize
+ if (j2 < 0) j2 = -j2; // Symmetrize
+ }
+ pix = pix + g[k]*(vin[j1]+vin[j2]);
+ }
+ vout[i+n2] = pix;
+ }
+ }
+
+ /**
+ * Perform an inverse wavelet transformation of the ImageObject
+ * calling this method with n scale. The size of image should
+ * be a interger factor of 2 at the power n.
+ * The input is the results of a wavelet transformation.
+ * The result is the reconstruction. It is put in the ImageObject
+ * calling this method.
+ *
+ * @param in an ImageAcess object provided by ImageJ
+ * @param n a integer value giving the number of scale
+ */
+
+ static public ImageAccess synthesis(ImageAccess in, int order, int n) {
+ // Compute the size to the fine and coarse levels
+ int div = (int)Math.pow(2.0, (double)(n-1));
+ int nxcoarse = in.getWidth() / div;
+ int nycoarse = in.getHeight() / div;
+
+ // Declare the object image
+ ImageAccess sub;
+
+ // Initialisazion
+ int nx = nxcoarse;
+ int ny = nycoarse;
+ ImageAccess out = in.duplicate();
+
+ // From fine to coarse main loop
+ for ( int i=0; i= 1 ) {
+ double rowin[] = new double[nx];
+ double rowout[] = new double[nx];
+ for (int y=0; y 1 ) {
+ double colin[] = new double[ny];
+ double colout[] = new double[ny];
+ for (int x=0; x Haar Transform
+ /////////////////////////////////////////////
+ if ((nh<=1) || (ng<=1)) {
+ double sqrt2 = Math.sqrt(2);
+ for (int i=0; i=n2) i1 = period-i1;
+ }
+ i2 = i+(k/2);
+ if (i2>n2-1) {
+ i2 = i2 % period;
+ if (i2>=n2) i2 = period-i2;
+ }
+ pix1 = pix1 + h[k]*(vin[i1]+vin[i2]);
+ }
+
+ pix2=0.;
+ for(k=-k02; k=n2) i1 = period-1-i1;
+ }
+ if (i1>=n2) {
+ i1 = i1 % period;
+ if (i1>=n2) i1 = period-1-i1;
+ }
+ pix2 = pix2 + g[kk]*vin[i1+n2];
+ }
+
+ vout[j] = pix1 + pix2;
+
+ j = j+1;
+ pix1 = 0.;
+ for (k=-k01; k=n2) i1 = period-i1;
+ }
+ if (i1>=n2) {
+ i1 = (i1) % period;
+ if (i1>=n2) i1 = period-i1;
+ }
+ pix1 = pix1 + h[kk]*vin[i1];
+ }
+ pix2 = g[0] * vin[i+n2];
+ for (k=2; k=n2) i1 = period-1-i1;
+ }
+ i2 = i+(k/2);
+ if (i2>n2-1) {
+ i2 = i2 % period;
+ if (i2>=n2) i2 = period-1-i2;
+ }
+ pix2 = pix2 + g[k]*(vin[i1+n2]+vin[i2+n2]);
+ }
+ vout[j] = pix1 + pix2;
+ }
+ }
+
+}
diff --git a/src-plugins/wavelets/wavelets/WaveSplineFilter.java b/src-plugins/wavelets/wavelets/WaveSplineFilter.java
new file mode 100644
index 0000000000..e367eff418
--- /dev/null
+++ b/src-plugins/wavelets/wavelets/WaveSplineFilter.java
@@ -0,0 +1,257 @@
+package wavelets;
+
+/**
+ * This class generates the Spline wavelets filters.
+ *
+ * @author
+ *
+ * Daniel Sage
+ * Biomedical Imaging Group (BIG),
+ * Ecole Polytechnique Federale de Lausanne (EPFL), Lausanne, Switzerland
+ * More information: http://bigwww.epfl.ch/
+ * You'll be free to use this software for research purposes, but you should
+ * not redistribute it without our consent. In addition, we expect you to
+ * include a citation or acknowledgement whenever you present or publish
+ * results that are based on it.
+ *
+ * @version
+ * 11 July 2009
+ */
+
+public class WaveSplineFilter {
+
+ /**
+ * real lowpass filter.
+ */
+ public double h[];
+
+ /**
+ * real highpass filter.
+ */
+ public double g[];
+
+ WaveSplineFilter(int order) {
+ switch (order) {
+
+ case 0:
+ h = new double[1];
+ h[0] = Math.sqrt(2.0);
+ break;
+
+ case 1:
+ h = new double[47];
+ h[0 ] = 0.81764640621546;
+ h[1 ] = 0.39729708810751;
+ h[2 ] = -0.06910098743038;
+ h[3 ] = -0.05194534825542;
+ h[4 ] = 0.01697104840045;
+ h[5 ] = 0.00999059568192;
+ h[6 ] = -0.00388326235731;
+ h[7 ] = -0.00220195129177;
+ h[8 ] = 0.00092337104427;
+ h[9 ] = 0.00051163604209;
+ h[10] = -0.00022429633694;
+ h[11] = -0.00012268632858;
+ h[12] = 0.00005535633860;
+ h[13] = 0.00003001119291;
+ h[14] = -0.00001381880394;
+ h[15] = -0.00000744435611;
+ h[16] = 0.00000347980027;
+ h[17] = 0.00000186561005;
+ h[18] = -0.00000088225856;
+ h[19] = -0.00000047122304;
+ h[20] = 0.00000022491351;
+ h[21] = 0.00000011976480;
+ h[22] = -0.00000005759525;
+ h[23] = -0.00000003059265;
+ h[24] = 0.00000001480431;
+ h[25] = 0.00000000784714;
+ h[26] = -0.00000000381742;
+ h[27] = -0.00000000201987;
+ h[28] = 0.00000000098705;
+ h[29] = 0.00000000052147;
+ h[30] = -0.00000000025582;
+ h[31] = -0.00000000013497;
+ h[32] = 0.00000000006644;
+ h[33] = 0.00000000003501;
+ h[34] = -0.00000000001729;
+ h[35] = -0.00000000000910;
+ h[36] = 0.00000000000451;
+ h[37] = 0.00000000000237;
+ h[38] = -0.00000000000118;
+ h[39] = -0.00000000000062;
+ h[40] = 0.00000000000031;
+ h[41] = 0.00000000000016;
+ h[42] = -0.00000000000008;
+ h[43] = -0.00000000000004;
+ h[44] = 0.00000000000002;
+ h[45] = 0.00000000000001;
+ break;
+
+ case 3:
+ double temp[] = {
+ 0.76613005375980,
+ 0.43392263358931,
+ -0.05020172467149,
+ -0.11003701838811,
+ 0.03208089747022,
+ 0.04206835144072,
+ -0.01717631549201,
+ -0.01798232098097,
+ 0.00868529481309,
+ 0.00820147720600,
+ -0.00435383945777,
+ -0.00388242526560,
+ 0.00218671237015,
+ 0.00188213352389,
+ -0.00110373982039,
+ -0.00092719873146,
+ 0.00055993664336,
+ 0.00046211522752,
+ -0.00028538371867,
+ -0.00023234729403,
+ 0.00014604186978,
+ 0.00011762760216,
+ -0.00007499842461,
+ -0.00005987934057,
+ 0.00003863216129,
+ 0.00003062054907,
+ -0.00001995254847,
+ -0.00001571784835,
+ 0.00001032898225,
+ 0.00000809408097,
+ -0.00000535805976
+ -0.00000417964096,
+ 0.00000278450629,
+ 0.00000216346143,
+ -0.00000144942177,
+ -0.00000112219704,
+ 0.00000075557065,
+ 0.00000058316635,
+ -0.00000039439119,
+ -0.00000030355006,
+ 0.00000020610937,
+ 0.00000015823692,
+ -0.00000010783016,
+ -0.00000008259641,
+ 0.00000005646954,
+ 0.00000004316539,
+ -0.00000002959949,
+ -0.00000002258313,
+ 0.00000001552811,
+ 0.00000001182675,
+ -0.00000000815248,
+ -0.00000000619931,
+ 0.00000000428324,
+ 0.00000000325227,
+ -0.00000000225188,
+ -0.00000000170752,
+ 0.00000000118465,
+ 0.00000000089713,
+ -0.00000000062357,
+ -0.00000000047167,
+ 0.00000000032841,
+ 0.00000000024814,
+ -0.00000000017305,
+ -0.00000000013062,
+ 0.00000000009123,
+ 0.00000000006879,
+ -0.00000000004811,
+ -0.00000000003625,
+ 0.00000000002539,
+ 0.00000000001911,
+ -0.00000000001340,
+ -0.00000000001008,
+ 0.00000000000708,
+ 0.00000000000532,
+ -0.00000000000374,
+ -0.00000000000281,
+ 0.00000000000198,
+ 0.00000000000148,
+ -0.00000000000104,
+ -0.00000000000078,
+ 0.00000000000055,
+ 0.00000000000041,
+ -0.00000000000029,
+ -0.00000000000022,
+ 0.00000000000015,
+ 0.00000000000012,
+ -0.00000000000008
+ -0.00000000000006,
+ 0.00000000000004,
+ 0.00000000000003,
+ -0.00000000000002,
+ -0.00000000000002,
+ 0.00000000000001,
+ 0.00000000000001,
+ -0.00000000000001,
+ -0.00000000000000
+ };
+ h = temp;
+ break;
+
+
+ case 5:
+ h = new double[42];
+ h[0 ] = 0.74729;
+ h[1 ] = 0.4425;
+ h[2 ] = -0.037023;
+ h[3 ] = -0.12928;
+ h[4 ] = 0.029477;
+ h[5 ] = 0.061317;
+ h[6 ] = -0.021008;
+ h[7 ] = -0.032523;
+ h[8 ] = 0.014011;
+ h[9 ] = 0.01821;
+ h[10] = -0.0090501;
+ h[11] = -0.010563;
+ h[12] = 0.0057688;
+ h[13] = 0.0062796;
+ h[14] = -0.0036605;
+ h[15] = -0.0037995;
+ h[16] = 0.0023214;
+ h[17] = 0.0023288;
+ h[18] = -0.0014738;
+ h[19] = -0.0014414;
+ h[20] = 0.00093747;
+ h[21] = 0.00089889;
+ h[22] = -0.00059753;
+ h[23] = -0.00056398;
+ h[24] = 0.00038165;
+ h[25] = 0.00035559;
+ h[26] = -0.00024423;
+ h[27] = -0.00022512;
+ h[28] = 0.00015658;
+ h[29] = 0.00014301;
+ h[30] = -0.00010055;
+ h[31] = -9.1113e-05;
+ h[32] = 6.4669e-05;
+ h[33] = 5.8198e-05;
+ h[34] = -4.1649e-05;
+ h[35] = -3.7256e-05;
+ h[36] = 2.729e-05;
+ h[37] = 2.458e-05;
+ h[38] = -2.2593e-05;
+ h[39] = -3.5791e-05;
+ h[40] = -1.7098e-05;
+ h[41] = -2.9619e-06;
+ break;
+ }
+
+ g = new double[h.length];
+ if (order > 0) {
+ g[0] = h[0];
+ for ( int k = 1; k < h.length; k++) {
+ if ((k/2)*2 == k)
+ g[k] = h[k];
+ else
+ g[k] = -h[k];
+ }
+ }
+ else {
+ g[0] = -h[0];
+ }
+
+ }
+
+}
\ No newline at end of file
From 029cc4ff4054b04dd6a9650b59e66789a84a8fe6 Mon Sep 17 00:00:00 2001
From: Daniel Sage
Date: Thu, 23 Dec 2010 16:46:17 +0100
Subject: [PATCH 2/5] Add the 'imageware' library
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This library is the basis for many plugins from the Biomedical Imaging
Group at the École polytechnique fédérale de Lausanne
(http://bigwww.epfl.ch/).
Signed-off-by: Johannes Schindelin
---
.gitignore | 1 +
Fakefile | 3 +-
src-plugins/imageware/imageware/Access.java | 161 ++
src-plugins/imageware/imageware/Buffer.java | 118 +
src-plugins/imageware/imageware/Builder.java | 704 +++++
.../imageware/imageware/ByteAccess.java | 1 +
.../imageware/imageware/ByteBuffer.java | 1 +
.../imageware/imageware/BytePointwise.java | 1 +
.../imageware/imageware/ByteProcess.java | 1 +
src-plugins/imageware/imageware/ByteSet.java | 1 +
.../imageware/imageware/Convolver.java | 1 +
src-plugins/imageware/imageware/Display.java | 1 +
.../imageware/imageware/DoubleAccess.java | 1 +
.../imageware/imageware/DoubleBuffer.java | 2519 ++++++++++++++++
.../imageware/imageware/DoublePointwise.java | 1 +
.../imageware/imageware/DoubleProcess.java | 1 +
.../imageware/imageware/DoubleSet.java | 1 +
src-plugins/imageware/imageware/FMath.java | 1 +
.../imageware/imageware/FloatAccess.java | 1 +
.../imageware/imageware/FloatBuffer.java | 1 +
.../imageware/imageware/FloatPointwise.java | 1 +
.../imageware/imageware/FloatProcess.java | 1 +
src-plugins/imageware/imageware/FloatSet.java | 1 +
.../imageware/imageware/ImageAccess.java | 1 +
.../imageware/imageware/ImageWare.java | 51 +
.../imageware/imageware/Pointwise.java | 47 +
src-plugins/imageware/imageware/Process.java | 22 +
.../imageware/imageware/ShortAccess.java | 1 +
.../imageware/imageware/ShortBuffer.java | 2520 +++++++++++++++++
.../imageware/imageware/ShortPointwise.java | 1 +
.../imageware/imageware/ShortProcess.java | 1 +
src-plugins/imageware/imageware/ShortSet.java | 1 +
32 files changed, 6167 insertions(+), 1 deletion(-)
create mode 100644 src-plugins/imageware/imageware/Access.java
create mode 100644 src-plugins/imageware/imageware/Buffer.java
create mode 100644 src-plugins/imageware/imageware/Builder.java
create mode 100644 src-plugins/imageware/imageware/ByteAccess.java
create mode 100644 src-plugins/imageware/imageware/ByteBuffer.java
create mode 100644 src-plugins/imageware/imageware/BytePointwise.java
create mode 100644 src-plugins/imageware/imageware/ByteProcess.java
create mode 100644 src-plugins/imageware/imageware/ByteSet.java
create mode 100644 src-plugins/imageware/imageware/Convolver.java
create mode 100644 src-plugins/imageware/imageware/Display.java
create mode 100644 src-plugins/imageware/imageware/DoubleAccess.java
create mode 100644 src-plugins/imageware/imageware/DoubleBuffer.java
create mode 100644 src-plugins/imageware/imageware/DoublePointwise.java
create mode 100644 src-plugins/imageware/imageware/DoubleProcess.java
create mode 100644 src-plugins/imageware/imageware/DoubleSet.java
create mode 100644 src-plugins/imageware/imageware/FMath.java
create mode 100644 src-plugins/imageware/imageware/FloatAccess.java
create mode 100644 src-plugins/imageware/imageware/FloatBuffer.java
create mode 100644 src-plugins/imageware/imageware/FloatPointwise.java
create mode 100644 src-plugins/imageware/imageware/FloatProcess.java
create mode 100644 src-plugins/imageware/imageware/FloatSet.java
create mode 100644 src-plugins/imageware/imageware/ImageAccess.java
create mode 100644 src-plugins/imageware/imageware/ImageWare.java
create mode 100644 src-plugins/imageware/imageware/Pointwise.java
create mode 100644 src-plugins/imageware/imageware/Process.java
create mode 100644 src-plugins/imageware/imageware/ShortAccess.java
create mode 100644 src-plugins/imageware/imageware/ShortBuffer.java
create mode 100644 src-plugins/imageware/imageware/ShortPointwise.java
create mode 100644 src-plugins/imageware/imageware/ShortProcess.java
create mode 100644 src-plugins/imageware/imageware/ShortSet.java
diff --git a/.gitignore b/.gitignore
index 4b3e3e93fb..c92f42b3be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -210,3 +210,4 @@
/plugins/Temporal_Color_Coder.jar
/plugins/Samples_.jar
/jars/wavelets.jar
+/jars/imageware.jar
diff --git a/Fakefile b/Fakefile
index a621901d3b..c9f95ad26e 100644
--- a/Fakefile
+++ b/Fakefile
@@ -204,7 +204,8 @@ PLUGIN_TARGETS=plugins/Jython_Interpreter.jar \
plugins/Temporal_Color_Coder.jar \
plugins/Samples_.jar \
jars/mij.jar \
- jars/wavelets.jar
+ jars/wavelets.jar \
+ jars/imageware.jar
all <- fiji $SUBMODULE_TARGETS $PLUGIN_TARGETS
diff --git a/src-plugins/imageware/imageware/Access.java b/src-plugins/imageware/imageware/Access.java
new file mode 100644
index 0000000000..e5b8940623
--- /dev/null
+++ b/src-plugins/imageware/imageware/Access.java
@@ -0,0 +1,161 @@
+package imageware;
+
+/**
+ * Class Access.
+ *
+ * @author Daniel Sage
+ * Biomedical Imaging Group
+ * Ecole Polytechnique Federale de Lausanne, Lausanne, Switzerland
+ */
+
+public interface Access extends Buffer {
+
+ // getPixel section
+ public double getPixel(int x, int y, int z);
+ public double getPixel(int x, int y, int z, byte boundaryConditions);
+ public double getInterpolatedPixel(double x, double y, double z);
+ public double getInterpolatedPixel(double x, double y, double z, byte boundaryConditions);
+
+ // putPixel section
+ public void putPixel(int x, int y, int z, double value);
+
+ // getBounded section
+
+ public void getBoundedX (int x, int y, int z, byte[] buffer);
+ public void getBoundedY (int x, int y, int z, byte[] buffer);
+ public void getBoundedZ (int x, int y, int z, byte[] buffer);
+ public void getBoundedXY (int x, int y, int z, byte[][] buffer);
+ public void getBoundedXZ (int x, int y, int z, byte[][] buffer);
+ public void getBoundedYZ (int x, int y, int z, byte[][] buffer);
+ public void getBoundedXYZ (int x, int y, int z, byte[][][] buffer);
+
+ public void getBoundedX (int x, int y, int z, short[] buffer);
+ public void getBoundedY (int x, int y, int z, short[] buffer);
+ public void getBoundedZ (int x, int y, int z, short[] buffer);
+ public void getBoundedXY (int x, int y, int z, short[][] buffer);
+ public void getBoundedXZ (int x, int y, int z, short[][] buffer);
+ public void getBoundedYZ (int x, int y, int z, short[][] buffer);
+ public void getBoundedXYZ (int x, int y, int z, short[][][] buffer);
+
+ public void getBoundedX (int x, int y, int z, float[] buffer);
+ public void getBoundedY (int x, int y, int z, float[] buffer);
+ public void getBoundedZ (int x, int y, int z, float[] buffer);
+ public void getBoundedXY (int x, int y, int z, float[][] buffer);
+ public void getBoundedXZ (int x, int y, int z, float[][] buffer);
+ public void getBoundedYZ (int x, int y, int z, float[][] buffer);
+ public void getBoundedXYZ (int x, int y, int z, float[][][] buffer);
+
+ public void getBoundedX (int x, int y, int z, double[] buffer);
+ public void getBoundedY (int x, int y, int z, double[] buffer);
+ public void getBoundedZ (int x, int y, int z, double[] buffer);
+ public void getBoundedXY (int x, int y, int z, double[][] buffer);
+ public void getBoundedXZ (int x, int y, int z, double[][] buffer);
+ public void getBoundedYZ (int x, int y, int z, double[][] buffer);
+ public void getBoundedXYZ (int x, int y, int z, double[][][] buffer);
+
+
+ // getBlock with boundary conditions section
+
+ public void getBlockX (int x, int y, int z, byte[] buffer, byte boundaryConditions);
+ public void getBlockY (int x, int y, int z, byte[] buffer, byte boundaryConditions);
+ public void getBlockZ (int x, int y, int z, byte[] buffer, byte boundaryConditions);
+ public void getBlockXY (int x, int y, int z, byte[][] buffer, byte boundaryConditions);
+ public void getBlockXZ (int x, int y, int z, byte[][] buffer, byte boundaryConditions);
+ public void getBlockYZ (int x, int y, int z, byte[][] buffer, byte boundaryConditions);
+ public void getBlockXYZ(int x, int y, int z, byte[][][] buffer, byte boundaryConditions);
+
+ public void getBlockX (int x, int y, int z, short[] buffer, byte boundaryConditions);
+ public void getBlockY (int x, int y, int z, short[] buffer, byte boundaryConditions);
+ public void getBlockZ (int x, int y, int z, short[] buffer, byte boundaryConditions);
+ public void getBlockXY (int x, int y, int z, short[][] buffer, byte boundaryConditions);
+ public void getBlockXZ (int x, int y, int z, short[][] buffer, byte boundaryConditions);
+ public void getBlockYZ (int x, int y, int z, short[][] buffer, byte boundaryConditions);
+ public void getBlockXYZ(int x, int y, int z, short[][][] buffer, byte boundaryConditions);
+
+ public void getBlockX (int x, int y, int z, float[] buffer, byte boundaryConditions);
+ public void getBlockY (int x, int y, int z, float[] buffer, byte boundaryConditions);
+ public void getBlockZ (int x, int y, int z, float[] buffer, byte boundaryConditions);
+ public void getBlockXY (int x, int y, int z, float[][] buffer, byte boundaryConditions);
+ public void getBlockXZ (int x, int y, int z, float[][] buffer, byte boundaryConditions);
+ public void getBlockYZ (int x, int y, int z, float[][] buffer, byte boundaryConditions);
+ public void getBlockXYZ(int x, int y, int z, float[][][] buffer, byte boundaryConditions);
+
+ public void getBlockX (int x, int y, int z, double[] buffer, byte boundaryConditions);
+ public void getBlockY (int x, int y, int z, double[] buffer, byte boundaryConditions);
+ public void getBlockZ (int x, int y, int z, double[] buffer, byte boundaryConditions);
+ public void getBlockXY (int x, int y, int z, double[][] buffer, byte boundaryConditions);
+ public void getBlockXZ (int x, int y, int z, double[][] buffer, byte boundaryConditions);
+ public void getBlockYZ (int x, int y, int z, double[][] buffer, byte boundaryConditions);
+ public void getBlockXYZ(int x, int y, int z, double[][][] buffer, byte boundaryConditions);
+
+
+ // getNeighborhood with boundary conditions section
+
+ public void getNeighborhoodX (int x, int y, int z, byte[] buffer, byte boundaryConditions);
+ public void getNeighborhoodY (int x, int y, int z, byte[] buffer, byte boundaryConditions);
+ public void getNeighborhoodZ (int x, int y, int z, byte[] buffer, byte boundaryConditions);
+ public void getNeighborhoodXY (int x, int y, int z, byte[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodXZ (int x, int y, int z, byte[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodYZ (int x, int y, int z, byte[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodXYZ(int x, int y, int z, byte[][][] buffer, byte boundaryConditions);
+
+ public void getNeighborhoodX (int x, int y, int z, short[] buffer, byte boundaryConditions);
+ public void getNeighborhoodY (int x, int y, int z, short[] buffer, byte boundaryConditions);
+ public void getNeighborhoodZ (int x, int y, int z, short[] buffer, byte boundaryConditions);
+ public void getNeighborhoodXY (int x, int y, int z, short[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodXZ (int x, int y, int z, short[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodYZ (int x, int y, int z, short[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodXYZ(int x, int y, int z, short[][][] buffer, byte boundaryConditions);
+
+ public void getNeighborhoodX (int x, int y, int z, float[] buffer, byte boundaryConditions);
+ public void getNeighborhoodY (int x, int y, int z, float[] buffer, byte boundaryConditions);
+ public void getNeighborhoodZ (int x, int y, int z, float[] buffer, byte boundaryConditions);
+ public void getNeighborhoodXY (int x, int y, int z, float[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodXZ (int x, int y, int z, float[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodYZ (int x, int y, int z, float[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodXYZ(int x, int y, int z, float[][][] buffer, byte boundaryConditions);
+
+ public void getNeighborhoodX (int x, int y, int z, double[] buffer, byte boundaryConditions);
+ public void getNeighborhoodY (int x, int y, int z, double[] buffer, byte boundaryConditions);
+ public void getNeighborhoodZ (int x, int y, int z, double[] buffer, byte boundaryConditions);
+ public void getNeighborhoodXY (int x, int y, int z, double[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodXZ (int x, int y, int z, double[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodYZ (int x, int y, int z, double[][] buffer, byte boundaryConditions);
+ public void getNeighborhoodXYZ(int x, int y, int z, double[][][] buffer, byte boundaryConditions);
+
+
+ // putBounded section
+
+ public void putBoundedX (int x, int y, int z, byte[] buffer);
+ public void putBoundedY (int x, int y, int z, byte[] buffer);
+ public void putBoundedZ (int x, int y, int z, byte[] buffer);
+ public void putBoundedXY (int x, int y, int z, byte[][] buffer);
+ public void putBoundedXZ (int x, int y, int z, byte[][] buffer);
+ public void putBoundedYZ (int x, int y, int z, byte[][] buffer);
+ public void putBoundedXYZ (int x, int y, int z, byte[][][] buffer);
+
+ public void putBoundedX (int x, int y, int z, short[] buffer);
+ public void putBoundedY (int x, int y, int z, short[] buffer);
+ public void putBoundedZ (int x, int y, int z, short[] buffer);
+ public void putBoundedXY (int x, int y, int z, short[][] buffer);
+ public void putBoundedXZ (int x, int y, int z, short[][] buffer);
+ public void putBoundedYZ (int x, int y, int z, short[][] buffer);
+ public void putBoundedXYZ (int x, int y, int z, short[][][] buffer);
+
+ public void putBoundedX (int x, int y, int z, float[] buffer);
+ public void putBoundedY (int x, int y, int z, float[] buffer);
+ public void putBoundedZ (int x, int y, int z, float[] buffer);
+ public void putBoundedXY (int x, int y, int z, float[][] buffer);
+ public void putBoundedXZ (int x, int y, int z, float[][] buffer);
+ public void putBoundedYZ (int x, int y, int z, float[][] buffer);
+ public void putBoundedXYZ (int x, int y, int z, float[][][] buffer);
+
+ public void putBoundedX (int x, int y, int z, double[] buffer);
+ public void putBoundedY (int x, int y, int z, double[] buffer);
+ public void putBoundedZ (int x, int y, int z, double[] buffer);
+ public void putBoundedXY (int x, int y, int z, double[][] buffer);
+ public void putBoundedXZ (int x, int y, int z, double[][] buffer);
+ public void putBoundedYZ (int x, int y, int z, double[][] buffer);
+ public void putBoundedXYZ (int x, int y, int z, double[][][] buffer);
+
+}
diff --git a/src-plugins/imageware/imageware/Buffer.java b/src-plugins/imageware/imageware/Buffer.java
new file mode 100644
index 0000000000..89f5f59048
--- /dev/null
+++ b/src-plugins/imageware/imageware/Buffer.java
@@ -0,0 +1,118 @@
+package imageware;
+
+/**
+ * Class Buffer.
+ *
+ * @author Daniel Sage
+ * Biomedical Imaging Group
+ * Ecole Polytechnique Federale de Lausanne, Lausanne, Switzerland
+ */
+
+public interface Buffer {
+ public int getType();
+ public String getTypeToString();
+ public int getDimension();
+ public int[] getSize();
+ public int getSizeX();
+ public int getSizeY();
+ public int getSizeZ();
+ public int getWidth();
+ public int getHeight();
+ public int getDepth();
+ public int getTotalSize();
+ public boolean isSameSize(ImageWare imageware);
+
+ // get section
+ public void getX (int x, int y, int z, ImageWare buffer);
+ public void getY (int x, int y, int z, ImageWare buffer);
+ public void getZ (int x, int y, int z, ImageWare buffer);
+ public void getXY (int x, int y, int z, ImageWare buffer);
+ public void getXZ (int x, int y, int z, ImageWare buffer);
+ public void getYZ (int x, int y, int z, ImageWare buffer);
+ public void getXYZ (int x, int y, int z, ImageWare buffer);
+
+ public void getX (int x, int y, int z, byte[] buffer);
+ public void getY (int x, int y, int z, byte[] buffer);
+ public void getZ (int x, int y, int z, byte[] buffer);
+ public void getXY (int x, int y, int z, byte[][] buffer);
+ public void getXZ (int x, int y, int z, byte[][] buffer);
+ public void getYZ (int x, int y, int z, byte[][] buffer);
+ public void getXYZ (int x, int y, int z, byte[][][] buffer);
+
+ public void getX (int x, int y, int z, short[] buffer);
+ public void getY (int x, int y, int z, short[] buffer);
+ public void getZ (int x, int y, int z, short[] buffer);
+ public void getXY (int x, int y, int z, short[][] buffer);
+ public void getXZ (int x, int y, int z, short[][] buffer);
+ public void getYZ (int x, int y, int z, short[][] buffer);
+ public void getXYZ (int x, int y, int z, short[][][] buffer);
+
+ public void getX (int x, int y, int z, float[] buffer);
+ public void getY (int x, int y, int z, float[] buffer);
+ public void getZ (int x, int y, int z, float[] buffer);
+ public void getXY (int x, int y, int z, float[][] buffer);
+ public void getXZ (int x, int y, int z, float[][] buffer);
+ public void getYZ (int x, int y, int z, float[][] buffer);
+ public void getXYZ (int x, int y, int z, float[][][] buffer);
+
+ public void getX (int x, int y, int z, double[] buffer);
+ public void getY (int x, int y, int z, double[] buffer);
+ public void getZ (int x, int y, int z, double[] buffer);
+ public void getXY (int x, int y, int z, double[][] buffer);
+ public void getXZ (int x, int y, int z, double[][] buffer);
+ public void getYZ (int x, int y, int z, double[][] buffer);
+ public void getXYZ (int x, int y, int z, double[][][] buffer);
+
+
+ // put section
+ public void putX (int x, int y, int z, ImageWare buffer);
+ public void putY (int x, int y, int z, ImageWare buffer);
+ public void putZ (int x, int y, int z, ImageWare buffer);
+ public void putXY (int x, int y, int z, ImageWare buffer);
+ public void putXZ (int x, int y, int z, ImageWare buffer);
+ public void putYZ (int x, int y, int z, ImageWare buffer);
+ public void putXYZ (int x, int y, int z, ImageWare buffer);
+
+ public void putX (int x, int y, int z, byte[] buffer);
+ public void putY (int x, int y, int z, byte[] buffer);
+ public void putZ (int x, int y, int z, byte[] buffer);
+ public void putXY (int x, int y, int z, byte[][] buffer);
+ public void putXZ (int x, int y, int z, byte[][] buffer);
+ public void putYZ (int x, int y, int z, byte[][] buffer);
+ public void putXYZ (int x, int y, int z, byte[][][] buffer);
+
+ public void putX (int x, int y, int z, short[] buffer);
+ public void putY (int x, int y, int z, short[] buffer);
+ public void putZ (int x, int y, int z, short[] buffer);
+ public void putXY (int x, int y, int z, short[][] buffer);
+ public void putXZ (int x, int y, int z, short[][] buffer);
+ public void putYZ (int x, int y, int z, short[][] buffer);
+ public void putXYZ (int x, int y, int z, short[][][] buffer);
+
+ public void putX (int x, int y, int z, float[] buffer);
+ public void putY (int x, int y, int z, float[] buffer);
+ public void putZ (int x, int y, int z, float[] buffer);
+ public void putXY (int x, int y, int z, float[][] buffer);
+ public void putXZ (int x, int y, int z, float[][] buffer);
+ public void putYZ (int x, int y, int z, float[][] buffer);
+ public void putXYZ (int x, int y, int z, float[][][] buffer);
+
+ public void putX (int x, int y, int z, double[] buffer);
+ public void putY (int x, int y, int z, double[] buffer);
+ public void putZ (int x, int y, int z, double[] buffer);
+ public void putXY (int x, int y, int z, double[][] buffer);
+ public void putXZ (int x, int y, int z, double[][] buffer);
+ public void putYZ (int x, int y, int z, double[][] buffer);
+ public void putXYZ (int x, int y, int z, double[][][] buffer);
+
+
+ // get Slice in a specific type for a fast and direct access
+ public Object[] getVolume();
+
+ public byte[] getSliceByte(int z);
+ public short[] getSliceShort(int z);
+ public float[] getSliceFloat(int z);
+ public double[] getSliceDouble(int z);
+
+}
+
diff --git a/src-plugins/imageware/imageware/Builder.java b/src-plugins/imageware/imageware/Builder.java
new file mode 100644
index 0000000000..9ce1408cd8
--- /dev/null
+++ b/src-plugins/imageware/imageware/Builder.java
@@ -0,0 +1,704 @@
+package imageware;
+
+import ij.ImagePlus;
+import ij.ImageStack;
+import ij.WindowManager;
+import ij.process.ByteProcessor;
+import ij.process.FloatProcessor;
+import ij.process.ImageProcessor;
+import ij.process.ShortProcessor;
+
+import java.awt.Image;
+
+/**
+ * Class Builder.
+ *
+ * @author Daniel Sage
+ * Biomedical Imaging Group
+ * Ecole Polytechnique Federale de Lausanne, Lausanne, Switzerland
+ */
+
+public class Builder {
+
+ /**
+ * Wrap a imageware of from the focused image of ImageJ.
+ */
+ public static ImageWare wrapOnFocus() {
+ ImagePlus imp = WindowManager.getCurrentImage();
+ return wrap(imp.getStack());
+ }
+
+
+ /**
+ * Wrap a imageware around a ImagePlus object.
+ *
+ * @param imp an ImagePlus object to wrap
+ */
+ public static ImageWare wrap(ImagePlus imp) {
+ return wrap(imp.getStack());
+ }
+
+
+ /**
+ * Wrap a imageware around a ImageStack object.
+ *
+ * @param stack an ImageStack object to wrap
+ */
+ public static ImageWare wrap(ImageStack stack) {
+ if (stack == null)
+ throw_null();
+ ImageProcessor ip = stack.getProcessor(1);
+ if (ip instanceof ByteProcessor) {
+ return new ByteSet(stack, ImageWare.WRAP);
+ }
+ else if (ip instanceof ShortProcessor) {
+ return new ShortSet(stack, ImageWare.WRAP);
+ }
+ else if (ip instanceof FloatProcessor) {
+ return new FloatSet(stack, ImageWare.WRAP);
+ }
+ else {
+ throw new ArrayStoreException(
+ "\n-------------------------------------------------------\n" +
+ "Error in imageware package\n" +
+ "Unable to wrap this ImageStack object.\n" +
+ "Support only the 8-bit, 16-bit and 32-bits type.\n" +
+ "-------------------------------------------------------\n"
+ );
+ }
+ }
+
+ /**
+ * Create an empty imageware of a specified type.
+ * @param nx size in X axis
+ * @param ny size in Y axis
+ * @param nz size in Z axis
+ * @param type type of the imageware
+ */
+ public static ImageWare create(int nx, int ny, int nz, int type) {
+ switch(type) {
+ case ImageWare.BYTE:
+ return new ByteSet(nx, ny, nz);
+ case ImageWare.SHORT:
+ return new ShortSet(nx, ny, nz);
+ case ImageWare.FLOAT:
+ return new FloatSet(nx, ny, nz);
+ case ImageWare.DOUBLE:
+ return new DoubleSet(nx, ny, nz);
+ default :
+ throw new ArrayStoreException(
+ "\n-------------------------------------------------------\n" +
+ "Error in imageware package\n" +
+ "Unknown type " + type + ".\n" +
+ "-------------------------------------------------------\n"
+ );
+ }
+ }
+
+ /**
+ * Create a imageware of from an Java AWT Image.
+ *
+ * @param image an Java AWT Image object
+ */
+ public static ImageWare create(Image image) {
+ if (image == null)
+ throw_null();
+ return new ByteSet(image, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from the focussed image of ImageJ.
+ */
+ public static ImageWare createOnFocus() {
+ return create(WindowManager.getCurrentImage());
+ }
+
+ /**
+ * Create a imageware of from an ImageStack.
+ *
+ * @param stack an ImageStack object
+ */
+ public static ImageWare create(ImageStack stack) {
+ if (stack == null)
+ throw_null();
+ ImageWare wrapped = wrap(stack);
+ return wrapped.duplicate();
+ }
+
+ /**
+ * Create a imageware of from an ImagePlus.
+ *
+ * @param imp an ImagePlus object
+ */
+ public static ImageWare create(ImagePlus imp) {
+ if (imp == null)
+ throw_null();
+ ImageWare wrapped = wrap(imp);
+ return wrapped.duplicate();
+ }
+
+ /**
+ * Create an array of 3 datasets from an ImagePlus.
+ *
+ * @param imp an ImagePlus object
+ */
+ public static ImageWare[] createColors(ImagePlus imp) {
+ if (imp == null)
+ throw_null();
+ return createColors(imp.getStack());
+ }
+
+ /**
+ * Create an array of 3 imageware from an ImageStack.
+ *
+ * @param stack an ImageStack object
+ */
+ public static ImageWare[] createColors(ImageStack stack) {
+ if (stack == null)
+ throw_null();
+ ImageWare color[] = new ImageWare[3];
+ color[0] = new ByteSet(stack, ImageWare.RED);
+ color[1] = new ByteSet(stack, ImageWare.GREEN);
+ color[2] = new ByteSet(stack, ImageWare.BLUE);
+ return color;
+ }
+
+ /**
+ * Create a imageware of a specific channel if the ImagePlus is
+ * a color image.
+ *
+ * @param imp an ImagePlus object
+ */
+ public static ImageWare createColorChannel(ImagePlus imp, byte channel) {
+ if (imp == null)
+ throw_null();
+ return createColorChannel(imp.getStack(), channel);
+ }
+
+ /**
+ * Create a imageware of a specific channel if the ImageStack is
+ * a color image.
+ * @param stack an ImageStack object
+ */
+ public static ImageWare createColorChannel(ImageStack stack, byte channel) {
+ if (stack == null)
+ throw_null();
+ return new ByteSet(stack, channel);
+ }
+
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object byte 1D array
+ */
+ public static ImageWare create(byte[] object) {
+ if (object == null)
+ throw_null();
+ return new ByteSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object short 1D array
+ */
+ public static ImageWare create(short[] object) {
+ if (object == null)
+ throw_null();
+ return new ShortSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object float 1D array
+ */
+ public static ImageWare create(float[] object) {
+ if (object == null)
+ throw_null();
+ return new FloatSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object double 1D array
+ */
+ public static ImageWare create(double[] object) {
+ if (object == null)
+ throw_null();
+ return new DoubleSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object byte 2D array
+ */
+ public static ImageWare create(byte[][] object) {
+ if (object == null)
+ throw_null();
+ return new ByteSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object short 2D array
+ */
+ public static ImageWare create(short[][] object) {
+ if (object == null)
+ throw_null();
+ return new ByteSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object float 2D array
+ */
+ public static ImageWare create(float[][] object) {
+ if (object == null)
+ throw_null();
+ return new FloatSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object double 2D array
+ */
+ public static ImageWare create(double[][] object) {
+ if (object == null)
+ throw_null();
+ return new DoubleSet(object, ImageWare.CREATE);
+ }
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object byte 3D array
+ */
+ public static ImageWare create(byte[][][] object) {
+ if (object == null)
+ throw_null();
+ return new ByteSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object short 3D array
+ */
+ public static ImageWare create(short[][][] object) {
+ if (object == null)
+ throw_null();
+ return new ShortSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object float 3D array
+ */
+ public static ImageWare create(float[][][] object) {
+ if (object == null)
+ throw_null();
+ return new FloatSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of from an array.
+ *
+ * @param object double 3D array
+ */
+ public static ImageWare create(double[][][] object) {
+ if (object == null)
+ throw_null();
+ return new DoubleSet(object, ImageWare.CREATE);
+ }
+
+ /**
+ * Create a imageware of a specified type from an Java AWT Image object.
+ *
+ * @param image an Java AWT Image object
+ * @param type type of the imageware
+ */
+ public static ImageWare create(Image image, int type) {
+ if (image == null)
+ throw_null();
+ switch(type) {
+ case ImageWare.BYTE:
+ return new ByteSet(image, ImageWare.CREATE);
+ case ImageWare.SHORT:
+ return new ShortSet(image, ImageWare.CREATE);
+ case ImageWare.FLOAT:
+ return new FloatSet(image, ImageWare.CREATE);
+ case ImageWare.DOUBLE:
+ return new DoubleSet(image, ImageWare.CREATE);
+ default :
+ throw new ArrayStoreException(
+ "\n-------------------------------------------------------\n" +
+ "Error in imageware package\n" +
+ "Unknown type " + type + ".\n" +
+ "-------------------------------------------------------\n"
+ );
+ }
+ }
+
+ /**
+ * Create a imageware of from the focused image of ImageJ.
+ *
+ * @param type type of the imageware
+ */
+ public static ImageWare createOnFocus(int type) {
+ return create(WindowManager.getCurrentImage(), type);
+ }
+
+ /**
+ * Create a imageware of a specified type from an ImagePlus object.
+ *
+ * @param imp an ImagePlus object
+ * @param type type of the imageware
+ */
+ public static ImageWare create(ImagePlus imp, int type) {
+ if (imp == null)
+ throw_null();
+ switch(type) {
+ case ImageWare.BYTE:
+ return new ByteSet(imp.getStack(), ImageWare.CREATE);
+ case ImageWare.SHORT:
+ return new ShortSet(imp.getStack(), ImageWare.CREATE);
+ case ImageWare.FLOAT:
+ return new FloatSet(imp.getStack(), ImageWare.CREATE);
+ case ImageWare.DOUBLE:
+ return new DoubleSet(imp.getStack(), ImageWare.CREATE);
+ default :
+ throw new ArrayStoreException(
+ "\n-------------------------------------------------------\n" +
+ "Error in imageware package\n" +
+ "Unknown type " + type + ".\n" +
+ "-------------------------------------------------------\n"
+ );
+ }
+ }
+
+ /**
+ * Create a imageware of a specified type from an ImageStack object.
+ *
+ * @param object an ImageStack object
+ * @param type type of the imageware
+ */
+ public static ImageWare create(ImageStack object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare wrapped = wrap(object);
+ return wrapped.convert(type);
+ }
+
+ /**
+ * Create an array of 3 datasets from an ImagePlus.
+ *
+ * @param imp an ImagePlus object
+ * @param type type of the imageware
+ */
+ public static ImageWare[] createColor(ImagePlus imp, int type) {
+ if (imp == null)
+ throw_null();
+ return createColor(imp.getStack(), type);
+ }
+
+ /**
+ * Create an array of 3 imageware from an ColorProcessor.
+ *
+ * @param stack an ColorProcessor object
+ * @param type type of the imageware
+ */
+ public static ImageWare[] createColor(ImageStack stack, int type) {
+ if (stack == null)
+ throw_null();
+ ImageWare color[] = new ImageWare[3];
+ switch(type) {
+ case ImageWare.BYTE:
+ color[0] = new ByteSet(stack, ImageWare.RED);
+ color[1] = new ByteSet(stack, ImageWare.GREEN);
+ color[2] = new ByteSet(stack, ImageWare.BLUE);
+ break;
+ case ImageWare.SHORT:
+ color[0] = new ShortSet(stack, ImageWare.RED);
+ color[1] = new ShortSet(stack, ImageWare.GREEN);
+ color[2] = new ShortSet(stack, ImageWare.BLUE);
+ break;
+ case ImageWare.FLOAT:
+ color[0] = new FloatSet(stack, ImageWare.RED);
+ color[1] = new FloatSet(stack, ImageWare.GREEN);
+ color[2] = new FloatSet(stack, ImageWare.BLUE);
+ break;
+ case ImageWare.DOUBLE:
+ color[0] = new DoubleSet(stack, ImageWare.RED);
+ color[1] = new DoubleSet(stack, ImageWare.GREEN);
+ color[2] = new DoubleSet(stack, ImageWare.BLUE);
+ break;
+ default:
+ throw new ArrayStoreException(
+ "\n-------------------------------------------------------\n" +
+ "Error in imageware package\n" +
+ "Unknown type " + type + ".\n" +
+ "-------------------------------------------------------\n"
+ );
+ }
+ return color;
+ }
+
+ /**
+ * Create a imageware of a specific channel if the ImagePlus is
+ * a color image.
+ *
+ * @param imp an ImagePlus object
+ */
+ public static ImageWare createColorChannel(ImagePlus imp, byte channel, int type) {
+ if (imp == null)
+ throw_null();
+ return createColorChannel(imp.getStack(), channel, type);
+ }
+
+ /**
+ * Create a imageware of a specific channel if the ImageStack is
+ * a color image.
+ * @param stack an ImageStack object
+ */
+ public static ImageWare createColorChannel(ImageStack stack, byte channel, int type) {
+ if (stack == null)
+ throw_null();
+ ImageWare out = null;
+ switch(type) {
+ case ImageWare.BYTE:
+ out = new ByteSet(stack, channel);
+ break;
+ case ImageWare.SHORT:
+ out = new ShortSet(stack, channel);
+ break;
+ case ImageWare.FLOAT:
+ out = new FloatSet(stack, channel);
+ break;
+ case ImageWare.DOUBLE:
+ out = new DoubleSet(stack, channel);
+ break;
+ default:
+ throw new ArrayStoreException(
+ "\n-------------------------------------------------------\n" +
+ "Error in imageware package\n" +
+ "Unknown type " + type + ".\n" +
+ "-------------------------------------------------------\n"
+ );
+ }
+ return out;
+ }
+
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object byte 1D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(byte[] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, 1, 1, type);
+ out.putX(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object short 1D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(short[] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, 1, 1, type);
+ out.putX(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object float 1D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(float[] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, 1, 1, type);
+ out.putX(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object double 1D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(double[] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, 1, 1, type);
+ out.putX(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object byte 2D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(byte[][] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, object[0].length, 1, type);
+ out.putXY(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object short 2D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(short[][] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, object[0].length, 1, type);
+ out.putXY(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object float 2D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(float[][] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, object[0].length, 1, type);
+ out.putXY(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object double 2D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(double[][] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, object[0].length, 1, type);
+ out.putXY(0, 0, 0, object);
+ return out;
+ }
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object byte 3D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(byte[][][] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, object[0].length, object[0][0].length, type);
+ out.putXYZ(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object short 3D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(short[][][] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, object[0].length, object[0][0].length, type);
+ out.putXYZ(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object float 3D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(float[][][] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, object[0].length, object[0][0].length, type);
+ out.putXYZ(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ * Create a imageware of a specified type from an array.
+ *
+ * @param object double 3D array
+ * @param type type of the imageware
+ */
+ public static ImageWare create(double[][][] object, int type) {
+ if (object == null)
+ throw_null();
+ ImageWare out = createType(object.length, object[0].length, object[0][0].length, type);
+ out.putXYZ(0, 0, 0, object);
+ return out;
+ }
+
+ /**
+ */
+ private static ImageWare createType(int nx, int ny , int nz, int type) {
+ ImageWare out = null;
+ switch(type) {
+ case ImageWare.BYTE:
+ out = new ByteSet(nx, ny, nz);
+ break;
+ case ImageWare.SHORT:
+ out = new ShortSet(nx, ny, nz);
+ break;
+ case ImageWare.FLOAT:
+ out = new FloatSet(nx, ny, nz);
+ break;
+ case ImageWare.DOUBLE:
+ out = new DoubleSet(nx, ny, nz);
+ break;
+ default:
+ throw new ArrayStoreException(
+ "\n-------------------------------------------------------\n" +
+ "Error in imageware package\n" +
+ "Unable to create this object.\n" +
+ "-------------------------------------------------------\n"
+ );
+ }
+ return out;
+ }
+
+ private static void throw_null() {
+ throw new ArrayStoreException(
+ "\n-------------------------------------------------------\n" +
+ "Error in imageware package\n" +
+ "Unable to wrap the ImagePlus.\n" +
+ "The object parameter is null.\n" +
+ "-------------------------------------------------------\n"
+ );
+ }
+
+}
diff --git a/src-plugins/imageware/imageware/ByteAccess.java b/src-plugins/imageware/imageware/ByteAccess.java
new file mode 100644
index 0000000000..57a29cc86d
--- /dev/null
+++ b/src-plugins/imageware/imageware/ByteAccess.java
@@ -0,0 +1 @@
+package imageware;
import ij.ImageStack;
import java.awt.Image;
/**
* Class ByteAccess.
*
* @author Daniel Sage
* Biomedical Imaging Group
* Ecole Polytechnique Federale de Lausanne, Lausanne, Switzerland
*/
public class ByteAccess extends ByteBuffer implements Access {
//------------------------------------------------------------------
//
// Constructors section
//
//------------------------------------------------------------------
protected ByteAccess(int nx, int ny, int nz) { super(nx, ny, nz); }
protected ByteAccess(Image image, int mode) { super(image, mode); }
protected ByteAccess(ImageStack stack, int mode) { super(stack, mode); }
protected ByteAccess(ImageStack stack, byte chan) { super(stack, chan); }
protected ByteAccess(byte[] array, int mode) { super(array, mode); }
protected ByteAccess(byte[][] array, int mode) { super(array, mode); }
protected ByteAccess(byte[][][] array, int mode) { super(array, mode); }
protected ByteAccess(short[] array, int mode) { super(array, mode); }
protected ByteAccess(short[][] array, int mode) { super(array, mode); }
protected ByteAccess(short[][][] array, int mode) { super(array, mode); }
protected ByteAccess(float[] array, int mode) { super(array, mode); }
protected ByteAccess(float[][] array, int mode) { super(array, mode); }
protected ByteAccess(float[][][] array, int mode) { super(array, mode); }
protected ByteAccess(double[] array, int mode) { super(array, mode); }
protected ByteAccess(double[][] array, int mode) { super(array, mode); }
protected ByteAccess(double[][][] array, int mode) { super(array, mode); }
//------------------------------------------------------------------
//
// getPixel section
//
//------------------------------------------------------------------
/**
* Get a pixel at specific position without specific boundary conditions
*
* If the positions is outside of this imageware, the method return 0.0.
*
* @param x position in the X axis
* @param y position in the Y axis
* @param z position in the Z axis
* @return a pixel value
*/
public double getPixel(int x, int y, int z) {
if (x >= nx) return 0.0;
if (y >= ny) return 0.0;
if (z >= nz) return 0.0;
if (x < 0) return 0.0;
if (y < 0) return 0.0;
if (z < 0) return 0.0;
return ((byte[])data[z])[x+y*nx] & 0xFF;
}
/**
* Get a pixel at specific position with specific boundary conditions
*
* If the positions is outside of this imageware, the method apply the
* boundary conditions to return a value.
*
* @param x position in the X axis
* @param y position in the Y axis
* @param z position in the Z axis
* @return a pixel value
*/
public double getPixel(int x, int y, int z, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw new ArrayStoreException(
"\n-------------------------------------------------------\n" +
"Error in imageware package\n" +
"Unable to put a pixel \n" +
"at the position (" + x + "," + y + "," + z + ".\n" +
"-------------------------------------------------------\n"
);
}
int xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
int yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
return ((byte[])data[zp])[xp+yp*nx] & 0xFF;
}
/**
* Get a interpolated pixel value at specific position without specific boundary conditions.
*
* If the positions is not on the pixel grid, the method return a interpolated
* value of the pixel (linear interpolation). If the positions is outside of this
* imageware, the method return 0.0.
*
* @param x position in the X axis
* @param y position in the Y axis
* @param z position in the Z axis
* @return a interpolated value
*/
public double getInterpolatedPixel(double x, double y, double z) {
if (x > nx-1) return 0.0;
if (y > ny-1) return 0.0;
if (z > nz-1) return 0.0;
if (x < 0) return 0.0;
if (y < 0) return 0.0;
if (z < 0) return 0.0;
double output = 0.0;
/*
int i = (x >= 0.0 ? ((int)x) : ((int)x - 1));
int j = (y >= 0.0 ? ((int)y) : ((int)y - 1));
int k = (z >= 0.0 ? ((int)z) : ((int)z - 1));
*/
int i = (x >= 0.0 ? ((int)x) : ((int)x - 1));
int j = (y >= 0.0 ? ((int)y) : ((int)y - 1));
int k = (z >= 0.0 ? ((int)z) : ((int)z - 1));
boolean fi = (i==nx-1);
boolean fj = (j==ny-1);
boolean fk = (k==nz-1);
int index = i+j*nx;
switch(getDimension()) {
case 1:
double v1_0 = (double)(((byte[])data[k])[index] & 0xFF);
double v1_1 = (fi ? v1_0 : (double)(((byte[])data[k])[index+1] & 0xFF));
double dx1 = x - (double)i;
return v1_1*dx1 - v1_0 * (dx1-1.0);
case 2:
double v2_00 = (double)(((byte[])data[k])[index] & 0xFF);
double v2_10 = (fi ? v2_00 : (double)(((byte[])data[k])[index+1] & 0xFF));
double v2_01 = (fj ? v2_00 : (double)(((byte[])data[k])[index+nx] & 0xFF));
double v2_11 = (fi ? (fj ? v2_00 : v2_01) : (double)(((byte[])data[k])[index+1+nx] & 0xFF));
double dx2 = x - (double)i;
double dy2 = y - (double)j;
return (dx2*(v2_11*dy2-v2_10*(dy2-1.0)) - (dx2-1.0)*(v2_01*dy2-v2_00*(dy2-1.0)));
case 3:
double v3_000 = (double)(((byte[])data[k])[index] & 0xFF);
double v3_100 = (fi ? v3_000 : (double)(((byte[])data[k])[index+1] & 0xFF));
double v3_010 = (fj ? v3_000 : (double)(((byte[])data[k])[index+nx] & 0xFF));
double v3_110 = (fi ? ( fj ? v3_000 : v3_010 ) : (double)(((byte[])data[k])[index+1+nx] & 0xFF));
double v3_001 = (fk ? v3_000 : (double)(((byte[])data[k+1])[index] & 0xFF));
double v3_011 = (fk ? ( fj ? v3_000 : v3_010) : (double)(((byte[])data[k+1])[index+1] & 0xFF));
double v3_101 = (fk ? ( fi ? v3_000 : v3_100) : (double)(((byte[])data[k+1])[index+nx] & 0xFF));
double v3_111 = (fk ? ( fj ? ( fi ? v3_000 : v3_100) : v3_110) :(double)(((byte[])data[k+1])[index+1+nx] & 0xFF));
double dx3 = x - (double)i;
double dy3 = y - (double)j;
double dz3 = z - (double)k;
double z1 = (dx3*(v3_110*dy3-v3_100*(dy3-1.0)) - (dx3-1.0)*(v3_010*dy3-v3_000*(dy3-1.0)));
double z2 = (dx3*(v3_111*dy3-v3_101*(dy3-1.0)) - (dx3-1.0)*(v3_011*dy3-v3_001*(dy3-1.0)));
return z2*dz3-z1*(dz3-1.0);
}
return output;
}
/**
* Get a interpolated pixel value at specific position with specific boundary conditions.
*
* If the positions is not on the pixel grid, the method return a interpolated
* value of the pixel (linear interpolation).
* If the positions is outside of this imageware, the method apply the
* boundary conditions to return a value.
*
* @param x position in the X axis
* @param y position in the Y axis
* @param z position in the Z axis
* @param boundaryConditions MIRROR or PERIODIC boundary conditions
* @return a interpolated value
*/
public double getInterpolatedPixel(double x, double y, double z, byte boundaryConditions) {
double output = 0.0;
int i = (x >= 0.0 ? ((int)x) : ((int)x - 1));
int j = (y >= 0.0 ? ((int)y) : ((int)y - 1));
int k = (z >= 0.0 ? ((int)z) : ((int)z - 1));
switch(getDimension()) {
case 1:
double v1_0 = getPixel(i, j, k, boundaryConditions);
double v1_1 = getPixel(i+1, j, k, boundaryConditions);
double dx1 = x - (double)i;
return v1_1*dx1 - v1_0 * (dx1-1.0);
case 2:
double v2_00 = getPixel(i, j, k, boundaryConditions);
double v2_10 = getPixel(i+1, j, k, boundaryConditions);
double v2_01 = getPixel(i, j+1, k, boundaryConditions);
double v2_11 = getPixel(i+1, j+1, k, boundaryConditions);
double dx2 = x - (double)i;
double dy2 = y - (double)j;
return (dx2*(v2_11*dy2-v2_10*(dy2-1.0)) - (dx2-1.0)*(v2_01*dy2-v2_00*(dy2-1.0)));
case 3:
double v3_000 = getPixel(i, j, k, boundaryConditions);
double v3_100 = getPixel(i+1, j, k, boundaryConditions);
double v3_010 = getPixel(i, j+1, k, boundaryConditions);
double v3_110 = getPixel(i+1, j+1, k, boundaryConditions);
double v3_001 = getPixel(i, j, k+1, boundaryConditions);
double v3_011 = getPixel(i+1, j, k+1, boundaryConditions);
double v3_101 = getPixel(i, j+1, k+1, boundaryConditions);
double v3_111 = getPixel(i+1, j+1, k+1, boundaryConditions);
double dx3 = x - (double)i;
double dy3 = y - (double)j;
double dz3 = z - (double)k;
double z1 = (dx3*(v3_110*dy3-v3_100*(dy3-1.0)) - (dx3-1.0)*(v3_010*dy3-v3_000*(dy3-1.0)));
double z2 = (dx3*(v3_111*dy3-v3_101*(dy3-1.0)) - (dx3-1.0)*(v3_011*dy3-v3_001*(dy3-1.0)));
return z2*dz3-z1*(dz3-1.0);
}
return output;
}
//------------------------------------------------------------------
//
// putPixel section
//
//------------------------------------------------------------------
/**
* Put a pixel at specific position
*
* If the positions is outside of this imageware, the method does nothing.
*
* @param x position in the X axis
* @param y position in the Y axis
* @param z position in the Z axis
*/
public void putPixel(int x, int y, int z, double value) {
if (x >= nx) return;
if (y >= ny) return;
if (z >= nz) return;
if (x < 0) return;
if (y < 0) return;
if (z < 0) return;
((byte[])data[z])[x+y*nx] = (byte)value;
}
//------------------------------------------------------------------
//
// getBounded section
//
//------------------------------------------------------------------
/**
* Get an array from the imageware at the position (x,y,z) in X axis.
* Copy only the bounded area, intersection between the array and the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer byte 1D array to get into the imageware
*/
public void getBoundedX(int x, int y, int z, byte[] buffer) {
try {
if (x >= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
byte[] tmp = (byte[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
byte[] tmp = (byte[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
byte[] tmp = (byte[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
byte[] tmp = (byte[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
byte[] tmp = (byte[])data[zp];
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (byte)(tmp[xp + yp] & 0xFF);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in X axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockX(int x, int y, int z, short[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
byte[] tmp = (byte[])data[zp];
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (short)(tmp[xp + yp] & 0xFF);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in X axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockX(int x, int y, int z, float[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
byte[] tmp = (byte[])data[zp];
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (float)(tmp[xp + yp] & 0xFF);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in X axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockX(int x, int y, int z, double[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
byte[] tmp = (byte[])data[zp];
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (double)(tmp[xp + yp] & 0xFF);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockY(int x, int y, int z, byte[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
byte[] tmp = (byte[])data[zp];
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (byte)(tmp[xp + yp*nx] & 0xFF);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockY(int x, int y, int z, short[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
byte[] tmp = (byte[])data[zp];
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (short)(tmp[xp + yp*nx] & 0xFF);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockY(int x, int y, int z, float[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
byte[] tmp = (byte[])data[zp];
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (float)(tmp[xp + yp*nx] & 0xFF);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockY(int x, int y, int z, double[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
byte[] tmp = (byte[])data[zp];
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (double)(tmp[xp + yp*nx] & 0xFF);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockZ(int x, int y, int z, byte[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (byte)(((byte[])data[zp])[xyp] & 0xFF);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockZ(int x, int y, int z, short[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (short)(((byte[])data[zp])[xyp] & 0xFF);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockZ(int x, int y, int z, float[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (float)(((byte[])data[zp])[xyp] & 0xFF);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockZ(int x, int y, int z, double[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (double)(((byte[])data[zp])[xyp] & 0xFF);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the start position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXY(int x, int y, int z, byte[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = (byte[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (byte)(tmp[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the start position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXY(int x, int y, int z, short[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = (byte[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (short)(tmp[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the start position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXY(int x, int y, int z, float[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = (byte[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (float)(tmp[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the start position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXY(int x, int y, int z, double[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = (byte[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (double)(tmp[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXZ(int x, int y, int z, byte[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (byte)(((byte[])data[zp])[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXZ(int x, int y, int z, short[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (short)(((byte[])data[zp])[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXZ(int x, int y, int z, float[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (float)(((byte[])data[zp])[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXZ(int x, int y, int z, double[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (double)(((byte[])data[zp])[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in YZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockYZ(int x, int y, int z, byte[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
for (int j=0; j= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i][j] = (byte)(((byte[])data[zp])[xp + yp*nx] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in YZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockYZ(int x, int y, int z, short[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
for (int j=0; j= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i][j] = (short)(((byte[])data[zp])[xp + yp*nx] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in YZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockYZ(int x, int y, int z, float[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
for (int j=0; j= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i][j] = (float)(((byte[])data[zp])[xp + yp*nx] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in YZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockYZ(int x, int y, int z, double[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
for (int j=0; j= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i][j] = (double)(((byte[])data[zp])[xp + yp*nx] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XYZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 3D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXYZ(int x, int y, int z, byte[][][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
for (int k=0; k= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = (byte[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j][k] = (byte)(tmp[xp + yp] & 0xFF);
}
}
}
}
catch(Exception e) {
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XYZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 3D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXYZ(int x, int y, int z, short[][][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
for (int k=0; k= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = (byte[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j][k] = (short)(tmp[xp + yp] & 0xFF);
}
}
}
}
catch(Exception e) {
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XYZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 3D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXYZ(int x, int y, int z, float[][][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
for (int k=0; k= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = (byte[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j][k] = (float)(tmp[xp + yp] & 0xFF);
}
}
}
}
catch(Exception e) {
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XYZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 3D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXYZ(int x, int y, int z, double[][][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
for (int k=0; k= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = (byte[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j][k] = (double)(tmp[xp + yp] & 0xFF);
}
}
}
}
catch(Exception e) {
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
//------------------------------------------------------------------
//
// getBlock section
//
//------------------------------------------------------------------
/**
* Get an array from the imageware at the center position (x,y,z) in X axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodX(int x, int y, int z, byte[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
int xs = x - leni/2;
byte[] tmp = ((byte[])data[zp]);
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (byte)(tmp[xp + yp] & 0xFF);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in X axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodX(int x, int y, int z, short[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
int xs = x - leni/2;
byte[] tmp = ((byte[])data[zp]);
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (short)(tmp[xp + yp] & 0xFF);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in X axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodX(int x, int y, int z, float[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
int xs = x - leni/2;
byte[] tmp = ((byte[])data[zp]);
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (float)(tmp[xp + yp] & 0xFF);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in X axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodX(int x, int y, int z, double[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
int xs = x - leni/2;
byte[] tmp = ((byte[])data[zp]);
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (double)(tmp[xp + yp] & 0xFF);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodY(int x, int y, int z, byte[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
int ys = y - leni/2;
byte[] tmp = ((byte[])data[zp]);
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (byte)(tmp[xp + yp*nx] & 0xFF);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodY(int x, int y, int z, short[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
int ys = y - leni/2;
byte[] tmp = ((byte[])data[zp]);
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (short)(tmp[xp + yp*nx] & 0xFF);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodY(int x, int y, int z, float[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
int ys = y - leni/2;
byte[] tmp = ((byte[])data[zp]);
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (float)(tmp[xp + yp*nx] & 0xFF);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodY(int x, int y, int z, double[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
int ys = y - leni/2;
byte[] tmp = ((byte[])data[zp]);
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (double)(tmp[xp + yp*nx] & 0xFF);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodZ(int x, int y, int z, byte[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
int zs = z - leni/2;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (byte)(((byte[])data[zp])[xyp] & 0xFF);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodZ(int x, int y, int z, short[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
int zs = z - leni/2;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (short)(((byte[])data[zp])[xyp] & 0xFF);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodZ(int x, int y, int z, float[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
int zs = z - leni/2;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (float)(((byte[])data[zp])[xyp] & 0xFF);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodZ(int x, int y, int z, double[] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
int zs = z - leni/2;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (double)(((byte[])data[zp])[xyp] & 0xFF);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the center position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXY(int x, int y, int z, byte[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
int xs = x - leni/2;
int ys = y - lenj/2;
byte[] tmp = ((byte[])data[zp]);
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (byte)(tmp[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the center position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXY(int x, int y, int z, short[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
int xs = x - leni/2;
int ys = y - lenj/2;
byte[] tmp = ((byte[])data[zp]);
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (short)(tmp[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the center position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXY(int x, int y, int z, float[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
int xs = x - leni/2;
int ys = y - lenj/2;
byte[] tmp = ((byte[])data[zp]);
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (float)(tmp[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the center position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXY(int x, int y, int z, double[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
int xs = x - leni/2;
int ys = y - lenj/2;
byte[] tmp = ((byte[])data[zp]);
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (double)(tmp[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXZ(int x, int y, int z, byte[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
int xs = x - leni/2;
int zs = z - lenj/2;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (byte)(((byte[])data[zp])[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXZ(int x, int y, int z, short[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
int xs = x - leni/2;
int zs = z - lenj/2;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (short)(((byte[])data[zp])[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXZ(int x, int y, int z, float[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
int xs = x - leni/2;
int zs = z - lenj/2;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (float)(((byte[])data[zp])[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXZ(int x, int y, int z, double[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
int xs = x - leni/2;
int zs = z - lenj/2;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (double)(((byte[])data[zp])[xp + yp] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in YZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodYZ(int x, int y, int z, byte[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
int ys = y - leni/2;
int zs = z - lenj/2;
for (int j=0; j= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i][j] = (byte)(((byte[])data[zp])[xp + yp*nx] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in YZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodYZ(int x, int y, int z, short[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
int ys = y - leni/2;
int zs = z - lenj/2;
for (int j=0; j= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i][j] = (short)(((byte[])data[zp])[xp + yp*nx] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in YZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodYZ(int x, int y, int z, float[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
int ys = y - leni/2;
int zs = z - lenj/2;
for (int j=0; j= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i][j] = (float)(((byte[])data[zp])[xp + yp*nx] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in YZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodYZ(int x, int y, int z, double[][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
int ys = y - leni/2;
int zs = z - lenj/2;
for (int j=0; j= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i][j] = (double)(((byte[])data[zp])[xp + yp*nx] & 0xFF);
}
}
}
catch(Exception e) {
throw_get("YZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in XYZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 3D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXYZ(int x, int y, int z, byte[][][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
int xs = x - leni/2;
int ys = y - lenj/2;
int zs = z - lenk/2;
for (int k=0; k= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = ((byte[])data[zp]);
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j][k] = (byte)(tmp[xp + yp] & 0xFF);
}
}
}
}
catch(Exception e) {
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in XYZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 3D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXYZ(int x, int y, int z, short[][][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
int xs = x - leni/2;
int ys = y - lenj/2;
int zs = z - lenk/2;
for (int k=0; k= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = ((byte[])data[zp]);
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j][k] = (short)(tmp[xp + yp] & 0xFF);
}
}
}
}
catch(Exception e) {
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in XYZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 3D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXYZ(int x, int y, int z, float[][][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
int xs = x - leni/2;
int ys = y - lenj/2;
int zs = z - lenk/2;
for (int k=0; k= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = ((byte[])data[zp]);
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j][k] = (float)(tmp[xp + yp] & 0xFF);
}
}
}
}
catch(Exception e) {
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the center position (x,y,z) in XYZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 3D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getNeighborhoodXYZ(int x, int y, int z, double[][][] buffer, byte boundaryConditions) {
int xperiod = (boundaryConditions == ImageWare.MIRROR ? (nx <= 1 ? 1: 2*nx - 2) : nx);
int yperiod = (boundaryConditions == ImageWare.MIRROR ? (ny <= 1 ? 1: 2*ny - 2) : ny);
int zperiod = (boundaryConditions == ImageWare.MIRROR ? (nz <= 1 ? 1: 2*nz - 2) : nz);
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
int xs = x - leni/2;
int ys = y - lenj/2;
int zs = z - lenk/2;
for (int k=0; k= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
byte[] tmp = ((byte[])data[zp]);
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j][k] = (double)(tmp[xp + yp] & 0xFF);
}
}
}
}
catch(Exception e) {
throw_get("XYZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
//------------------------------------------------------------------
//
// putBounded section
//
//------------------------------------------------------------------
/**
* Put an array into the imageware at the position (x,y,z) in X axis.
* Copy only the bounded area, intersection between the array and the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer byte 1D array to put into the imageware
*/
public void putBoundedX(int x, int y, int z, byte[] buffer) {
try {
if (x >= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
byte[] tmp = (byte[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
byte[] tmp = (byte[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
byte[] tmp = (byte[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
byte[] tmp = (byte[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
byte[] tmp = (byte[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k>16);
g = (double)((c & 0xFF00)>>8);
b = (double)((c & 0xFF));
((byte[])data[z])[k] = (byte)((r+g+b)/3.0);
}
}
}
else {
throw_constructor();
}
break;
default:
throw_constructor();
break;
}
}
/**
* Constructor of a byte buffer from a specific color channel of ImageStack.
*
* New data are always allocated. If it is a gray image the imageware is
* created and fill up with data of the source ImageStack. If it is a color
* image only the selected channel is used to create this imageware.
*
* @param stack source to build a new imageware
* @param channel RED, GREEN or BLUE
*/
protected ByteBuffer(ImageStack stack, byte channel) {
if (stack == null) {
throw_constructor();
}
this.nx = stack.getWidth();
this.ny = stack.getHeight();
this.nz = stack.getSize();
this.nxy = nx*ny;
allocate();
ImageProcessor ip = stack.getProcessor(1);
if (ip instanceof ByteProcessor) {
Object[] vol = stack.getImageArray();
for (int z=0; z>16);
}
break;
case ImageWare.GREEN:
for (int k=0; k>8);
}
break;
case ImageWare.BLUE:
for (int k=0; k 1 ? 1 : 0);
dims += (ny > 1 ? 1 : 0);
dims += (nz > 1 ? 1 : 0);
return dims;
}
/**
* Return the size of the imageware int[0] : x, int[1] : y, int[2] : z.
*
* @return an array given the size of the imageware
*/
public int[] getSize() {
int[] size = {nx, ny, nz};
return size;
}
/**
* Return the size in the X axis.
*
* @return the size in the X axis
*/
public int getSizeX() {
return nx;
}
/**
* Return the size in the Y axis.
*
* @return the size in the Y axis
*/
public int getSizeY() {
return ny;
}
/**
* Return the size in the Z axis.
*
* @return the size in the Z axis
*/
public int getSizeZ() {
return nz;
}
/**
* Return the size in the X axis.
*
* @return the size in the X axis
*/
public int getWidth() {
return nx;
}
/**
* Return the size in the Y axis.
*
* @return the size in the Y axis
*/
public int getHeight() {
return ny;
}
/**
* Return the size in the Z axis.
*
* @return the size in the Z axis
*/
public int getDepth() {
return nz;
}
/**
* Return the number of pixels in the imageware.
*
* @return number of pixels in the imageware
*/
public int getTotalSize() {
return nxy*nz;
}
/**
* Return true is this imageware has the same size the imageware
* given as parameter.
*
* @param imageware imageware to be compared
* @return true if the imageware of the same size than this imageware
*/
public boolean isSameSize(ImageWare imageware) {
if (nx != imageware.getSizeX())
return false;
if (ny != imageware.getSizeY())
return false;
if (nz != imageware.getSizeZ())
return false;
return true;
}
//------------------------------------------------------------------
//
// put Section
//
//------------------------------------------------------------------
/**
* Put an array into the imageware at the position (x,y,z) in X axis.
* No check are performed if the array is outside of the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer ImageWare object to put into the imageware
*/
public void putX(int x, int y, int z, ImageWare buffer) {
int bnx = buffer.getSizeX();
double buf[] = new double[bnx];
buffer.getX(0, 0, 0, buf);
putX(x, y, z, buf);
}
/**
* Put an array into the imageware at the position (x,y,z) in Y axis.
* No check are performed if the array is outside of the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer ImageWare object to put into the imageware
*/
public void putY(int x, int y, int z, ImageWare buffer) {
int bny = buffer.getSizeY();
double buf[] = new double[bny];
buffer.getY(0, 0, 0, buf);
putY(x, y, z, buf);
}
/**
* Put an array into the imageware at the position (x,y,z) in Z axis.
* No check are performed if the array is outside of the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer ImageWare object to put into the imageware
*/
public void putZ(int x, int y, int z, ImageWare buffer) {
int bnz = buffer.getSizeZ();
double buf[] = new double[bnz];
buffer.getZ(0, 0, 0, buf);
putZ(x, y, z, buf);
}
/**
* Put an array into the imageware at the position (x,y,z) in XY axis.
* No check are performed if the array is outside of the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer ImageWare object to put into the imageware
*/
public void putXY(int x, int y, int z, ImageWare buffer) {
int bnx = buffer.getSizeX();
int bny = buffer.getSizeY();
double buf[][] = new double[bnx][bny];
buffer.getXY(0, 0, 0, buf);
putXY(x, y, z, buf);
}
/**
* Put an array into the imageware at the position (x,y,z) in XZ axis.
* No check are performed if the array is outside of the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer ImageWare object to put into the imageware
*/
public void putXZ(int x, int y, int z, ImageWare buffer) {
int bnx = buffer.getSizeX();
int bnz = buffer.getSizeZ();
double buf[][] = new double[bnx][bnz];
buffer.getXZ(0, 0, 0, buf);
putXZ(x, y, z, buf);
}
/**
* Put an array into the imageware at the position (x,y,z) in YZ axis.
* No check are performed if the array is outside of the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer ImageWare object to put into the imageware
*/
public void putYZ(int x, int y, int z, ImageWare buffer) {
int bny = buffer.getSizeY();
int bnz = buffer.getSizeZ();
double buf[][] = new double[bny][bnz];
buffer.getYZ(0, 0, 0, buf);
putYZ(x, y, z, buf);
}
/**
* Put an array into the imageware at the position (x,y,z) in XYZ axis.
* No check are performed if the array is outside of the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer ImageWare object to put into the imageware
*/
public void putXYZ(int x, int y, int z, ImageWare buffer) {
int bnx = buffer.getSizeX();
int bny = buffer.getSizeY();
int bnz = buffer.getSizeZ();
double buf[][][] = new double[bnx][bny][bnz];
buffer.getXYZ(0, 0, 0, buf);
putXYZ(x, y, z, buf);
}
/**
* Put an array into the imageware at the position (x,y,z) in X axis.
* No check are performed if the array is outside of the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer byte 1D array to put into the imageware
*/
public void putX(int x, int y, int z, byte[] buffer) {
try {
int offset = x+y*nx;
int leni = buffer.length;
byte[] tmp = (byte[])data[z];
System.arraycopy(buffer, 0, tmp, offset, leni);
}
catch(Exception e) {
throw_put("X", "No check", buffer, x, y, z);
}
}
/**
* Put an array into the imageware at the position (x,y,z) in X axis.
* No check are performed if the array is outside of the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer short 1D array to put into the imageware
*/
public void putX(int x, int y, int z, short[] buffer) {
try {
int offset = x+y*nx;
int leni = buffer.length;
byte[] tmp = (byte[])data[z];
for (int i=0; i 0) {
double nbSalt = nxy*nz/percentageSalt;
for( int k=0; k < nbSalt; k++) {
index = (int)(rnd.nextDouble() * nxy);
z = (int)(rnd.nextDouble() * nz);
((byte[])data[z])[index] = (byte)(rnd.nextDouble()*amplitudeSalt);
}
}
if (percentagePepper > 0) {
double nbPepper = nxy*nz/percentagePepper;
for( int k=0; k < nbPepper; k++) {
index = (int)(rnd.nextDouble() * nxy);
z = (int)(rnd.nextDouble() * nz);
((byte[])data[z])[index] = (byte)(-rnd.nextDouble()*amplitudeSalt);
}
}
}
/**
* Build an ImageStack of ImageJ.
*/
public ImageStack buildImageStack() {
ImageStack imagestack = new ImageStack(nx, ny);
for (int z=0; z max)
max = slice[k] & 0xFF;
}
}
for(int z=0; z max)
slice[k] = max;
}
}
}
/**
* Rescale the pixel intensity into [0..255].
*/
public void rescale() {
double maxImage = -Double.MAX_VALUE;
double minImage = Double.MAX_VALUE;
byte[] slice;
for(int z=0; z maxImage)
maxImage = slice[k] & 0xFF;
if ((slice[k] & 0xFF) < minImage)
minImage = slice[k] & 0xFF;
}
}
double a;
if (minImage-maxImage == 0) {
a = 1.0;
minImage = 128.0;
}
else {
a = 255.0 / (maxImage-minImage);
}
for(int z=0; z maxImage)
maxImage = slice[k] & 0xFF;
if ((slice[k] & 0xFF) < minImage)
minImage = slice[k] & 0xFF;
}
}
double a;
if (minImage-maxImage == 0) {
a = 1.0;
minImage = (maxLevel-minLevel)/2.0;
}
else {
a = (maxLevel-minLevel) / (maxImage-minImage);
}
for(int z=0; z maxImage)
maxImage = slice[k] & 0xFF;
if ((slice[k] & 0xFF) < minImage)
minImage = slice[k] & 0xFF;
}
}
double center = (maxLevel+minLevel)/2.0;
double a;
if ( minImage-maxImage == 0) {
a = 1.0;
minImage = (maxLevel-minLevel)/2.0;
}
else {
if ( Math.abs(maxImage) > Math.abs(minImage) )
a = (maxLevel-center) / Math.abs(maxImage);
else
a = (center-minLevel) / Math.abs(minImage);
}
for(int z=0; z thresholdValue ? high : low);
}
}
}
/**
* Apply a soft thresholding.
*
* All the pixels values strictly greater than '-thresholdValue' and stricty
* lower than 'thresholdValue' set to 0. The remaining positive values are
* reduced by 'thresholdvalue'; the remaining negative values are
* augmented by 'thresholdValue'.
*
* @param thresholdValue double value given the threshold
*/
public void thresholdSoft(double thresholdValue) {
byte zero = (byte)(0.0);
double pixel;
byte[] slice;
for(int z=0; zthresholdValue ? (byte)(pixel-thresholdValue) : zero));
}
}
}
/**
* Apply a hard thresholding.
*
* All the pixels values strictly greater than '-thresholdValue' and stricty
* lower than 'thresholdValue' are set to 0. The remaining values are
* unchanged.
*
* @param thresholdValue double value given the threshold
*/
public void thresholdHard(double thresholdValue) {
byte zero = (byte)(0.0);
double pixel;
byte[] slice;
for(int z=0; z -thresholdValue && pixel < thresholdValue)
slice[k] = zero;
}
}
}
/**
* Add a gaussian noise with a range [-amplitude..amplitude].
*
* @param amplitude amplitude of the noise
*/
public void addGaussianNoise(double amplitude) {
Random rnd = new Random();
byte[] slice = null;
for(int z=0; z 0) {
double nbSalt = nxy*nz/percentageSalt;
for( int k=0; k < nbSalt; k++) {
index = (int)(rnd.nextDouble() * nxy);
z = (int)(rnd.nextDouble() * nz);
((byte[])data[z])[index] += (byte)(rnd.nextDouble()*amplitudeSalt);
}
}
if (percentagePepper > 0) {
double nbPepper = nxy*nz/percentagePepper;
for( int k=0; k < nbPepper; k++) {
index = (int)(rnd.nextDouble() * nxy);
z = (int)(rnd.nextDouble() * nz);
((byte[])data[z])[index] -= (byte)(rnd.nextDouble()*amplitudeSalt);
}
}
}
} // end of class
\ No newline at end of file
diff --git a/src-plugins/imageware/imageware/ByteProcess.java b/src-plugins/imageware/imageware/ByteProcess.java
new file mode 100644
index 0000000000..01f5f30f2e
--- /dev/null
+++ b/src-plugins/imageware/imageware/ByteProcess.java
@@ -0,0 +1 @@
+package imageware;
import ij.ImageStack;
import java.awt.Image;
/**
* Class ByteProcess.
*
* @author Daniel Sage
* Biomedical Imaging Group
* Ecole Polytechnique Federale de Lausanne, Lausanne, Switzerland
*/
public class ByteProcess extends BytePointwise implements Process {
//------------------------------------------------------------------
//
// Constructors section
//
//------------------------------------------------------------------
protected ByteProcess(int nx, int ny, int nz) { super(nx, ny, nz); }
protected ByteProcess(Image image, int mode) { super(image, mode); }
protected ByteProcess(ImageStack stack, int mode) { super(stack, mode); }
protected ByteProcess(ImageStack stack, byte chan) { super(stack, chan); }
protected ByteProcess(byte[] array, int mode) { super(array, mode); }
protected ByteProcess(byte[][] array, int mode) { super(array, mode); }
protected ByteProcess(byte[][][] array, int mode) { super(array, mode); }
protected ByteProcess(short[] array, int mode) { super(array, mode); }
protected ByteProcess(short[][] array, int mode) { super(array, mode); }
protected ByteProcess(short[][][] array, int mode) { super(array, mode); }
protected ByteProcess(float[] array, int mode) { super(array, mode); }
protected ByteProcess(float[][] array, int mode) { super(array, mode); }
protected ByteProcess(float[][][] array, int mode) { super(array, mode); }
protected ByteProcess(double[] array, int mode) { super(array, mode); }
protected ByteProcess(double[][] array, int mode) { super(array, mode); }
protected ByteProcess(double[][][] array, int mode){ super(array, mode); }
/**
* Apply a separable gaussian smoothing over the image with the same
* strengthness in all directions.
* To have a smmothing effect the strengthness should be strictly
* greater than 0 and the size in the considered directions
* should be greater strictly than 1.
*
* @param sigma Strengthness of the smoothing
*/
public void smoothGaussian(double sigma) {
smoothGaussian(sigma, sigma, sigma);
}
/**
* Apply a separablegaussian smoothing over the image with an
* independant strengthness in the different directions.
* To have a smmothing effect the strengthness should be strictly
* greater than 0 and the size in the considered directions
* should be greater strictly than 1.
*
* @param sigmaX Strengthness of the smoothing in X axis
* @param sigmaY Strengthness of the smoothing in X axis
* @param sigmaZ Strengthness of the smoothing in X axis
*/
public void smoothGaussian(double sigmaX, double sigmaY, double sigmaZ) {
int n = 3;
double N = (double)n;
double poles[] = new double[n];
if (nx > 1 && sigmaX > 0.0) {
double s2 = sigmaX * sigmaX;
double alpha = 1.0 + (N/s2) - (Math.sqrt(N*N+2*N*s2)/s2);
poles[0] = poles[1] = poles[2] = alpha;
double line[] = new double[nx];
for (int z=0; z 1 && sigmaY > 0.0) {
double s2 = sigmaY * sigmaY;
double alpha = 1.0 + (N/s2) - (Math.sqrt(N*N+2*N*s2)/s2);
poles[0] = poles[1] = poles[2] = alpha;
double line[] = new double[ny];
for (int x=0; x 1 && sigmaZ > 0.0) {
double s2 = sigmaZ * sigmaZ;
double alpha = 1.0 + (N/s2) - (Math.sqrt(N*N+2*N*s2)/s2);
poles[0] = poles[1] = poles[2] = alpha;
double line[] = new double[nz];
for (int y=0; y (byte)tmp[k])
((byte[])data[z])[k] = (byte)tmp[k];
}
}
break;
case ImageWare.SHORT:
for(int z=0; z (byte)tmp[k])
((byte[])data[z])[k] = (byte)tmp[k];
}
}
break;
case ImageWare.FLOAT:
for(int z=0; z (byte)tmp[k])
((byte[])data[z])[k] = (byte)tmp[k];
}
}
break;
case ImageWare.DOUBLE:
for(int z=0; z (byte)tmp[k])
((byte[])data[z])[k] = (byte)tmp[k];
}
}
break;
default :
throw new ArrayStoreException(
"\n-------------------------------------------------------\n" +
"Error in imageware package\n" +
"Unknown type " + imageware.getType() + "].\n" +
"-------------------------------------------------------\n"
);
}
}
/**
* Add a imageware to the current imageware.
*
* @param imageware imageware to add
*/
public void add(ImageWare imageware) {
if (!isSameSize(imageware)) {
throw new ArrayStoreException(
"\n-------------------------------------------------------\n" +
"Error in imageware package\n" +
"Unable to add because the two operands are not the same size.\n" +
"[" + nx + "," + ny + "," + "," + nz + "] != " +
"[" + imageware.getSizeX() + "," + imageware.getSizeY() + "," + imageware.getSizeZ() + "].\n" +
"-------------------------------------------------------\n"
);
}
switch(imageware.getType()) {
case ImageWare.BYTE:
for(int z=0; z max)
max = slice[k] & 0xFF;
}
return max;
}
/**
* Return the mean value of this imageware.
*
* @return the mean value of this imageware
*/
public double getMean() {
return getTotal() / (nz*nxy);
}
/**
* Return the norm value of order 1.
*
* @return the norm value of this imageware in L1 sense
*/
public double getNorm1() {
double norm = 0.0;
double value = 0;
byte[] slice;
for(int z=0; z 0.0 ? value : -value);
}
}
return norm;
}
/**
* Return the norm value of order 2.
*
* @return the norm value of this imageware in L2 sense
*/
public double getNorm2() {
double norm = 0.0;
byte[] slice;
for(int z=0; z max)
max = slice[k] & 0xFF;
if ((slice[k] & 0xFF) < min)
min = slice[k] & 0xFF;
}
}
double minmax[] = {min, max};
return minmax;
}
} // end of class
\ No newline at end of file
diff --git a/src-plugins/imageware/imageware/Convolver.java b/src-plugins/imageware/imageware/Convolver.java
new file mode 100644
index 0000000000..ad0658e4bf
--- /dev/null
+++ b/src-plugins/imageware/imageware/Convolver.java
@@ -0,0 +1 @@
+package imageware;
/**
* Class Convolver.
* Routines to convolve a 1D signal applying mirror boundary conditions.
*
*
* @author Daniel Sage
* Biomedical Imaging Group
* Ecole Polytechnique Federale de Lausanne, Lausanne, Switzerland
*/
public class Convolver extends Object {
private static double tolerance = 10e-6;
/**
* Convolution with a Finite Impulse Response (FIR) filter.
*
* Note: Only with the periodic boundary conditions.
*
* @param input 1D input signal
* @param kernel kernel of the filter
*/
public static double[] convolveFIR(double[] input, double[] kernel)
{
int l = input.length;
if (l <= 1)
throw new IllegalArgumentException("convolveFIR: input signal too short");
double[] output = new double[l];
int indexq = kernel.length - 1;
int indexp = 0;
int n2 = 2 * (l - 1);
int origin = kernel.length/2;
int m = 1 + origin - kernel.length;
m -= (m < 0L) ? (n2 * ((m + 1 - n2) / n2)) : (n2 * (m / n2));
int k;
for (int i = 0; i < l; i++) {
int j = -kernel.length;
k = m;
indexq = kernel.length - 1;
double Sum = 0.0;
while (j < 0) {
indexp = k;
int kp = ((k - l) < j) ? (j) : (k - l);
if (kp < 0L) {
for (int n = kp; n < 0; n++) {
Sum += input[indexp] * kernel[indexq];
indexq--;
indexp++;
}
k -= kp;
j -= kp;
}
indexp = n2 - k;
int km = ((k - n2) < j) ? (j) : (k - n2);
if (km < 0L) {
for (int n = km; n < 0; n++) {
Sum += input[indexp] * kernel[indexq];
indexq--;
indexp--;
}
j -= km;
}
k = 0;
}
if (++m == n2) {
m = 0;
}
output[i] = Sum;
}
return output;
}
/**
* Convolve with with a Infinite Impluse Response filter (IIR)
*
* @param input 1D input signal
* @param poles 1D array containing the poles of the filter
*/
public static double[] convolveIIR(double[] input, double poles[]) {
double lambda = 1.0;
int l = input.length;
double[] output = new double[l];
for (int k = 0; k < poles.length; k++) {
lambda = lambda * (1.0 - poles[k]) * (1.0 - 1.0 / poles[k]);
}
for (int n = 0; n < l; n++) {
output[n] = input[n] * lambda;
}
for (int k = 0; k < poles.length; k++) {
output[0] = getInitialCausalCoefficientMirror(output, poles[k]);
for (int n = 1; n < l; n++) {
output[n] = output[n] + poles[k] * output[n - 1];
}
output[l-1] = getInitialAntiCausalCoefficientMirror(output, poles[k]);
for (int n = l - 2; 0 <= n; n--) {
output[n] = poles[k] * (output[n+1] - output[n]);
}
}
return output;
}
/**
* Convolve a 1D signal with a Infinite Impluse Response 2nd order (IIR2)
*
* Note: Only with the mirror (on bounds) boundary conditions.
*
* Purpose: Recursive implementation of a symmetric 2nd order
* filter with mirror symmetry boundary conditions :
*
* 1 1
* H[z] = --------------- * ---------------
* (1-b1*z-b2*z^2) (1-b1/z-b2/z^2)
*
* implemented in the following form:
*
* a1+a2*z a1+a2/z
* H[z] = --------------- + --------------- - a1
* (1-b1*z+b2*z^2) (1-b1/z+b2/z^2)
*
* where :
* a1 = -(b2 + 1.0) * (1 - b1 + b2) / ((b2 - 1.0) * (1 + b1 + b2));
* a2 = - a1 * b2 * b1 / (b2 + 1.0);
*
* @param input 1D input signal
* @param b1 first pole of the filter
* @param b2 second pole of the filter
*/
public static double[] convolveIIR2( double input[], double b1, double b2) {
int l = input.length;
int n2 = 2 * l;
double a1 = -(b2 + 1.0) * (1 - b1 + b2) / ((b2 - 1.0) * (1 + b1 + b2));
double a2 = - a1 * b2 * b1 / (b2 + 1.0);
// cBuffer stores temporary spline coefficients
double cBuffer[] = new double[n2];
// sBuffer contains a copy of s[] and a time reversed version of s[]
double sBuffer[] = new double[n2];
// copy signal s[] and its time reversed version to sBuffer[]
for( int n = 0; n < l; n++){
sBuffer[n] = input[n];
sBuffer[n2 - n - 1] = input[n];
}
// Determine the start index n0 for the causal recursion. n0 is chosen such
// that the error of cBuffer[0] and cBuffer[1] is smaller than the
// specified 'Tolerance'.
int n0 = 2;
if ((tolerance > 0.0) && (b2 != 1.0)) {
n0 = n2 - (int) Math.ceil(2.0 * Math.log(tolerance) / Math.log(b2));
}
if (n0 < 2) {
n0 = 2;
}
cBuffer[n0 - 1] = 0.0;
cBuffer[n0 - 2] = 0.0;
for (int n = n0; n < n2; n++) {
cBuffer[n] = a1 * sBuffer[n] + a2 * sBuffer[n-1] + b1 * cBuffer[n-1] - b2 * cBuffer[n-2];
}
cBuffer[0] = a1 * sBuffer[0] + a2 * sBuffer[n2-1] + b1 * cBuffer[n2-1] - b2 * cBuffer[n2-2];
cBuffer[1] = a1 * sBuffer[1] + a2 * sBuffer[0] + b1 * cBuffer[0] - b2 * cBuffer[n2-1];
// compute the remaining spline coefficients cBuffer(z) = H_{+}(z) * sBuffer(z) by
// recursive filtering
for( int n = 2; n < n2; n++) {
cBuffer[n] = a1 * sBuffer[n] + a2 * sBuffer[n-1] + b1 * cBuffer[n-1] - b2 * cBuffer[n-2];
}
// add together the temporary filter outputs to obtain the final spline coefficients
double[] output = new double[l];
for( int n = 0; n < l; n++) {
output[n] = cBuffer[n] + cBuffer[n2-n-1] - a1 * input[n];
}
return output;
}
/**
*/
private static double getInitialAntiCausalCoefficientMirror(double[] c, double z)
{
return((z * c[c.length - 2] + c[c.length - 1]) * z / (z * z - 1.0));
}
/**
*/
private static double getInitialCausalCoefficientMirror(double[] c, double z)
{
double z1 = z, zn = Math.pow(z, c.length - 1);
double sum = c[0] + zn * c[c.length - 1];
int horizon = c.length;
if (0.0 < tolerance) {
horizon = 2 + (int)(Math.log(tolerance) / Math.log(Math.abs(z)));
horizon = (horizon < c.length) ? (horizon) : (c.length);
}
zn = zn * zn;
for (int n = 1; (n < (horizon - 1)); n++) {
zn = zn / z;
sum = sum + (z1 + zn) * c[n];
z1 = z1 * z;
}
return(sum / (1.0 - Math.pow(z, 2 * c.length - 2)));
}
} // end of classe
\ No newline at end of file
diff --git a/src-plugins/imageware/imageware/Display.java b/src-plugins/imageware/imageware/Display.java
new file mode 100644
index 0000000000..96e02a7159
--- /dev/null
+++ b/src-plugins/imageware/imageware/Display.java
@@ -0,0 +1 @@
+package imageware;
import ij.ImagePlus;
import ij.ImageStack;
import ij.gui.ImageCanvas;
import ij.gui.ImageWindow;
import ij.process.ColorProcessor;
/**
* Class Display.
*
* @author Daniel Sage
* Biomedical Imaging Group
* Ecole Polytechnique Federale de Lausanne, Lausanne, Switzerland
*/
public class Display {
/**
* Shows a imageware with a specifc title.
*
* @param title a specific title
* @param ds the imageware to be shown
*/
static public void show(String title, ImageWare ds) {
(new ImagePlus(title, ds.buildImageStack())).show();
}
/**
* Shows color image composed by three datasets with a specifc title.
*
* @param title a specific title
* @param red the imageware to be shown in the red channel
* @param green the imageware to be shown in the green channel
* @param blue the imageware to be shown in the blue channel
*/
static public void showColor(String title, ImageWare red, ImageWare green, ImageWare blue) {
(new ImagePlus(title, buildColor(red, green, blue))).show();
}
/**
* Shows a imageware with a specifc title and with a specific magnification.
*
* @param title a specific title
* @param ds the imageware to be shown
* @param magnification zoom factor
*/
static public void show(String title, ImageWare ds, double magnification) {
ImagePlus imp = new ImagePlus(title, ds.buildImageStack());
imp.show();
ImageWindow win = imp.getWindow();
ImageCanvas canvas = win.getCanvas();
canvas.setMagnification(magnification);
canvas.setDrawingSize(
(int)Math.ceil(ds.getWidth()*magnification),
(int)Math.ceil(ds.getHeight()*magnification));
win.pack();
imp.updateAndRepaintWindow();
}
/**
* Shows color image composed by three datasets with a specifc title and with a specific magnification.
*
* @param title a specific title
* @param red the imageware to be shown in the red channel
* @param green the imageware to be shown in the green channel
* @param blue the imageware to be shown in the blue channel
* @param magnification zoom factor
*/
static public void showColor(String title, ImageWare red, ImageWare green, ImageWare blue, double magnification) {
ImagePlus imp = new ImagePlus(title, buildColor(red, green, blue));
imp.show();
ImageWindow win = imp.getWindow();
ImageCanvas canvas = win.getCanvas();
canvas.setMagnification(magnification);
canvas.setDrawingSize(
(int)Math.ceil(red.getWidth()*magnification),
(int)Math.ceil(red.getHeight()*magnification));
win.pack();
imp.updateAndRepaintWindow();
}
/**
*/
static private ImageStack buildColor(ImageWare red, ImageWare green, ImageWare blue) {
if (!red.isSameSize(green)) {
throw new ArrayStoreException(
"\n-------------------------------------------------------\n" +
"Error in imageware package\n" +
"Unable to create a ImageStack the channel are not the same size.\n" +
"[" + red.getSizeX() + "," + red.getSizeY() + "," + red.getSizeZ() + "] != " +
"[" + green.getSizeX() + "," + green.getSizeY() + "," + green.getSizeZ() + "].\n" +
"-------------------------------------------------------\n"
);
}
if (!red.isSameSize(blue)) {
throw new ArrayStoreException(
"\n-------------------------------------------------------\n" +
"Error in imageware package\n" +
"Unable to create a ImageStack the channel are not the same size.\n" +
"[" + red.getSizeX() + "," + red.getSizeY() + "," + red.getSizeZ() + "] != " +
"[" + blue.getSizeX() + "," + blue.getSizeY() + "," + blue.getSizeZ() + "].\n" +
"-------------------------------------------------------\n"
);
}
int nx = red.getSizeX();
int ny = red.getSizeY();
int nz = red.getSizeZ();
int nxy = nx*ny;
ImageStack imagestack = new ImageStack(nx, ny);
ColorProcessor cp;
byte[] r = new byte[nxy];
byte[] g = new byte[nxy];
byte[] b = new byte[nxy];
for (int z=0; z= nx) return 0.0;
if (y >= ny) return 0.0;
if (z >= nz) return 0.0;
if (x < 0) return 0.0;
if (y < 0) return 0.0;
if (z < 0) return 0.0;
return ((double[])data[z])[x+y*nx];
}
/**
* Get a pixel at specific position with specific boundary conditions
*
* If the positions is outside of this imageware, the method apply the
* boundary conditions to return a value.
*
* @param x position in the X axis
* @param y position in the Y axis
* @param z position in the Z axis
* @return a pixel value
*/
public double getPixel(int x, int y, int z, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw new ArrayStoreException(
"\n-------------------------------------------------------\n" +
"Error in imageware package\n" +
"Unable to put a pixel \n" +
"at the position (" + x + "," + y + "," + z + ".\n" +
"-------------------------------------------------------\n"
);
}
int xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
int yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
return ((double[])data[zp])[xp+yp*nx];
}
/**
* Get a interpolated pixel value at specific position without specific boundary conditions.
*
* If the positions is not on the pixel grid, the method return a interpolated
* value of the pixel (linear interpolation). If the positions is outside of this
* imageware, the method return 0.0.
*
* @param x position in the X axis
* @param y position in the Y axis
* @param z position in the Z axis
* @return a interpolated value
*/
public double getInterpolatedPixel(double x, double y, double z) {
if (x > nx-1) return 0.0;
if (y > ny-1) return 0.0;
if (z > nz-1) return 0.0;
if (x < 0) return 0.0;
if (y < 0) return 0.0;
if (z < 0) return 0.0;
double output = 0.0;
/*
int i = (x >= 0.0 ? ((int)x) : ((int)x - 1));
int j = (y >= 0.0 ? ((int)y) : ((int)y - 1));
int k = (z >= 0.0 ? ((int)z) : ((int)z - 1));
*/
int i = (x >= 0.0 ? ((int)x) : ((int)x - 1));
int j = (y >= 0.0 ? ((int)y) : ((int)y - 1));
int k = (z >= 0.0 ? ((int)z) : ((int)z - 1));
boolean fi = (i==nx-1);
boolean fj = (j==ny-1);
boolean fk = (k==nz-1);
int index = i+j*nx;
switch(getDimension()) {
case 1:
double v1_0 = (double)(((double[])data[k])[index]);
double v1_1 = (fi ? v1_0 : (double)(((double[])data[k])[index+1]));
double dx1 = x - (double)i;
return v1_1*dx1 - v1_0 * (dx1-1.0);
case 2:
double v2_00 = (double)(((double[])data[k])[index]);
double v2_10 = (fi ? v2_00 : (double)(((double[])data[k])[index+1]));
double v2_01 = (fj ? v2_00 : (double)(((double[])data[k])[index+nx]));
double v2_11 = (fi ? (fj ? v2_00 : v2_01) : (double)(((double[])data[k])[index+1+nx]));
double dx2 = x - (double)i;
double dy2 = y - (double)j;
return (dx2*(v2_11*dy2-v2_10*(dy2-1.0)) - (dx2-1.0)*(v2_01*dy2-v2_00*(dy2-1.0)));
case 3:
double v3_000 = (double)(((double[])data[k])[index]);
double v3_100 = (fi ? v3_000 : (double)(((double[])data[k])[index+1]));
double v3_010 = (fj ? v3_000 : (double)(((double[])data[k])[index+nx]));
double v3_110 = (fi ? ( fj ? v3_000 : v3_010 ) : (double)(((double[])data[k])[index+1+nx]));
double v3_001 = (fk ? v3_000 : (double)(((double[])data[k+1])[index]));
double v3_011 = (fk ? ( fj ? v3_000 : v3_010) : (double)(((double[])data[k+1])[index+1]));
double v3_101 = (fk ? ( fi ? v3_000 : v3_100) : (double)(((double[])data[k+1])[index+nx]));
double v3_111 = (fk ? ( fj ? ( fi ? v3_000 : v3_100) : v3_110) :(double)(((double[])data[k+1])[index+1+nx]));
double dx3 = x - (double)i;
double dy3 = y - (double)j;
double dz3 = z - (double)k;
double z1 = (dx3*(v3_110*dy3-v3_100*(dy3-1.0)) - (dx3-1.0)*(v3_010*dy3-v3_000*(dy3-1.0)));
double z2 = (dx3*(v3_111*dy3-v3_101*(dy3-1.0)) - (dx3-1.0)*(v3_011*dy3-v3_001*(dy3-1.0)));
return z2*dz3-z1*(dz3-1.0);
}
return output;
}
/**
* Get a interpolated pixel value at specific position with specific boundary conditions.
*
* If the positions is not on the pixel grid, the method return a interpolated
* value of the pixel (linear interpolation).
* If the positions is outside of this imageware, the method apply the
* boundary conditions to return a value.
*
* @param x position in the X axis
* @param y position in the Y axis
* @param z position in the Z axis
* @param boundaryConditions MIRROR or PERIODIC boundary conditions
* @return a interpolated value
*/
public double getInterpolatedPixel(double x, double y, double z, byte boundaryConditions) {
double output = 0.0;
int i = (x >= 0.0 ? ((int)x) : ((int)x - 1));
int j = (y >= 0.0 ? ((int)y) : ((int)y - 1));
int k = (z >= 0.0 ? ((int)z) : ((int)z - 1));
switch(getDimension()) {
case 1:
double v1_0 = getPixel(i, j, k, boundaryConditions);
double v1_1 = getPixel(i+1, j, k, boundaryConditions);
double dx1 = x - (double)i;
return v1_1*dx1 - v1_0 * (dx1-1.0);
case 2:
double v2_00 = getPixel(i, j, k, boundaryConditions);
double v2_10 = getPixel(i+1, j, k, boundaryConditions);
double v2_01 = getPixel(i, j+1, k, boundaryConditions);
double v2_11 = getPixel(i+1, j+1, k, boundaryConditions);
double dx2 = x - (double)i;
double dy2 = y - (double)j;
return (dx2*(v2_11*dy2-v2_10*(dy2-1.0)) - (dx2-1.0)*(v2_01*dy2-v2_00*(dy2-1.0)));
case 3:
double v3_000 = getPixel(i, j, k, boundaryConditions);
double v3_100 = getPixel(i+1, j, k, boundaryConditions);
double v3_010 = getPixel(i, j+1, k, boundaryConditions);
double v3_110 = getPixel(i+1, j+1, k, boundaryConditions);
double v3_001 = getPixel(i, j, k+1, boundaryConditions);
double v3_011 = getPixel(i+1, j, k+1, boundaryConditions);
double v3_101 = getPixel(i, j+1, k+1, boundaryConditions);
double v3_111 = getPixel(i+1, j+1, k+1, boundaryConditions);
double dx3 = x - (double)i;
double dy3 = y - (double)j;
double dz3 = z - (double)k;
double z1 = (dx3*(v3_110*dy3-v3_100*(dy3-1.0)) - (dx3-1.0)*(v3_010*dy3-v3_000*(dy3-1.0)));
double z2 = (dx3*(v3_111*dy3-v3_101*(dy3-1.0)) - (dx3-1.0)*(v3_011*dy3-v3_001*(dy3-1.0)));
return z2*dz3-z1*(dz3-1.0);
}
return output;
}
//------------------------------------------------------------------
//
// putPixel section
//
//------------------------------------------------------------------
/**
* Put a pixel at specific position
*
* If the positions is outside of this imageware, the method does nothing.
*
* @param x position in the X axis
* @param y position in the Y axis
* @param z position in the Z axis
*/
public void putPixel(int x, int y, int z, double value) {
if (x >= nx) return;
if (y >= ny) return;
if (z >= nz) return;
if (x < 0) return;
if (y < 0) return;
if (z < 0) return;
((double[])data[z])[x+y*nx] = (double)value;
}
//------------------------------------------------------------------
//
// getBounded section
//
//------------------------------------------------------------------
/**
* Get an array from the imageware at the position (x,y,z) in X axis.
* Copy only the bounded area, intersection between the array and the imageware.
*
* @param x X starting position to put the buffer
* @param y Y starting position to put the buffer
* @param z Z starting position to put the buffer
* @param buffer byte 1D array to get into the imageware
*/
public void getBoundedX(int x, int y, int z, byte[] buffer) {
try {
if (x >= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
double[] tmp = (double[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
double[] tmp = (double[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
double[] tmp = (double[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int offset = (x+iinf) + (y)*nx;
int leni = buffer.length;
if (x+leni < 0) return;
if (y < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
double[] tmp = (double[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
double[] tmp = (double[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
double[] tmp = (double[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
double[] tmp = (double[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int offset = (x) + (y+iinf)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y+leni < 0) return;
if (z < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
double[] tmp = (double[])data[z];
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (z < 0 ? -z : 0);
int k = z+iinf;
int offset = (x) + (y)*nx;
int leni = buffer.length;
if (x < 0) return;
if (y < 0) return;
if (z+leni < 0) return;
int isup = (z+leni >= nz ? nz-z : leni);
for (int i=iinf; i= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
double[] tmp = (double[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
double[] tmp = (double[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
double[] tmp = (double[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
double[] tmp = (double[])data[z];
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x+leni < 0) return;
if (y < 0) return;
if (z+lenj < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (y < 0 ? -y : 0);
int jinf = (z < 0 ? -z : 0);
int k = z+jinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
if (x < 0) return;
if (y+leni < 0) return;
if (z+lenj < 0) return;
int isup = (y+leni >= ny ? ny-y : leni);
int jsup = (z+lenj >= nz ? nz-z : lenj);
for (int j=jinf; j= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nx) return;
if (y >= ny) return;
if (z >= nz) return;
int iinf = (x < 0 ? -x : 0);
int jinf = (y < 0 ? -y : 0);
int kinf = (z < 0 ? -z : 0);
int ko = z+kinf;
int offset = 0;
int leni = buffer.length;
int lenj = buffer[0].length;
int lenk = buffer[0][0].length;
if (x+leni < 0) return;
if (y+lenj < 0) return;
if (z+lenk < 0) return;
int isup = (x+leni >= nx ? nx-x : leni);
int jsup = (y+lenj >= ny ? ny-y : lenj);
int ksup = (z+lenk >= nz ? nz-z : lenk);
for (int k=kinf; k= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
double[] tmp = (double[])data[zp];
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (byte)(tmp[xp + yp]);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in X axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockX(int x, int y, int z, short[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
double[] tmp = (double[])data[zp];
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (short)(tmp[xp + yp]);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in X axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockX(int x, int y, int z, float[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
double[] tmp = (double[])data[zp];
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (float)(tmp[xp + yp]);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in X axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockX(int x, int y, int z, double[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
double[] tmp = (double[])data[zp];
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i] = (double)(tmp[xp + yp]);
}
}
catch(Exception e) {
throw_get("X", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockY(int x, int y, int z, byte[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
double[] tmp = (double[])data[zp];
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (byte)(tmp[xp + yp*nx]);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockY(int x, int y, int z, short[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
double[] tmp = (double[])data[zp];
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (short)(tmp[xp + yp*nx]);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockY(int x, int y, int z, float[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
double[] tmp = (double[])data[zp];
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (float)(tmp[xp + yp*nx]);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Y axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockY(int x, int y, int z, double[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
double[] tmp = (double[])data[zp];
for (int i=0; i= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
buffer[i] = (double)(tmp[xp + yp*nx]);
}
}
catch(Exception e) {
throw_get("Y", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockZ(int x, int y, int z, byte[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (byte)(((double[])data[zp])[xyp]);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockZ(int x, int y, int z, short[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (short)(((double[])data[zp])[xyp]);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockZ(int x, int y, int z, float[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (float)(((double[])data[zp])[xyp]);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in Z axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 1D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockZ(int x, int y, int z, double[] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
xp = x;
while (xp < 0)
xp += xperiod;
while (xp >= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
int xyp = xp + yp*nx;
for (int i=0; i= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
buffer[i] = (double)(((double[])data[zp])[xyp]);
}
}
catch(Exception e) {
throw_get("Z", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the start position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXY(int x, int y, int z, byte[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
double[] tmp = (double[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (byte)(tmp[xp + yp]);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the start position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXY(int x, int y, int z, short[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
double[] tmp = (double[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (short)(tmp[xp + yp]);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the start position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXY(int x, int y, int z, float[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
double[] tmp = (double[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (float)(tmp[xp + yp]);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* get an array into the imageware at the start position (x,y,z) in XY axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer double 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXY(int x, int y, int z, double[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
zp = z;
while (zp < 0)
zp += zperiod;
while (zp >= nz) {
zp = zperiod - zp;
zp = (zp < 0 ? -zp : zp);
}
double[] tmp = (double[])data[zp];
for (int j=0; j= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (double)(tmp[xp + yp]);
}
}
}
catch(Exception e) {
throw_get("XY", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer byte 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXZ(int x, int y, int z, byte[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (byte)(((double[])data[zp])[xp + yp]);
}
}
}
catch(Exception e) {
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer short 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXZ(int x, int y, int z, short[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i= nx) {
xp = xperiod - xp;
xp = (xp < 0 ? -xp : xp);
}
buffer[i][j] = (short)(((double[])data[zp])[xp + yp]);
}
}
}
catch(Exception e) {
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
}
/**
* Get an array from the imageware at the start position (x,y,z) in XZ axis.
* Apply boundary conditions to get the outside area.
*
* @param x X starting position to get the buffer
* @param y Y starting position to get the buffer
* @param z Z starting position to get the buffer
* @param buffer float 2D array to get into the imageware
* @param boundaryConditions mirror or periodic boundary conditions
*/
public void getBlockXZ(int x, int y, int z, float[][] buffer, byte boundaryConditions) {
int xperiod=0;
int yperiod=0;
int zperiod=0;
switch(boundaryConditions) {
case ImageWare.MIRROR:
xperiod = (nx <= 1 ? 1: 2*nx - 2);
yperiod = (ny <= 1 ? 1: 2*ny - 2);
zperiod = (nz <= 1 ? 1: 2*nz - 2);
break;
case ImageWare.PERIODIC:
xperiod = nx;
yperiod = ny;
zperiod = nz;
break;
default:
throw_get("XZ", "Mirror or periodic boundaray conditions", buffer, x, y, z);
}
int xp, yp, zp;
try {
int leni = buffer.length;
int lenj = buffer[0].length;
yp = y;
while (yp < 0)
yp += yperiod;
while (yp >= ny) {
yp = yperiod - yp;
yp = (yp < 0 ? -yp : yp);
}
yp *= nx;
for (int j=0; j= nz) {
zp = zperiod - yp;
zp = (zp < 0 ? -zp : zp);
}
for (int i=0; i