-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
DecodePixelData incorrectly y flips the image when loading "Decreasing Y" files #213
Comments
Thank you for the detailed report. Let me give some time to investigate the issue(and the spec of EXR lineOrder) |
I think that
because regardless of the order of the scanlines in the file, the scanline for For the case where If |
Firstly, Dumping line_no info at here: Line 5318 in 756f7d3 for Blobbies.exr gives the following result.
NOTE: ZIP compression(used on Blobbies.exr) uses 16 scanlines(num_lines) per block. So, i'th block(scanline) corresponds to i'th block(scanline) position(no change to the ordering of scanline) but offset(memory address) is descending order for decreasing Y. Also, scanline data itself in the memory seems not flipped when |
@MarkCallow Could you please prepare synthetic EXR image with decreasing Y, with compression none(num_lines = 1) and ZIP(num_lines=16) using OpenEXR lib? e.g. height 256 image, whose y'th scanline value has 'y'. |
What is
|
You should read the comment here: Line 5338 in 756f7d3
Blobbies.exr has negative value in
? testexrorder.zip has C++ code with OpenEXR lib. |
Thanks. I'll have to study the data window. I'm new to EXR.
I did not write that. It was written by @peterhillman and provided by him in AcademySoftwareFoundation/openexr#1946 (comment) to help explain decreasing scanline order to me. |
You should not post someone's code. There is no meaningful info about lineOrder attribute in the OpenEXR spec, so you need to check the source code of OpenEXR. After some code investigation, lineOrder handling when reading the image changed from openexr 2.0(TinyEXR is based on) and openexr 3.0. For example, there is no lineOrder consideration anymore in recent ImfScanLineInputFile.cpp Whereas lineOrder is considered in openexr 2.0 So flipping may be an expected behavior in openexr 2.0. You need to prepare reproducible code with openexr 2.0 and openexr 3.0, and check if how it behaves. |
Describe the issue
I think the title is a clear and concise description.
To Reproduce
Steps to reproduce the behavior:
decreasing.exr
, in testexrorder.zip attached below.LoadEXRImageFromMemory
to load the file.testexrorder.zip contains increasing and decreasing versions of the same simple 3 line image. See AcademySoftwareFoundation/openexr#1946 (comment) for a detailed description of the test case.
The same issue arises using the only decreasing Y file I found in the Academy's EXR test files: https://raw.githubusercontent.com/AcademySoftwareFoundation/openexr-images/main/ScanLines/Blobbies.jpg.
Expected behavior
I got this result:
I expected this
Ignore that it is red (the sole channel in the file is labelled "R" which my software follows) and the lighter area (this is from a 3D scene with illumination).
The images in "decreasing.exr" and "increasing.exr" are identical so the result should be identical.
** My Analysis **
The source
data_ptr
passed toDecodePixelData
is acquired fromoffsets[y_idx]
wherey_idx
essentially becomes theline_no
parameter also passed toDecodePixelData
. Sodata_ptr
is pointing at the correct source for, e.g. line 0 so it just needs to be copied to the first scanline in the output image.But in
DecodePixelData
we see lines liketinyexr/tinyexr.h
Lines 4100 to 4105 in 5fcb4dc
The above is taken from the uncompressed case as being the simplest example.
We can see that for decreasing line order it sets the output pointer to the last scanline of the output and proceeds to write scanline 0 there.
I can workaround this by setting
line_order = 0
in the header I pass toLoadEXRImageFromMemory
. But I am worried this might not work for, lets say, more complex cases. In both the examples I've referencedDecodePixelData
is called once for each scanline withnum_lines == 1
. I do not know enough about EXR or TinyEXR to judge what cases, if any, would be broken by simply removing theif (line_order == 0)
clauses and always performing the line_order == 0 case.num_lines > 1
looks iffy to me.Environment
The text was updated successfully, but these errors were encountered: