Open unrecognised stack

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Open unrecognised stack

Michael Doube-2
Hi all

I have some stacks that I'd like to open with ImageJ, more quickly than
having to go File->Import->Raw, and recovering stack dimensions with a
hex editor.

The recorded macro command goes like this:
run("Raw...", "open="+imagename+" image=8-bit width=900 height=160
offset=512 number=496 gap=0");

I can get the stack dimensions from the first 6 bytes of the header (512
B header) e.g. hex 84 03 A0 00 F0 01 = 900 x 160 x 496 pixels.

Is there a quick and dirty way to get the stack dimensions from the
header so that I can make a wee macro, or could a file opener plugin be
extended?

Cheers,

Mike

--
Michael Doube  BPhil BVSc MRCVS
PhD Student
Dental Institute
Queen Mary, University of London
New Rd
London  E1 1BB
United Kingdom

Phone +44 (0)20 7377 7000 ext 2681
Reply | Threaded
Open this post in threaded view
|

Re: Open unrecognised stack

Michael Schmid
Hi Mike,

Yes, there is such a trick:

First open the file as single 16-bit raw image with offset = 0, 3 x 1  
pixels size.

Read the first three pixel values - these are the first three 16-bit  
numbers.

For an example of such a macro, see
   http://rsb.info.nih.gov/ij/macros/OpenMacIPLab.txt

Michael

On 18 Apr 2007, at 11:44, Michael Doube wrote:

> Hi all
>
> I have some stacks that I'd like to open with ImageJ, more quickly  
> than having to go File->Import->Raw, and recovering stack  
> dimensions with a hex editor.
>
> The recorded macro command goes like this:
> run("Raw...", "open="+imagename+" image=8-bit width=900 height=160  
> offset=512 number=496 gap=0");
>
> I can get the stack dimensions from the first 6 bytes of the header  
> (512 B header) e.g. hex 84 03 A0 00 F0 01 = 900 x 160 x 496 pixels.
>
> Is there a quick and dirty way to get the stack dimensions from the  
> header so that I can make a wee macro, or could a file opener  
> plugin be extended?
>
> Cheers,
>
> Mike
>
Reply | Threaded
Open this post in threaded view
|

Re: Open unrecognised stack

Michael Doube-2
Thanks Michael, this worked:

--------------------
      run("Raw...", "image=8-bit width=100 height=1 offset=0 number=1");
      width = getPixel(1,0)*256 + getPixel(0,0);
      height = getPixel(3,0)*256 + getPixel(2,0);
      slices = getPixel(5,0)*256 +getPixel(4,0);
      path = "'"+getDirectory("image")+getTitle+"'";
      run("Close");
      run("Raw...", "open="+path+" image=8-bit width="+width+"
height="+height+" offset=512 number="+slices);
-----------------------

Mike

Michael Schmid wrote:

> Hi Mike,
>
> Yes, there is such a trick:
>
> First open the file as single 16-bit raw image with offset = 0, 3 x 1
> pixels size.
>
> Read the first three pixel values - these are the first three 16-bit
> numbers.
>
> For an example of such a macro, see
>   http://rsb.info.nih.gov/ij/macros/OpenMacIPLab.txt
>
> Michael
>
> On 18 Apr 2007, at 11:44, Michael Doube wrote:
>
>> Hi all
>>
>> I have some stacks that I'd like to open with ImageJ, more quickly
>> than having to go File->Import->Raw, and recovering stack dimensions
>> with a hex editor.
>>
>> The recorded macro command goes like this:
>> run("Raw...", "open="+imagename+" image=8-bit width=900 height=160
>> offset=512 number=496 gap=0");
>>
>> I can get the stack dimensions from the first 6 bytes of the header
>> (512 B header) e.g. hex 84 03 A0 00 F0 01 = 900 x 160 x 496 pixels.
>>
>> Is there a quick and dirty way to get the stack dimensions from the
>> header so that I can make a wee macro, or could a file opener plugin
>> be extended?
>>
>> Cheers,
>>
>> Mike
>>