-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IBA::normalize() - Normalize 3D vectors (i.e., divide by their length) textures. #3945
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks great and is fine as-is. I made two minor suggestions for a more clear description comment and a very minor formatting fix. You should be able to merge those into what you have via the web interface here.
What I would like to request, though, is related to what is missing:
-
The Python bindings for normalize(). This should go in py_imagebufalgo.cpp, and there should be plenty of examples to copy from in that file, so this should be very straightforward and only be a few lines of code. I definitely want that as part of this PR, we should never add a C++ function without also adding the Python wrapper.
-
Tests. You could add a test in imagebufalgo_test.cpp, but if you add the python binding, you can just test python (in testsuite/python-imagebufalgo) and know that the python test will also exercise the C++ underneath.
-
Expose a
--normalize
command in oiiotool. This is more work, and somewhat trickier if you aren't familiar with oiiotool internals. I wouldn't blame you if you wanted to skip this part and leave it to me or somebody else, or for you to do it separately as follow-up PR. (It should also include a test, probably in testsuite/oiiotool.) But if you want to try it as part of this PR, it would be much appreciated!
Normalize 3D vectors (i.e., divide by their length) textures. inCenter and outCenter define 0.0 coordinate in input and output 3D vectors encodings (e.g. 0.0f for [-1,1] or 0.5f for [0,1] encoding). scale defines the scale factor to apply to the normalized vectors (i.e. 1.0f for a full range normalization, 0.5f for 0.0-1.0 range encoding). Default values are for [-1,1] encoding and full range normalization. Functions required 3 or 4 channels. If destination have no alpha channel, but source have, alpha channel will be dropped. Signed-off-by: ssh4net <[email protected]>
When building the code with Xcode ("cmake -G Xcode"), there are 1000+ warnings about implicit 64 to 32 bit conversion. This change adds a compile option to suppress such warnings when generating an Xcode project. Signed-off-by: Anton Dukhovnikov <[email protected]> Signed-off-by: ssh4net <[email protected]>
Adjusting the description. Co-authored-by: Larry Gritz <[email protected]> Signed-off-by: ssh4net <[email protected]>
Adjusting error message. Co-authored-by: Larry Gritz <[email protected]> Signed-off-by: ssh4net <[email protected]>
code formatting Co-authored-by: Larry Gritz <[email protected]> Signed-off-by: ssh4net <[email protected]>
python bindings Signed-off-by: ssh4net <[email protected]>
Added python tests Signed-off-by: Vlad Erium <[email protected]> Signed-off-by: ssh4net <[email protected]>
different normalize settings including alpha and no alpha channel float sources. Signed-off-by: Vlad Erium <[email protected]> Signed-off-by: ssh4net <[email protected]>
Actually, have zero understanding of how these python tests are working. Any examples? |
Signed-off-by: Larry Gritz <[email protected]>
Signed-off-by: Larry Gritz <[email protected]>
The run.py for each test is not executed directly, it is called by testsuite/runtest.py. I took the liberty of helping out by making a few minor fixes:
You can find this in the lgritz/normalize branch. |
Sorry, can't find lgritz/normalize 😳 |
I think this should work for you:
|
added --normalize to oiiotools. example: oiiotool.exe -v -i:ch=R,G,B OpenImageIO\testsuite\common\vectorschart_raw_xyza.exr --normalize:incntr=0.0:outcntr=0.0:scale=1.0 -d float -o normalize.exr Signed-off-by: ssh4net <[email protected]>
--normalize: cli syntax fix. Signed-off-by: ssh4net <[email protected]>
This looks good. The only think I can think of is that it should really have a test for the oiiotool part. But I'm also happy to tackle that (few lines) after the merge, if you just want to get what you've got in. |
@lgritz if you can add this test lines, that will be great. I feel uncomfortable with code that I can't run and test myself to be sure that I got idea correctly. |
Yeah, sounds good, @ssh4net. I will merge and then add the tests as a small follow-on PR. Next time you submit a PR, try to create a new branch for it rather than using your master. I think use of master is what prevented me from being able to push amendments directly to your branch to include it in this PR directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for all the hard work on this.
I'll add the oiiotool test separately as a small follow-on PR.
Description
Normalize 3D vectors (i.e., divide by their length) textures.
inCenter and outCenter define 0.0 coordinate in input and output
3D vectors encodings (e.g. 0.0f for [-1,1] or 0.5f for [0,1] encoding).
scale defines the scale factor to apply to the normalized vectors
(i.e. 1.0f for a full range normalization, 0.5f for 0.0-1.0 range encoding).
Default values are for [-1,1] encoding and full range normalization.
Functions required 3 or 4 channels. If destination have no alpha channel,
but source have, alpha channel will be dropped.
Tests
Checklist:
have previously submitted a Contributor License Agreement
(individual, and if there is any way my
employers might think my programming belongs to them, then also
corporate).
(adding new test cases if necessary).