Overlay cache buggy?

27 views
Skip to first unread message

lobsiger...@gmail.com

unread,
Mar 27, 2023, 11:16:44 AM3/27/23
to pytroll
Dear developers,

I only discovered that lately but I can reproduce it on Satpy 0.36, 0.38 and 0.41.1. Christian Peters confirmed this issue. When we use the overlay cache to speed up image creation all overlay outline and fill colors are dimmed down. I have a hard time to believe that this has always been like that. I normally design my overlays without cache and then switch cache on in scheduled image production. I definitely expect identical results with overlay cache True or False. Any ideas?

Best regards,
Ernst

Attached two examples with and without overlay cache.
Christian Peters provided the images of lake Geneva.



ir108_3d-cacheFalse.jpg
Sen3X-20230327-DAY-1202-hugo211709n-a_76-multi-blend_with_weights-cacheFalse.webp
ir108_3d-cacheTrue.jpg
Sen3X-20230327-DAY-1202-hugo211709n-a_76-multi-blend_with_weights-cacheTrue.webp

David Hoese

unread,
Mar 27, 2023, 11:53:17 AM3/27/23
to pyt...@googlegroups.com
Hey Ernst,

Wow, this should be a fun one to debug...

My guess is it has something to do with the alpha band. Looking at source code and documentation we see the `Image.paste` method being used:

https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.paste

This is used in two locations:

https://github.com/pytroll/pycoast/blob/4687a0ea4fa4b3bf630baec907b92cd06a01c5ff/pycoast/cw_base.py#L1202

and:

https://github.com/pytroll/pycoast/blob/4687a0ea4fa4b3bf630baec907b92cd06a01c5ff/pycoast/cw_base.py#L1215

You can see from the Pillow API docs how `mask` is supposed to be used. My guess is maybe we need to be smarter about how alpha is handled with the background image and the foreground/cached overlays. Basically the alpha channel of the overlay is used to determine how to blend the pasted image with the background/original image. The docs mention an "alpha_composite" method as an alternative that maybe we want to look into.

My other guess which is still alpha related, is that when creating the initial cached overlays there is one or more pycoast drawing method that isn't setting the alpha channel completely. For example, you have coastlines configured with the color being (255, 0, 0) but don't specify an alpha. What if the drawing method is updating R, G, and B, but leaving alpha at the default 0 or maybe interpolating it to something like 128. These are all just guesses so far.

Dave
> --
> You received this message because you are subscribed to the Google Groups "pytroll" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pytroll+u...@googlegroups.com <mailto:pytroll+u...@googlegroups.com>.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/pytroll/8d86e94e-853a-4ea5-b6d7-d36f4e22fb0fn%40googlegroups.com <https://groups.google.com/d/msgid/pytroll/8d86e94e-853a-4ea5-b6d7-d36f4e22fb0fn%40googlegroups.com?utm_medium=email&utm_source=footer>.
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

lobsiger...@gmail.com

unread,
Mar 28, 2023, 4:26:57 AM3/28/23
to pytroll
Test. Google seems to delete my posts :-(

lobsiger...@gmail.com

unread,
Mar 28, 2023, 5:19:07 AM3/28/23
to pytroll
My experiments show that the problem is in the PyCoast cache file generation.
I opened a PyCoast issue. Many thanks to Dave that will take care of this BUG.


Ernst
Reply all
Reply to author
Forward
0 new messages