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
namespace
OIIO
;
auto
min
=
half
{
0.0f
};
auto
max
=
half
{
0.0f
};
for
(
auto
it
=
ImageBuf
::
ConstIterator
<
float
>{
*
image
};
!
it
.
done
();
++
it
)
for
(
auto
c
=
0
;
c
<
image
->
nchannels
();
++
c
)
{
if
(
it
[
c
]
<
min
)
min
=
it
[
c
]
;
if
(
it
[
c
]
>
max
)
max
=
it
[
c
]
;
}
for
(
auto
it
=
ImageBuf
::
Iterator
<
float
>{
*
image
};
!
it
.
done
();
++
it
)
for
(
auto
c
=
0
;
c
<
image
->
nchannels
();
++
c
)
it
[
c
]
=
0.0f
+
(
it
[
c
]
-
min
)
*
(
1.0f
-
0.0f
)
/
(
max
-
min
);
}
_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org