Returns, as a double, the value of the specified voxel. Throws an IndexOutOfBoundsException if x, y or z are beyond the stack limits. Use the ImagePlus.getStackIndex() method to convert a C,Z,T hyperstack position (one-based) into a z index (zero-based). @see ij.ImagePlus#getStackIndex
(int x, int y, int z)
| 412 | * @see ij.ImagePlus#getStackIndex |
| 413 | */ |
| 414 | public final double getVoxel(int x, int y, int z) { |
| 415 | if (x>=0 && x<width && y>=0 && y<height && z>=0 && z<nSlices) { |
| 416 | switch (bitDepth) { |
| 417 | case 8: |
| 418 | byte[] bytes = (byte[])stack[z]; |
| 419 | return bytes[y*width+x]&0xff; |
| 420 | case 16: |
| 421 | short[] shorts = (short[])stack[z]; |
| 422 | return shorts[y*width+x]&0xffff; |
| 423 | case 32: |
| 424 | float[] floats = (float[])stack[z]; |
| 425 | return floats[y*width+x]; |
| 426 | case 24: |
| 427 | int[] ints = (int[])stack[z]; |
| 428 | return ints[y*width+x]&0xffffffff; |
| 429 | default: return Double.NaN; |
| 430 | } |
| 431 | } else |
| 432 | throw new IndexOutOfBoundsException(); |
| 433 | } |
| 434 | |
| 435 | /** Sets the value of the specified voxel. */ |
| 436 | public final void setVoxel(int x, int y, int z, double value) { |
no outgoing calls
no test coverage detected