This project has moved. For the latest updates, please go here.

[SOLVED] HDRI tonemapping to [0,1]

Apr 24, 2016 at 5:25 PM
Edited Apr 26, 2016 at 12:00 PM
Hello, I am using magick.net HDRI 16 AnyCpu and I was struggling to find a magick.net built in way to convert my freshly loaded from .hdr file MagickImage into another MagickImage with colors in range of [0,1]. Is there any? I know that if i write back my image as filename.jpg it gets automatically tonemapped to 0-255 8bit depth rgb image so I hope it's just that I don't know where to look for.

[SOLUTION]
I was mistaken thinking I should upload a [0,1] Texture. The right techinque consists in rendering in high dynamic range to a FBO and then tonemap with a chosen techinique with another couple of vertex/fragment shaders. This is what helped me a lot. As a matter of fact, this is not related anymore to Magick.net, so if you want to delete it, go on.
Coordinator
Apr 24, 2016 at 9:39 PM
ImageMagick / Magick.NET will always translate the values to 0-65535 (Q16) internally. I don't understand why you need the range to be at 0-1 instead.
Apr 25, 2016 at 7:01 AM
That's because I want to load it in an OpenGL texture, and I read that OpenGL works with values normalized in [0,1]. Isn't it how I should do it? Shouldn't I normalize all the values before loading them in the texture?
Coordinator
Apr 25, 2016 at 9:07 PM
You can use Evaluate as Snibgo suggested in this topic: https://www.imagemagick.org/discourse-server/viewtopic.php?f=27&p=132377
image.Evaluate(Channels.All, EvaluateOperator.Divide, Quantum.Max);
This will normalize the pixel values and you could then access the pixels directly with image.GetPixels().
Apr 26, 2016 at 8:26 AM
I think you are missing a passage. Being a .hdr file I have values which are higher than Quantum.Max, so dividing by it doesn't normalize in [0,1]. I have tried to convert to tiff as Snibgo suggested but I got no luck, as I've written in that thread. Although there my be something wrong in my code, so I posted it. Thanks for following my issue, I really appreaciate that.