MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / setVoxels

Method setVoxels

ij/src/main/java/ij/ImageStack.java:535–588  ·  view source on GitHub ↗

Experimental

(int x0, int y0, int z0, int w, int h, int d, float[] voxels)

Source from the content-addressed store, hash-verified

533
534 /** Experimental */
535 public void setVoxels(int x0, int y0, int z0, int w, int h, int d, float[] voxels) {
536 boolean inBounds = x0>=0 && x0+w<=width && y0>=0 && y0+h<=height && z0>=0 && z0+d<=nSlices;
537 if (voxels==null || voxels.length!=w*h*d)
538 ;
539 int i = 0;
540 float value;
541 for (int z=z0; z<z0+d; z++) {
542 for (int y=y0; y<y0+h; y++) {
543 if (inBounds) {
544 switch (bitDepth) {
545 case 8:
546 byte[] bytes = (byte[])stack[z];
547 for (int x=x0; x<x0+w; x++) {
548 value = voxels[i++];
549 if (value>255f)
550 value = 255f;
551 else if (value<0f)
552 value = 0f;
553 bytes[y*width+x] = (byte)(value+0.5f);
554 }
555 break;
556 case 16:
557 short[] shorts = (short[])stack[z];
558 for (int x=x0; x<x0+w; x++) {
559 value = voxels[i++];
560 if (value>65535f)
561 value = 65535f;
562 else if (value<0f)
563 value = 0f;
564 shorts[y*width+x] = (short)(value+0.5f);
565 }
566 break;
567 case 32:
568 float[] floats = (float[])stack[z];
569 for (int x=x0; x<x0+w; x++) {
570 value = voxels[i++];
571 floats[y*width+x] = value;
572 }
573 break;
574 case 24:
575 int[] ints = (int[])stack[z];
576 for (int x=x0; x<x0+w; x++) {
577 value = voxels[i++];
578 ints[y*width+x] = (int)value;
579 }
580 break;
581 }
582 } else {
583 for (int x=x0; x<x0+w; x++)
584 setVoxel(x, y, z, voxels[i++]);
585 }
586 }
587 }
588 }
589
590 /** Experimental */
591 public void setVoxels(int x0, int y0, int z0, int w, int h, int d, float[] voxels, int channel) {

Callers 1

blurZMethod · 0.80

Calls 2

setVoxelMethod · 0.95
getVoxelMethod · 0.95

Tested by

no test coverage detected