Header position in Image stack

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

Header position in Image stack

junsheng
 
Hello,

Does anybody know where the header is automatically written in Tiff and
Raw stack? Because I'd like to read the information of height and width
of each image and number of images in the stack with our codes
programmed with C.

Cheers,
Junsheng
Reply | Threaded
Open this post in threaded view
|

Re: Header position in Image stack

Wayne Rasband
> Does anybody know where the header is automatically
> written in Tiff and Raw stack?

ImageJ puts TIFF header information in the first 768 bytes of the file.
Raw images and stacks do not have a header.

>  Because I'd like to read the information of height and
> width of each image and number of images in the stack
> with our codes programmed with C.

Bytes 0-7 contain the TIFF header. Within the header, bytes 0-1 are
always "MM", indicating  big-endian byte order. The first IFD (Image
File Directory) starts at byte 8. Within the IFD,  bytes 30-31 contain
the image width and bytes 42-43 contain the height. The number of
images in the stack can be found by doing a string search in the first
768 bytes for "images=". For example, with a 350 slice stack, the
string "images=350" will be somewhere within the first 768 bytes of the
file.

Why not use a tiff library like libtiff (http://www.libtiff.org/) to
open the images?

-wayne