Sets the value of the specified voxel.
(int x, int y, int z, double value)
| 434 | |
| 435 | /** Sets the value of the specified voxel. */ |
| 436 | public final void setVoxel(int x, int y, int z, double value) { |
| 437 | if (x>=0 && x<width && y>=0 && y<height && z>=0 && z<nSlices) { |
| 438 | switch (bitDepth) { |
| 439 | case 8: |
| 440 | byte[] bytes = (byte[])stack[z]; |
| 441 | if (value>255.0) |
| 442 | value = 255.0; |
| 443 | else if (value<0.0) |
| 444 | value = 0.0; |
| 445 | bytes[y*width+x] = (byte)(value+0.5); |
| 446 | break; |
| 447 | case 16: |
| 448 | short[] shorts = (short[])stack[z]; |
| 449 | if (value>65535.0) |
| 450 | value = 65535.0; |
| 451 | else if (value<0.0) |
| 452 | value = 0.0; |
| 453 | shorts[y*width+x] = (short)(value+0.5); |
| 454 | break; |
| 455 | case 32: |
| 456 | float[] floats = (float[])stack[z]; |
| 457 | floats[y*width+x] = (float)value; |
| 458 | break; |
| 459 | case 24: |
| 460 | int[] ints = (int[])stack[z]; |
| 461 | ints[y*width+x] = (int)value; |
| 462 | break; |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | public float[] getVoxels(int x0, int y0, int z0, int w, int h, int d, float[] voxels) { |
| 468 | boolean inBounds = x0>=0 && x0+w<=width && y0>=0 && y0+h<=height && z0>=0 && z0+d<=nSlices; |
no outgoing calls
no test coverage detected