Re: [Oiio-dev] Normalize values

2019-11-29 Thread Kevin Wheatley
to further what Larry is saying, you might want to check out using numeric limits to initialise min and max based on your source data type, (or at least for float as that is the type of your min and max variables) see https://en.cppreference.com/w/cpp/types/numeric_limits/lowest So you should

Re: [Oiio-dev] Normalize values

2019-11-27 Thread Larry Gritz
I'm still concerned about your initialization of the "min" variable. Can you see how this will give the incorrect result if the minimum pixel value in your image is > 0 ? As written below, this will scale up the lightest values to fully "white", but it will fail to convert the darkest values

Re: [Oiio-dev] Normalize values

2019-11-27 Thread Chris Dawlud
Thank you. It makes a lot of sense. I completely forgot about discarding alpha channel. Also, I'm using half format so in my specific case I should have used half instead of float in the iterator constructor. For future reference, here's the working code: void ImageLoader :: normalize (

Re: [Oiio-dev] Normalize values

2019-11-27 Thread Larry Gritz
To clarify: I believe that the contrast_remap function is new in OIIO 2.1. On older versions, or merely if you prefer it, I think you could achieve the same thing with ImageBufAlgo::sub(*image, *image, min, roi); ImageBufAlgo::mul(*image, *image, (max-min), roi); Note also that this

Re: [Oiio-dev] Normalize values

2019-11-27 Thread Larry Gritz
In what way doesn't it work properly? Does it crash? Appear to do nothing? Do something but not what you expect? What kind of image are you trying (I mean, what data type and channels)? I can only speak in generalities without this info, but here's what I spotted as likely problems. *

[Oiio-dev] Normalize values

2019-11-27 Thread Chris Dawlud
Hi, I want to normalize exr to make even very bright/dark images visible. The idea is simple but I can't figure out how to do this correctly. I have come up with the following, but it doesn't work properly: void ImageLoader :: normalize ( OIIO :: ImageBuf * image ) { using