Julia image display on Mac goes dark

I’m working with some images in Julia, and I’m running into a problem; the images, when displayed from the Julia command line with ImageView, or within a Jupyter notebook, are much much darker than when they are displayed by the Mac image viewer, preview, or by the Chrome browser. Has anyone else observed this? Any ideas about what is going on?

What type of images are they, and how are you loading them?

Also, what do you mean when you much much darker? Do all the colors appear as their darker variant, or is it some parts of the image that appear black or some dark colour? If it’s the former, then the issue is probably with the loading of the image, the data in it not being interpreted the right way.

It would also be useful if you’re able to share any of the images, along with how they look in Julia vs other image viewers.

Loading it with FileIO.load()

This is my test image; a very old image from a physically based rendering program. I’ve done some more experimentation and it’s absolutely eerie. There’s some sort of exposure compensation with the OS app and browser that works differently in the Julia image display software with this particular image. Here, right now, in the browser it looks fine. I’ve screenshotted the Jupyter display, and look how dark it is. And yet most of the time the Julia image load seems to work fine.

A little more testing reveals that, not very surprisingly, the pixel values come in correctly and that, yes, the dark areas of the image are quite dark. Is the OS/browser display software applying some sort of exposure correction (gamma? histogram?) which Julia does not apply?

Have you tried different browsers?

I’ve now tried Chrome, Firefox, and Safari, as well as the macOS “preview” app and Affinity Photo; all produce similar results.

And I’ve also tried Julia ImageView from the command line which again produces dark results.

And the answer is…

All the browsers, preview, and Affinity Photo apply a 𝛾 of .45 to the image before displaying it; Julia apparently does not.

4 Likes

Thanks for sharing the answer once you figured it out! That’s probably gonna help a bunch of folks in the future with the same issue.

Since you’re using Images.jl anyway, you can also use the GammaCorrection via adjust_histogram like in this example.

1 Like

I figured that out this morning; adjust_histogram(…, GammaCorrection(.45)) seems to do the same thing as my hack. It’s also an open issue from ten years ago(!) on the JuliaGraphics GitHub.

When I get a few moments, I’m going to try it on Windows and see what happens.

2 Likes

I did get a moment, uploaded several images, and they seem to have gotten lost. Possibly I shut the browser down before the upload finished. But, yes, the same issue occurs on Windows. It’s apparently an old issue, which perhaps has never even been discussed. Unfortunately, “RGB” is not standardized. (That has been discussed.) The common treatment of RGB data which doesn’t have a profile is to assume that a 𝛾 of .45 has been used, and reverse that on display by applying a 𝛾 of 2.2. Julia doesn’t do that.

Here’s a discussion of why using 𝛾 makes sense when using 8-bit RGB data from a photographic web site.

1 Like