Posted by
Arne Seitz on
Jul 29, 2013; 2:41pm
URL: http://imagej.273.s1.nabble.com/ImageStack-unexpected-behaviour-tp5004200p5004202.html
Hi Seamus,
I can't explain why your script is not working but with slight modifications the first Image is no longer blank.
Cheers
Arne
int numImages=10;
int w = 16;
int h = 16;
// ImagePlus acqIm = NewImage.createShortImage("test", w, h, numImages, NewImage.FILL_BLACK);
ImageStack acqStack=new ImageStack(w,h,numImages);
// ImageStack acqStack = acqIm.getStack();
int nn = 1;
for (int i = 0; i < numImages; i++) {
short[] pixels = new short[w * h]; // zero-filled
for (int j = 0; j < w && j < h; j++) { // set diagonal to nonzero
pixels[j + w * j] = (short)15000;
}
acqStack.setPixels(pixels, nn);
nn++;
}
ImagePlus acqIm=new ImagePlus("test",acqStack);
acqIm.show();
> -----Original Message-----
> From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of
> Seamus Holden
> Sent: lundi 29 juillet 2013 15:42
> To:
[hidden email]
> Subject: ImageStack unexpected behaviour
>
> Hi there
>
> I am trying to preallocate a stack and then write some data to it (specifically
> images from a microscope in micromanager).
>
> Every time I try to write images to the preallocated stack, the first image is
> always blank. I have no idea why!
> Specifically, the script below gives a blank first frame, all other frames have a
> white diagonal as expected.
>
> Can anyone see where I am going wrong?
>
> Thanks in advance for your help.
> Regards,
> Seamus
>
> [test script]
>
> import ij.*;
> import ij.gui.*;
>
> int numImages=10;
> int w = 16;
> int h = 16;
>
> ImagePlus acqIm = NewImage.createShortImage("test", w, h, numImages,
> NewImage.FILL_BLACK); ImageStack acqStack = acqIm.getStack();
>
> int nn = 1;
> for (int i = 0; i < numImages; i++) {
> short[] pixels = new short[w * h]; // zero-filled
> for (int j = 0; j < w && j < h; j++) { // set diagonal to nonzero
> pixels[j + w * j] = (short)15000;
> }
>
> acqStack.setPixels(pixels, nn);
> nn++;
> }
> acqIm.show();
>
> [end of test script]
>
>
>
> --
> Dr Seamus Holden
> Post-doctoral Fellow
> Bâtiment des Sciences Physiques
> École Polytechnique Fédérale de Lausanne
> CH-1015 Lausanne, Switzerland
>
> Phone: +41-(0)21-693-0557
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html