diff --git a/Makefile b/Makefile index f9ecb17d2e..d6ba974a48 100644 --- a/Makefile +++ b/Makefile @@ -299,7 +299,7 @@ clang-format: config # DEPRECATED: 'make dist' is just a synonym for 'make install' dist : install -TEST_FLAGS += --force-new-ctest-process --output-on-failure --progress +TEST_FLAGS += --force-new-ctest-process --output-on-failure # 'make test' does a full build and then runs all tests test: build diff --git a/src/doc/oiiotool.rst b/src/doc/oiiotool.rst index d719f19dc8..e32eaa0dc9 100644 --- a/src/doc/oiiotool.rst +++ b/src/doc/oiiotool.rst @@ -2557,6 +2557,38 @@ current top image. Include/exclude subimages (see :ref:`sec-oiiotool-subimage-modifier`). +.. option:: --normalize + + Normalize the top image. Assuming the first three channels represent a 3D + vector, divide each pixel by its length to make it unit length. This + function assumes a 3-channel image that represents a 3-vector, or a + 4-channel image that represents a 3-vector plus an alpha value. If an + alpha channel is present, its value is merely copied, and is not part of + the normalization computation. + + Optional appended modifiers include: + + `:incenter=` *float* + The pixel value that corresponds to a 0.0 vector value for the input. + (default: 0.0) + + `:outcenter=` *float* + The pixel value that corresponds to a 0.0 vector value for the output. + (default: 0.0) + + `:scale=` *float* + The desired length of the output vectors. (default: 1.0) + + Example:: + + # Normalize a floating point image containing vector values: + oiiotool xyzvectors.exr --normalize -o normalized.exr + + # Normalize an unsigned integer image where [-1,1] vector values + # are encoded on [0,1] for both input and output: + oiiotool xyzvectors.tif --normalize:incenter=0.5:outcenter=0.5:scale=0.5 -o normalized.tif + + .. option:: --noise Alter the top image to introduce noise, with the option `:type=` diff --git a/src/include/OpenImageIO/imagebufalgo.h b/src/include/OpenImageIO/imagebufalgo.h index 8805d74426..bbefc8187b 100644 --- a/src/include/OpenImageIO/imagebufalgo.h +++ b/src/include/OpenImageIO/imagebufalgo.h @@ -1047,6 +1047,10 @@ bool OIIO_API pow (ImageBuf &dst, const ImageBuf &A, cspan B, /// `outCenter=0.5` and `scale=0.5`, but if you want them to be in the range /// [-1,1], use `outCenter=0.0` and `scale=1.0` (this probably will only work /// if you intend to write the results in `float` or `half` format). +/// +/// Expressed another way, the computation is conceptually: +/// +/// out = outCenter + scale * (in - inCenter) / length(in - inCenter) /// bool OIIO_API normalize(ImageBuf& dst, const ImageBuf& A, float inCenter=0.0f, float outCenter=0.0f, float scale=1.0f, diff --git a/testsuite/common/vectorschart_raw.tif b/testsuite/common/vectorschart_raw.tif deleted file mode 100644 index 59713d04f6..0000000000 Binary files a/testsuite/common/vectorschart_raw.tif and /dev/null differ diff --git a/testsuite/common/vectorschart_raw_xyza.exr b/testsuite/common/vectorschart_raw_xyza.exr deleted file mode 100644 index 210d19bc16..0000000000 Binary files a/testsuite/common/vectorschart_raw_xyza.exr and /dev/null differ diff --git a/testsuite/oiiotool/ref/normalize.exr b/testsuite/oiiotool/ref/normalize.exr new file mode 100644 index 0000000000..b4e29d05cd Binary files /dev/null and b/testsuite/oiiotool/ref/normalize.exr differ diff --git a/testsuite/oiiotool/ref/normalize_in.exr b/testsuite/oiiotool/ref/normalize_in.exr new file mode 100644 index 0000000000..27f10471ee Binary files /dev/null and b/testsuite/oiiotool/ref/normalize_in.exr differ diff --git a/testsuite/oiiotool/ref/normalize_offsetin.exr b/testsuite/oiiotool/ref/normalize_offsetin.exr new file mode 100644 index 0000000000..1199caa4de Binary files /dev/null and b/testsuite/oiiotool/ref/normalize_offsetin.exr differ diff --git a/testsuite/oiiotool/ref/normalize_offsetscale.exr b/testsuite/oiiotool/ref/normalize_offsetscale.exr new file mode 100644 index 0000000000..c45e1293a3 Binary files /dev/null and b/testsuite/oiiotool/ref/normalize_offsetscale.exr differ diff --git a/testsuite/oiiotool/ref/normalize_offsetscaleout.exr b/testsuite/oiiotool/ref/normalize_offsetscaleout.exr new file mode 100644 index 0000000000..8fd02b57b1 Binary files /dev/null and b/testsuite/oiiotool/ref/normalize_offsetscaleout.exr differ diff --git a/testsuite/oiiotool/ref/normalize_scale.exr b/testsuite/oiiotool/ref/normalize_scale.exr new file mode 100644 index 0000000000..559b535fa6 Binary files /dev/null and b/testsuite/oiiotool/ref/normalize_scale.exr differ diff --git a/testsuite/oiiotool/ref/out.txt b/testsuite/oiiotool/ref/out.txt index 98b8a9ac4b..b47e96d18e 100644 --- a/testsuite/oiiotool/ref/out.txt +++ b/testsuite/oiiotool/ref/out.txt @@ -140,6 +140,16 @@ Comparing "cpow1.exr" and "ref/cpow1.exr" PASS Comparing "cpow2.exr" and "ref/cpow2.exr" PASS +Comparing "normalize.exr" and "ref/normalize.exr" +PASS +Comparing "normalize_scale.exr" and "ref/normalize_scale.exr" +PASS +Comparing "normalize_offsetin.exr" and "ref/normalize_offsetin.exr" +PASS +Comparing "normalize_offsetscaleout.exr" and "ref/normalize_offsetscaleout.exr" +PASS +Comparing "normalize_offsetscale.exr" and "ref/normalize_offsetscale.exr" +PASS Comparing "abs.exr" and "ref/abs.exr" PASS Comparing "absdiff.exr" and "ref/absdiff.exr" diff --git a/testsuite/oiiotool/run.py b/testsuite/oiiotool/run.py index 87c9a54ab9..a55b918f0f 100755 --- a/testsuite/oiiotool/run.py +++ b/testsuite/oiiotool/run.py @@ -69,6 +69,14 @@ # Test --powc val,val,val... (per-channel powers) command += oiiotool ("grey128.exr --powc 2,2,1 -o cpow2.exr") +# Test --normalize +command += oiiotool ("src/norm.exr --normalize -o normalize.exr " + + "src/norm.exr --normalize:scale=0.5 -o normalize_scale.exr " + + "src/normoffset.exr --normalize:incenter=0.5 -o normalize_offsetin.exr " + + "src/norm.exr --normalize:outcenter=0.5:scale=0.5 -o normalize_offsetscaleout.exr " + + "src/normoffset.exr --normalize:incenter=0.5:outcenter=0.5:scale=0.5 -o normalize_offsetscale.exr ") + + # Test --abs, --absdiff, --absdiffc # First, make a test image that's 0.5 on the left, -0.5 on the right command += oiiotool ("-pattern constant:color=-0.25,-0.25,-0.25 64x128 3 " @@ -263,6 +271,8 @@ "div.exr", "divc1.exr", "divc2.exr", "mad.exr", "invert.tif", "cpow1.exr", "cpow2.exr", + "normalize.exr", "normalize_scale.exr", "normalize_offsetin.exr", + "normalize_offsetscaleout.exr", "normalize_offsetscale.exr", "abs.exr", "absdiff.exr", "absdiffc.exr", "chsum.tif", "rgbahalf-zfloat.exr", diff --git a/testsuite/oiiotool/src/norm.exr b/testsuite/oiiotool/src/norm.exr new file mode 100644 index 0000000000..ad6add677e Binary files /dev/null and b/testsuite/oiiotool/src/norm.exr differ diff --git a/testsuite/oiiotool/src/normoffset.exr b/testsuite/oiiotool/src/normoffset.exr new file mode 100644 index 0000000000..dc62c97ab2 Binary files /dev/null and b/testsuite/oiiotool/src/normoffset.exr differ diff --git a/testsuite/python-imagebufalgo/ref/norm.exr b/testsuite/python-imagebufalgo/ref/norm.exr new file mode 100644 index 0000000000..ad6add677e Binary files /dev/null and b/testsuite/python-imagebufalgo/ref/norm.exr differ diff --git a/testsuite/python-imagebufalgo/ref/normalize.exr b/testsuite/python-imagebufalgo/ref/normalize.exr new file mode 100644 index 0000000000..b4e29d05cd Binary files /dev/null and b/testsuite/python-imagebufalgo/ref/normalize.exr differ diff --git a/testsuite/python-imagebufalgo/ref/normalize_flfl.exr b/testsuite/python-imagebufalgo/ref/normalize_flfl.exr deleted file mode 100644 index b39bb81ab9..0000000000 Binary files a/testsuite/python-imagebufalgo/ref/normalize_flfl.exr and /dev/null differ diff --git a/testsuite/python-imagebufalgo/ref/normalize_flui.tif b/testsuite/python-imagebufalgo/ref/normalize_flui.tif deleted file mode 100644 index c646fb5b22..0000000000 Binary files a/testsuite/python-imagebufalgo/ref/normalize_flui.tif and /dev/null differ diff --git a/testsuite/python-imagebufalgo/ref/normalize_flui_na.tif b/testsuite/python-imagebufalgo/ref/normalize_flui_na.tif deleted file mode 100644 index c646fb5b22..0000000000 Binary files a/testsuite/python-imagebufalgo/ref/normalize_flui_na.tif and /dev/null differ diff --git a/testsuite/python-imagebufalgo/ref/normalize_in.exr b/testsuite/python-imagebufalgo/ref/normalize_in.exr new file mode 100644 index 0000000000..27f10471ee Binary files /dev/null and b/testsuite/python-imagebufalgo/ref/normalize_in.exr differ diff --git a/testsuite/python-imagebufalgo/ref/normalize_offsetin.exr b/testsuite/python-imagebufalgo/ref/normalize_offsetin.exr new file mode 100644 index 0000000000..1199caa4de Binary files /dev/null and b/testsuite/python-imagebufalgo/ref/normalize_offsetin.exr differ diff --git a/testsuite/python-imagebufalgo/ref/normalize_offsetscale.exr b/testsuite/python-imagebufalgo/ref/normalize_offsetscale.exr new file mode 100644 index 0000000000..c45e1293a3 Binary files /dev/null and b/testsuite/python-imagebufalgo/ref/normalize_offsetscale.exr differ diff --git a/testsuite/python-imagebufalgo/ref/normalize_offsetscaleout.exr b/testsuite/python-imagebufalgo/ref/normalize_offsetscaleout.exr new file mode 100644 index 0000000000..8fd02b57b1 Binary files /dev/null and b/testsuite/python-imagebufalgo/ref/normalize_offsetscaleout.exr differ diff --git a/testsuite/python-imagebufalgo/ref/normalize_scale.exr b/testsuite/python-imagebufalgo/ref/normalize_scale.exr new file mode 100644 index 0000000000..559b535fa6 Binary files /dev/null and b/testsuite/python-imagebufalgo/ref/normalize_scale.exr differ diff --git a/testsuite/python-imagebufalgo/ref/normalize_uifl.exr b/testsuite/python-imagebufalgo/ref/normalize_uifl.exr deleted file mode 100644 index 113c7ad2eb..0000000000 Binary files a/testsuite/python-imagebufalgo/ref/normalize_uifl.exr and /dev/null differ diff --git a/testsuite/python-imagebufalgo/ref/normalize_uiui.tif b/testsuite/python-imagebufalgo/ref/normalize_uiui.tif deleted file mode 100644 index 5b10e3fa89..0000000000 Binary files a/testsuite/python-imagebufalgo/ref/normalize_uiui.tif and /dev/null differ diff --git a/testsuite/python-imagebufalgo/ref/normoffset.exr b/testsuite/python-imagebufalgo/ref/normoffset.exr new file mode 100644 index 0000000000..dc62c97ab2 Binary files /dev/null and b/testsuite/python-imagebufalgo/ref/normoffset.exr differ diff --git a/testsuite/python-imagebufalgo/ref/out-freetype2.4.11-py2.7-pybind2.3.txt b/testsuite/python-imagebufalgo/ref/out-freetype2.4.11-py2.7-pybind2.3.txt index 5629f32cda..c478d681fd 100644 --- a/testsuite/python-imagebufalgo/ref/out-freetype2.4.11-py2.7-pybind2.3.txt +++ b/testsuite/python-imagebufalgo/ref/out-freetype2.4.11-py2.7-pybind2.3.txt @@ -138,9 +138,9 @@ Comparing "minimg.tif" and "ref/minimg.tif" PASS Comparing "minval.tif" and "ref/minval.tif" PASS -Comparing "minchan.tif" and "../../../testsuite/oiiotool/ref/minchan.tif" +Comparing "minchan.tif" and "ref/minchan.tif" PASS -Comparing "maxchan.tif" and "../../../testsuite/oiiotool/ref/maxchan.tif" +Comparing "maxchan.tif" and "ref/maxchan.tif" PASS Comparing "chsum.tif" and "../../../testsuite/oiiotool/ref/chsum.tif" PASS @@ -172,15 +172,19 @@ Comparing "resample.tif" and "../../../testsuite/oiiotool-xform/ref/resample.tif PASS Comparing "fit.tif" and "../../../testsuite/oiiotool-xform/ref/fit.tif" PASS -Comparing "normalize_uiui.tif" and "ref/normalize_uiui.tif" +Comparing "norm.exr" and "ref/norm.exr" PASS -Comparing "normalize_uifl.exr" and "ref/normalize_uifl.exr" +Comparing "normoffset.exr" and "ref/normoffset.exr" PASS -Comparing "normalize_flfl.exr" and "ref/normalize_flfl.exr" +Comparing "normalize.exr" and "ref/normalize.exr" PASS -Comparing "normalize_flui.tif" and "ref/normalize_flui.tif" +Comparing "normalize_scale.exr" and "ref/normalize_scale.exr" PASS -Comparing "normalize_flui_na.tif" and "ref/normalize_flui_na.tif" +Comparing "normalize_offsetin.exr" and "ref/normalize_offsetin.exr" +PASS +Comparing "normalize_offsetscaleout.exr" and "ref/normalize_offsetscaleout.exr" +PASS +Comparing "normalize_offsetscale.exr" and "ref/normalize_offsetscale.exr" PASS Comparing "bsplinekernel.exr" and "../../../testsuite/oiiotool/ref/bsplinekernel.exr" PASS diff --git a/testsuite/python-imagebufalgo/ref/out-freetype2.4.11.txt b/testsuite/python-imagebufalgo/ref/out-freetype2.4.11.txt index 13e9d9f792..03448ada4d 100644 --- a/testsuite/python-imagebufalgo/ref/out-freetype2.4.11.txt +++ b/testsuite/python-imagebufalgo/ref/out-freetype2.4.11.txt @@ -138,9 +138,9 @@ Comparing "minimg.tif" and "ref/minimg.tif" PASS Comparing "minval.tif" and "ref/minval.tif" PASS -Comparing "minchan.tif" and "../../../testsuite/oiiotool/ref/minchan.tif" +Comparing "minchan.tif" and "ref/minchan.tif" PASS -Comparing "maxchan.tif" and "../../../testsuite/oiiotool/ref/maxchan.tif" +Comparing "maxchan.tif" and "ref/maxchan.tif" PASS Comparing "chsum.tif" and "../../../testsuite/oiiotool/ref/chsum.tif" PASS @@ -172,15 +172,19 @@ Comparing "resample.tif" and "../../../testsuite/oiiotool-xform/ref/resample.tif PASS Comparing "fit.tif" and "../../../testsuite/oiiotool-xform/ref/fit.tif" PASS -Comparing "normalize_uiui.tif" and "ref/normalize_uiui.tif" +Comparing "norm.exr" and "ref/norm.exr" PASS -Comparing "normalize_uifl.exr" and "ref/normalize_uifl.exr" +Comparing "normoffset.exr" and "ref/normoffset.exr" PASS -Comparing "normalize_flfl.exr" and "ref/normalize_flfl.exr" +Comparing "normalize.exr" and "ref/normalize.exr" PASS -Comparing "normalize_flui.tif" and "ref/normalize_flui.tif" +Comparing "normalize_scale.exr" and "ref/normalize_scale.exr" PASS -Comparing "normalize_flui_na.tif" and "ref/normalize_flui_na.tif" +Comparing "normalize_offsetin.exr" and "ref/normalize_offsetin.exr" +PASS +Comparing "normalize_offsetscaleout.exr" and "ref/normalize_offsetscaleout.exr" +PASS +Comparing "normalize_offsetscale.exr" and "ref/normalize_offsetscale.exr" PASS Comparing "bsplinekernel.exr" and "../../../testsuite/oiiotool/ref/bsplinekernel.exr" PASS diff --git a/testsuite/python-imagebufalgo/ref/out-python2-alt.txt b/testsuite/python-imagebufalgo/ref/out-python2-alt.txt index 2e20341393..294a19bb5a 100644 --- a/testsuite/python-imagebufalgo/ref/out-python2-alt.txt +++ b/testsuite/python-imagebufalgo/ref/out-python2-alt.txt @@ -138,9 +138,9 @@ Comparing "minimg.tif" and "ref/minimg.tif" PASS Comparing "minval.tif" and "ref/minval.tif" PASS -Comparing "minchan.tif" and "../../../testsuite/oiiotool/ref/minchan.tif" +Comparing "minchan.tif" and "ref/minchan.tif" PASS -Comparing "maxchan.tif" and "../../../testsuite/oiiotool/ref/maxchan.tif" +Comparing "maxchan.tif" and "ref/maxchan.tif" PASS Comparing "chsum.tif" and "../../../testsuite/oiiotool/ref/chsum.tif" PASS @@ -172,15 +172,19 @@ Comparing "resample.tif" and "../../../testsuite/oiiotool-xform/ref/resample.tif PASS Comparing "fit.tif" and "../../../testsuite/oiiotool-xform/ref/fit.tif" PASS -Comparing "normalize_uiui.tif" and "ref/normalize_uiui.tif" +Comparing "norm.exr" and "ref/norm.exr" PASS -Comparing "normalize_uifl.exr" and "ref/normalize_uifl.exr" +Comparing "normoffset.exr" and "ref/normoffset.exr" PASS -Comparing "normalize_flfl.exr" and "ref/normalize_flfl.exr" +Comparing "normalize.exr" and "ref/normalize.exr" PASS -Comparing "normalize_flui.tif" and "ref/normalize_flui.tif" +Comparing "normalize_scale.exr" and "ref/normalize_scale.exr" PASS -Comparing "normalize_flui_na.tif" and "ref/normalize_flui_na.tif" +Comparing "normalize_offsetin.exr" and "ref/normalize_offsetin.exr" +PASS +Comparing "normalize_offsetscaleout.exr" and "ref/normalize_offsetscaleout.exr" +PASS +Comparing "normalize_offsetscale.exr" and "ref/normalize_offsetscale.exr" PASS Comparing "bsplinekernel.exr" and "../../../testsuite/oiiotool/ref/bsplinekernel.exr" PASS diff --git a/testsuite/python-imagebufalgo/ref/out-python3-freetype2.4.11.txt b/testsuite/python-imagebufalgo/ref/out-python3-freetype2.4.11.txt index d857d072ec..a9bc042c87 100644 --- a/testsuite/python-imagebufalgo/ref/out-python3-freetype2.4.11.txt +++ b/testsuite/python-imagebufalgo/ref/out-python3-freetype2.4.11.txt @@ -138,9 +138,9 @@ Comparing "minimg.tif" and "ref/minimg.tif" PASS Comparing "minval.tif" and "ref/minval.tif" PASS -Comparing "minchan.tif" and "../../../testsuite/oiiotool/ref/minchan.tif" +Comparing "minchan.tif" and "ref/minchan.tif" PASS -Comparing "maxchan.tif" and "../../../testsuite/oiiotool/ref/maxchan.tif" +Comparing "maxchan.tif" and "ref/maxchan.tif" PASS Comparing "chsum.tif" and "../../../testsuite/oiiotool/ref/chsum.tif" PASS @@ -172,15 +172,19 @@ Comparing "resample.tif" and "../../../testsuite/oiiotool-xform/ref/resample.tif PASS Comparing "fit.tif" and "../../../testsuite/oiiotool-xform/ref/fit.tif" PASS -Comparing "normalize_uiui.tif" and "ref/normalize_uiui.tif" +Comparing "norm.exr" and "ref/norm.exr" PASS -Comparing "normalize_uifl.exr" and "ref/normalize_uifl.exr" +Comparing "normoffset.exr" and "ref/normoffset.exr" PASS -Comparing "normalize_flfl.exr" and "ref/normalize_flfl.exr" +Comparing "normalize.exr" and "ref/normalize.exr" PASS -Comparing "normalize_flui.tif" and "ref/normalize_flui.tif" +Comparing "normalize_scale.exr" and "ref/normalize_scale.exr" PASS -Comparing "normalize_flui_na.tif" and "ref/normalize_flui_na.tif" +Comparing "normalize_offsetin.exr" and "ref/normalize_offsetin.exr" +PASS +Comparing "normalize_offsetscaleout.exr" and "ref/normalize_offsetscaleout.exr" +PASS +Comparing "normalize_offsetscale.exr" and "ref/normalize_offsetscale.exr" PASS Comparing "bsplinekernel.exr" and "../../../testsuite/oiiotool/ref/bsplinekernel.exr" PASS diff --git a/testsuite/python-imagebufalgo/ref/out-python3.txt b/testsuite/python-imagebufalgo/ref/out-python3.txt index 4c96630ed9..8088a0e276 100644 --- a/testsuite/python-imagebufalgo/ref/out-python3.txt +++ b/testsuite/python-imagebufalgo/ref/out-python3.txt @@ -138,9 +138,9 @@ Comparing "minimg.tif" and "ref/minimg.tif" PASS Comparing "minval.tif" and "ref/minval.tif" PASS -Comparing "minchan.tif" and "../../../testsuite/oiiotool/ref/minchan.tif" +Comparing "minchan.tif" and "ref/minchan.tif" PASS -Comparing "maxchan.tif" and "../../../testsuite/oiiotool/ref/maxchan.tif" +Comparing "maxchan.tif" and "ref/maxchan.tif" PASS Comparing "chsum.tif" and "../../../testsuite/oiiotool/ref/chsum.tif" PASS @@ -172,15 +172,19 @@ Comparing "resample.tif" and "../../../testsuite/oiiotool-xform/ref/resample.tif PASS Comparing "fit.tif" and "../../../testsuite/oiiotool-xform/ref/fit.tif" PASS -Comparing "normalize_uiui.tif" and "ref/normalize_uiui.tif" +Comparing "norm.exr" and "ref/norm.exr" PASS -Comparing "normalize_uifl.exr" and "ref/normalize_uifl.exr" +Comparing "normoffset.exr" and "ref/normoffset.exr" PASS -Comparing "normalize_flfl.exr" and "ref/normalize_flfl.exr" +Comparing "normalize.exr" and "ref/normalize.exr" PASS -Comparing "normalize_flui.tif" and "ref/normalize_flui.tif" +Comparing "normalize_scale.exr" and "ref/normalize_scale.exr" PASS -Comparing "normalize_flui_na.tif" and "ref/normalize_flui_na.tif" +Comparing "normalize_offsetin.exr" and "ref/normalize_offsetin.exr" +PASS +Comparing "normalize_offsetscaleout.exr" and "ref/normalize_offsetscaleout.exr" +PASS +Comparing "normalize_offsetscale.exr" and "ref/normalize_offsetscale.exr" PASS Comparing "bsplinekernel.exr" and "../../../testsuite/oiiotool/ref/bsplinekernel.exr" PASS diff --git a/testsuite/python-imagebufalgo/ref/out.txt b/testsuite/python-imagebufalgo/ref/out.txt index e945cc9c32..3611460d2b 100644 --- a/testsuite/python-imagebufalgo/ref/out.txt +++ b/testsuite/python-imagebufalgo/ref/out.txt @@ -138,9 +138,9 @@ Comparing "minimg.tif" and "ref/minimg.tif" PASS Comparing "minval.tif" and "ref/minval.tif" PASS -Comparing "minchan.tif" and "../../../testsuite/oiiotool/ref/minchan.tif" +Comparing "minchan.tif" and "ref/minchan.tif" PASS -Comparing "maxchan.tif" and "../../../testsuite/oiiotool/ref/maxchan.tif" +Comparing "maxchan.tif" and "ref/maxchan.tif" PASS Comparing "chsum.tif" and "../../../testsuite/oiiotool/ref/chsum.tif" PASS @@ -172,15 +172,19 @@ Comparing "resample.tif" and "../../../testsuite/oiiotool-xform/ref/resample.tif PASS Comparing "fit.tif" and "../../../testsuite/oiiotool-xform/ref/fit.tif" PASS -Comparing "normalize_uiui.tif" and "ref/normalize_uiui.tif" +Comparing "norm.exr" and "ref/norm.exr" PASS -Comparing "normalize_uifl.exr" and "ref/normalize_uifl.exr" +Comparing "normoffset.exr" and "ref/normoffset.exr" PASS -Comparing "normalize_flfl.exr" and "ref/normalize_flfl.exr" +Comparing "normalize.exr" and "ref/normalize.exr" PASS -Comparing "normalize_flui.tif" and "ref/normalize_flui.tif" +Comparing "normalize_scale.exr" and "ref/normalize_scale.exr" PASS -Comparing "normalize_flui_na.tif" and "ref/normalize_flui_na.tif" +Comparing "normalize_offsetin.exr" and "ref/normalize_offsetin.exr" +PASS +Comparing "normalize_offsetscaleout.exr" and "ref/normalize_offsetscaleout.exr" +PASS +Comparing "normalize_offsetscale.exr" and "ref/normalize_offsetscale.exr" PASS Comparing "bsplinekernel.exr" and "../../../testsuite/oiiotool/ref/bsplinekernel.exr" PASS diff --git a/testsuite/python-imagebufalgo/run.py b/testsuite/python-imagebufalgo/run.py index 56a0fa292b..3b41070126 100755 --- a/testsuite/python-imagebufalgo/run.py +++ b/testsuite/python-imagebufalgo/run.py @@ -5,6 +5,7 @@ # https://github.com/OpenImageIO/oiio refdirlist = [ + refdir, OIIO_TESTSUITE_ROOT + "/oiiotool/ref/", OIIO_TESTSUITE_ROOT + "/oiiotool-color/ref/", OIIO_TESTSUITE_ROOT + "/oiiotool-copy/ref/", @@ -14,7 +15,6 @@ OIIO_TESTSUITE_ROOT + "/oiiotool-pattern/ref/", OIIO_TESTSUITE_ROOT + "/oiiotool-text/ref/", OIIO_TESTSUITE_ROOT + "/oiiotool-xform/ref/", - refdir ] # Run the script @@ -50,9 +50,9 @@ "contrast-sigmoid5.tif", "saturate-0.tif", "saturate-2.tif", "resize.tif", "resample.tif", "fit.tif", - "normalize_uiui.tif", "normalize_uifl.exr", - "normalize_flfl.exr", "normalize_flui.tif", - "normalize_flui_na.tif", + "norm.exr", "normoffset.exr", "normalize.exr", "normalize_scale.exr", + "normalize_offsetin.exr", "normalize_offsetscaleout.exr", + "normalize_offsetscale.exr", "bsplinekernel.exr", "bspline-blur.tif", "tahoe-median.tif", "dilate.tif", "erode.tif", "unsharp.tif", "unsharp-median.tif", "tahoe-laplacian.tif", diff --git a/testsuite/python-imagebufalgo/src/test_imagebufalgo.py b/testsuite/python-imagebufalgo/src/test_imagebufalgo.py index 5acb070458..b0e2713ce6 100755 --- a/testsuite/python-imagebufalgo/src/test_imagebufalgo.py +++ b/testsuite/python-imagebufalgo/src/test_imagebufalgo.py @@ -265,21 +265,32 @@ def test_iba (func, *args, **kwargs) : write (b, "invert.tif", oiio.UINT8) # normalize - a = ImageBuf (OIIO_TESTSUITE_ROOT+"/common/vectorschart_raw.tif") - b = test_iba (ImageBufAlgo.normalize, a, 0.5, 0.5, 0.5) - write (b, "normalize_uiui.tif", oiio.UINT16) - b = test_iba (ImageBufAlgo.normalize, a, 0.5, 0.0, 1.0) - write (b, "normalize_uifl.exr", oiio.HALF) - - a = ImageBuf (OIIO_TESTSUITE_ROOT+"/common/vectorschart_raw_xyza.exr") - b = test_iba (ImageBufAlgo.normalize, a, 0.0, 0.0, 1.0) - write (b, "normalize_flfl.exr", oiio.HALF) - b = test_iba (ImageBufAlgo.normalize, a, 0.0, 0.5, 0.5) - write (b, "normalize_flui.tif", oiio.UINT16) - b = ImageBuf() - b.specmod().nchannels = 3 - b = test_iba (ImageBufAlgo.normalize, a, 0.0, 0.5, 0.5) - write (b, "normalize_flui_na.tif", oiio.UINT16) + # Construct an image with several values to test normalization + norm = ImageBuf(ImageSpec(3, 3, 3, "half")) + ImageBufAlgo.render_point(norm, 0, 0, (0.0, 0.0, 0.0)) # zero + ImageBufAlgo.render_point(norm, 1, 0, (0.6, 0.0, 0.0)) # x + ImageBufAlgo.render_point(norm, 2, 0, (-0.6, 0.0, 0.0)) # -x + ImageBufAlgo.render_point(norm, 0, 1, (0.0, 0.6, 0.0)) # y + ImageBufAlgo.render_point(norm, 1, 1, (0.0, -0.6, 0.0)) # -y + ImageBufAlgo.render_point(norm, 2, 1, (0.0, 0.0, 0.6)) # z + ImageBufAlgo.render_point(norm, 0, 2, (0.0, 0.0, -0.6)) # -z + ImageBufAlgo.render_point(norm, 1, 2, (0.6, 0.6, -0.6)) # diag3 + ImageBufAlgo.render_point(norm, 2, 2, (0.0, -0.6, -0.6)) # diag2 + write (norm, "norm.exr", "half") + # and another copy that is offset to .5 center and scaled by 0.5 + normoffset = ImageBufAlgo.add(ImageBufAlgo.mul(norm, 0.5), 0.5) + write (normoffset, "normoffset.exr", "half") + # Test various options + b = test_iba (ImageBufAlgo.normalize, norm) + write (b, "normalize.exr", "half") + b = test_iba (ImageBufAlgo.normalize, norm, scale=0.5) + write (b, "normalize_scale.exr", "half") + b = test_iba (ImageBufAlgo.normalize, normoffset, inCenter=0.5) + write (b, "normalize_offsetin.exr", "half") + b = test_iba (ImageBufAlgo.normalize, norm, outCenter=0.5, scale=0.5) + write (b, "normalize_offsetscaleout.exr", "half") + b = test_iba (ImageBufAlgo.normalize, normoffset, inCenter=0.5, outCenter=0.5, scale=0.5) + write (b, "normalize_offsetscale.exr", "half") # pow b = ImageBufAlgo.pow (gray128, 2)