Gif - Colored string gets dimmed

Hello All,

I am a new user and would first like to greet everyone here in the community. :slight_smile:

While writing a macro to overlay text over an image stack, I noticed that the quality of the result looks good in Fiji/ImageJ, but when I save the animation as a gif the colored part of the text gets dimmed in some frames. I have attached two images so you guys can see what I mean. At first I deleted the section of the image stack where the text is supposed to go, and also tried coloring it black before adding the overlay, but neither method worked. I also tried using the “save as animated gif” option, but the result was the same. Any ideas how to fix this issue?

(The macro is written in the ImageJ1 Macro language.)
Thank you in advance :slight_smile:

imagej_gif1 imagej_gif2

Good day,

no idea how to fix it because the problem appears being with the GIF-format that uses AFAIK a maximum of 255 colors, grays included, and these colors may be assigned automatically.

Furthermore, you don’t use ImagJ to view your stack. Perhaps IrfanView is responsible for the problem. And why do you post screen shots?

Why don’t you post image sample, not screen shots, from ImageJ.

Regards

Herbie

Hello,

thank you for your quick response. I just tried opening the GIF with internet explorer and I see the same issue. The reason why I posted screenshots is because the data is confidential.

Thank you.

Are you sure that ImageJ, not the GIF-format per se, is responsible for the described effect?

Herbie

I tried the BioFormats Exporter and it seems that saving the animation as an animated PNG fixed the issue. From the properties of the files I see that the regular “save as GIF” option saves an 8 bit file, whereas the BioFormats Exporter saves a 32 bit file. The file size difference is larger, but for now I can live with that.

Perhaps an option to set the bit depth could be added to the “save as gif” menu.

Good day!

I fear you are not perfectly clear about the formats.

GIF uses lossy image compression and indexed colors.
The standard GIF (used by ImageJ) is 8bit deep and can display 256 colors (Grays included).
https://de.wikipedia.org/wiki/Graphics_Interchange_Format
I guess that this color-table coding is the reason for the observed color differences.

PNG uses lossless compression and true color.
The standard PNG does not allow for 32bit per channel.
Compared to GIF it will necessarily create bigger files.
https://de.wikipedia.org/wiki/Portable_Network_Graphics

ImageJ directly allows one to save stacks as standard GIF (8bit color table) but also as 24bit-RGB AVI with no compression, with lossy JPEG-compression or with lossless PNG-compression.

HTH

Herbie

Hello again,

You are right, I should have looked into the details of what a GIF is. It seems a bit strange though that for some frames it “works” and for others it doesn’t. I assume that that has to do with the individual frames, and if I threshold the images prior to adding the overlay, it would help. For now I’ll use the animated PNG, or leave the color as white.

Thanks for the help :slight_smile:

I assume that that has to do with the individual frames

Indeed, I suspect that the color table is set on a frame by frame basis and not for the whole stack.

Regards

Herbie