nullpainter/sanchez

Completely Black and White PNG produced when underlaying with tranparency

Closed this issue · 13 comments

I have noticed some strange behaviour when underlaying with transparency.
I am trying to create a reprojected image of clouds on a transparent background, I am trying to do this by using a fully transparent PNG file as the underlay for a reprojected image.

If you set the output as a JPG file, you get the clouds overlaid on a black background, But if you save as a PNG file the output seems to have binary black/white pixels.

I understand this is not the intended use case for this feature and so might not be a bug.

I have attached a JPG and PNG of the image I am testing.

I could not identify a source for this problem unfortunately.

JPG image:
test

PNG image:
test

Hi Thomas,

Really sorry for the delay. I'm afraid I'm unable to replicate this. Are you able to send me the command-line arguments you used?

For your reference, I created a fully transparent PNG file with Gimp (Photoshop didn't let me!) and used the following basic arguments:

.\sanchesz.exe reproject -s C:\code\sanchez\Tests\TestSuite\sample-images\IMG_FD_020_IR105_20200907_032006.jpg -u C:\temp\transparent.png -o foo.png -v -f

I've also tried with various level adjustment options, and none ended up looking like that.

By the way, does -U (no underlay) not suit your purposes?

I can still reproduce this with your options, I am running linux so that is probably the reason here. I tried running on windows 7 but I could not install .net7. I am going to install Windows 11 and see if it works on there

and -U is not what I'm trying to do, I'm trying to have the transparency as the underlay and have a cloud only image.

This is strange! I can reproduce it on windows 11 too. With the same options you are using. Would you like me to send the exact file I'm using?

Here is a zip with the output image, input image, transparent background and satellites.json I was using.
The command run on windows 11 was Sanchez.exe reproject -s GOES16_IR_20230814T100506Z.png -u transparent.png -o out.png -D satellites.json -v -f
upload.zip

Thanks @thomasdouwes. The issue appears to be with your transparent png file, or rather, how Sanchez is handling it. exiftool reveals that your image is 1 bit only:

File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 10848
Image Height                    : 5424
Bit Depth                       : 1
Color Type                      : Grayscale
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced

This is resulting in the output file also being 1 bit. I can certainly see if I can force the output to be the highest bit depth of all images, although this sounds like a bit of an edge case.

and -U is not what I'm trying to do, I'm trying to have the transparency as the underlay and have a cloud only image.

-U renders the image without the underlay. It's been a while since I wrote this, but isn't a fully transparent underlay the equivalent of no underlay?

I think I made that transparent image with ImageMagick and probably made a mistake with the parameters. I made a new image in GIMP, but I seem to be running into a different issue. Now the background is completely black, like with the JPEG image.
out
This is the sort of image I am trying to make:
out

-U renders the image without the underlay. It's been a while since I wrote this, but isn't a fully transparent underlay the equivalent of no underlay?

With -U It seems to project the full colour image without any underlaying, I'm trying to get the clouds on a transparent background
out
Thank you for all the help so far.

With -U It seems to project the full colour image without any underlaying, I'm trying to get the clouds on a transparent background

The only reason Sanchez produces a full-colour image is beacuse of the underlay and the tint that it applies to improve the final blended image. Using -U renders the image with no underlay and no tint, and with a transparent background if outputting to a PNG. I'm still confused as to how this isn't what you're after. Namely:

.\sanchez.exe reproject -U -o out.png  -v -f -s GOES16_FD_CH13_20200830T035020Z.jpg -n

Here, -n removes the gaussian noise which is currently also being applied to the transparent background. I should probably fix this.

No noise:
no-noise

Default with noise:
with-noise

A transparent underlay is identical to no underlay.

If you're attempting to change the transparency of the output image based on pixel intensity, I'm afraid this isn't something that Sanchez does. You may want to use Photoshop (or ImageMagick?) and duplicate an inverted image into an alpha channel.

If there's a really useful use-case for this though, I'm all ears!

Sounds like a task for ImageMagick, I do this in a lot of my imagery post-processing.
Taking the image generated then stripping out the background and creating a transparent png that could then be applied over any other image (the grid in the image is just a background for the transparency).

Screenshot 2023-08-16 154609

convert "input.png or input.jpg" -alpha set -background none -channel A -evaluate multiply 0.2 +channel -filter spline -unsharp 0x1 -blur 1x1 "transparent.png"

Of course you would have to play with all the parameters to truly build what is essentially a clear sky mask, the trick is to keep the cloud level brightness, yet strip away, land mass, ocean, sunlight elections etc.

The image at the top of this page is built using sanchez and imagemagick https://usradioguy.com/daily-global-composite/

Thanks, I made the example using ImageMagick, but your settings are much better than the basic ones I was using

With -U It seems to project the full colour image without any underlaying, I'm trying to get the clouds on a transparent background

The only reason Sanchez produces a full-colour image is beacuse of the underlay and the tint that it applies to improve the final blended image. Using -U renders the image with no underlay and no tint, and with a transparent background if outputting to a PNG. I'm still confused as to how this isn't what you're after. Namely:

.\sanchez.exe reproject -U -o out.png  -v -f -s GOES16_FD_CH13_20200830T035020Z.jpg -n

Here, -n removes the gaussian noise which is currently also being applied to the transparent background. I should probably fix this.

No noise: no-noise

Default with noise: with-noise

A transparent underlay is identical to no underlay.

Sorry, I should have been more clear, by full colour I meant projecting the original image without any underlaying, like in your example. I think @creinemann's ImageMagick setting are what I am looking for here. Thank you for the help though.
I will close this issue now as it isn't a bug.