Memory allocation of czi image

Everything OAD-related that won't fit in the other categories: share general aspects of macro programming and discuss the OAD environment
Post Reply
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Memory allocation of czi image

Post by user-6033 »

Hi,

I am a little bit confused of how the memory is allocated for the czi images? I allocate an array of zenimages of size 2752 x 2208 with pixeltype Bgr24, z-stack set to 9, time slices 0 and channels set to 1. After adding nine images into it the file size ends up in 640 Mb, which feels a bit large. The czi-idea is great and is excellent to use for the collection of images where image analaysis is to be performed but I foresee a coming problem when the stacks will be substantially larger. I might then need to need to change binning, compress images or use images saved as separate files in another file format. A plain colored image from the microscope of the same size with camera set at 14 bit becomes 35 Mb in czi format and about 10 Mb in tif. Even compressed (although at highest setting for jpg) is about twice as large as tif.

Best regards
Fredrik Olsson
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Hello all,

generally speaking the pure pixel data is, of course, the same regardless of czi or tiff as long as we compare equal images, e.g. pixel size 8 bit czi with 8 bit tiff and both uncompressed.

In some cases, e.g. some LSM experiments, a significant amount of additional data is stored in the czi file as attachments, so that certain processing functions etc. are able to their work most accuratly.

If all of this does not apply to your cases please respond here in the forum and we will have to find a way that we can download your example file(s) to investigate your case(s).
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Hi,

Unfortunately it does not apply to our case. It is ordninary LOM images. Tried to upload czi-file as a zipped file but nothing happpens and ordinary czi format is not allowed (and colored 2752x2208 image becomes 35 Mb in uncompressed/original mode).

Best regards
Fredrik Olsson
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Hello all,

thanks to Fredrik Olsson I got a bundle of image files to investigate the case.

To do the comparison ZEN (2.5, especially the Info-View) has been used for the czi files and IrfanView to get the information from the tif files.
I concentrated on the comparison between uncompressed czi and tif files, a color and a bw file.

First, the 14 bit depth color image with a size of 2752 x 2208 pixels:


The czi file has a true bit depth of 42 bit, which represents 3x14 bit. As 3x14 bit cannot easily be saved the memory necessary to hold the data is 3x16 bit which results in 48 bit. This is in accordance with the size of the file.

The tif file has a true bit depth of 24 bit, which represents 3x8 bit. In addition the uncompressed file showed up as LZW compressed in the info of IrfanView. This is in accordance with the size of the file which is a bis smaller than half of the size the czi file shows.

Second, the black and white image, also with a size of 2752 x 2208 pixels:

The czi file has a true bit depth of 14 bit. Again, as 14 bit cannot easily be saved the memory necessary to hold the data is 16 bit. This is in accordance with the size of the file.

The tif file has a true bit depth of 24 bit according to the Info-View. From my point of view, this is something to think about, as only 8 bit give an image size that is according to the file size. Investigating the image a bit more with IrfanView shows that the image has RGB with three absolute equal ‘channels’. Again, the uncompressed file showed up as LZW compressed in the info of IrfanView. From my point of view, LZW is aware of having three times the same data and thus is able to reduce the size by a factor of 3. This is in accordance with the size of the file, which is again half of the size the czi file shows.


I hope that everyone can see similar cases with his own files.

A czi file usually holds the full image data given from the camera in a very compact manner where metadata etc. is neglectable. So nobody has to 'feel odd'.

When converting the images from czi to other file formats care must be taken not to lose data. If data is lost (14 bit to 8, which means 16 bit to 8), the file simply is just half the size and when ‘unintended’ compression comes into play even more reduction of size is possible without being recognized easily.
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Thank you for your answer, very interesting!

So in practice it is not the czi images that are large its the other way around even though tif images could have been even smaller for BW. Even though the camera (we have Axiocam 506 color) is set at 14 bits there is an conversion for tif and jpg to 3x8 bits for both jpg and tif for BW images when we save the image in these formats. Changing the camera setting to 8 bits gives similar file size for tif so its logic. Is it possible to let Zen 2 Core save images acquired in BW mode as true BW images regarding tif or jpg?

So when acquiring 2D images through OAD script into a large czi stack the czi format of choice should be gray 16 bor BW and RGB48 for colored for a camera set at 14 bit depth?

Best regards
Fredrik
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Is it possible to let Zen 2 Core save images acquired in BW mode as true BW images regarding tif or jpg?
Hello Fredrik Olsson,

you could try 'save as' (right mouse click on image in the image list at the right hand side) or simply type jpg or tif as extension instead of czi when saving a file.
So when acquiring 2D images through OAD script into a large czi stack the czi format of choice should be gray 16 bor BW and RGB48 for colored for a camera set at 14 bit depth?
Yes, correct!
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Hi,

I did not mean how to save a general image as jpg or tif, that I know :)
What I mean is that how to save an image taken in BW mode so that the image is in grayscale but then avoid that Zen 2 core saves it as a colored image with equal values in all three channels (since this occurs when saving as jpg or tif). The images would take less memory space but my concern is more to avoid an extra grayscale conversion when opening the image in some other image processing softwares.
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

I did not mean how to save a general image as jpg or tif
On the 'Save File' workbench click 'Add Tool' and choose 'Image Export'.

Then choose the file type 'TIFF',
enable 'Convert to 8 Bit',
enable 'Original Data',
disable 'Apply Display Setting'.
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Thank you!!
user-6939
Posts: 1
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6939 »

Carl Zeiss Microscopy 3 wrote:Hello all,

thanks to Fredrik Olsson I got a bundle of image files to investigate the case.

To do the comparison ZEN (2.5, especially the Info-View) has been used for the czi files and IrfanView to get the information from the tif files.
I concentrated on the comparison between uncompressed czi and tif files, a color and a bw file.

First, the 14 bit depth color image with a size of 2752 x 2208 pixels:


The czi file has a true bit depth of 42 bit, which represents 3x14 bit. As 3x14 bit cannot easily be saved the memory necessary to hold the data is 3x16 bit which results in 48 bit. This is in accordance with the size of the file.

The tif file has a true bit depth of 24 bit, which represents 3x8 bit. In addition the uncompressed file showed up as LZW compressed in the info of IrfanView. This is in accordance with the size of the file which is a bis smaller than half of the size the czi file shows.

Second, the black and white image, also with a size of 2752 x 2208 pixels:

The czi file has a true bit depth of 14 bit. Again, as 14 bit cannot easily be saved the memory necessary to hold the data is 16 bit. This is in accordance with the size of the file.

The tif file has a true bit depth of 24 bit according to the Info-View. From my point of view, this is something to think about, as only 8 bit give an image size that is according to the file size. Investigating the image a bit more with IrfanView Psiphon shows that the image has RGB with three absolute equal ‘channels’. Again, the uncompressed file showed up as LZW compressed in the info of IrfanView. From my point of view, LZW is aware of having three times the same data and thus is able to reduce the size by a factor of 3. This is in accordance with the size of the file, which is again half of the size the czi file shows.


I hope that everyone can see similar cases with his own files.

A czi file usually holds the full image data given from the camera in a very compact manner where metadata etc. is neglectable. So nobody has to 'feel odd'.

When converting the images from czi to other file formats care must be taken not to lose data. If data is lost (14 bit to 8, which means 16 bit to 8), the file simply is just half the size and when ‘unintended’ compression comes into play even more reduction of size is possible without being recognized easily.
Thank you so much for helping with this wonderful post.
Post Reply