-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Fixing imread() function 16 bit reading png problem with libspng #27113
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
base: 4.x
Are you sure you want to change the base?
Conversation
640563f
to
bc40042
Compare
@asmorkalov the PR is still WIP. no need to start CI yet. |
This reverts commit 4e15215.
The purpose of the PR was to load bit-exact compatible results with libspng and libpng. To test this, |
I added the motivation to the PR description to save it in Git history after merge. |
#ifdef HAVE_PNG | ||
EXPECT_EQ(19519, img.at<ushort>(0, 0)); | ||
#endif | ||
#ifdef HAVE_SPNG | ||
EXPECT_EQ(19517, img.at<ushort>(0, 0)); | ||
#endif |
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.
Sounds like wrong rounding somewhere in libspng.
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.
last commit is temporarily to show that the spng conversion code is the same as libpng. i temporarily used if (m_frame_count > 5)
that means the difference caused by cvtColor which i used in apng decoding.
[ RUN ] Imgcodecs_APNG.imread_animation_16u
/build/precommit_linux64/4.x/opencv/modules/imgcodecs/test/test_animation.cpp:680: Failure
Expected equality of these values:
19519
img.at<ushort>(0, 0)
Which is: 19517
[ FAILED ] Imgcodecs_APNG.imread_animation_16u (2 ms)
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.
If you find it appropriate, I can add a to-do note and let's merge this. I'll work on apng and try to find a solution for this difference later.
This reverts commit 1d6b6f8.
To show that the spng conversion code is the same as libpng
The last commit looks suspicious. |
now the value is |
in conclusion, I think this PR is correct. I suggest leaving a to-do note about libpng and postponing the solution. |
This reverts commit 58aac2d.
|
||
// Uncomment this block to write out the decoded images for visual/manual inspection | ||
// or for regenerating expected ground truth PNGs (for example, after changing decoder logic). | ||
#if 0 |
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.
I forgot to mention that i used this commented blocks to be sure libspng and libpng loads exact same data. first i set 1 the upper block with OpenCV compiled with libpng. and for each pngsuite file saved what loaded with each flag. then set 0 the upper block and set 1 the lower block with OpenCV compiled with libspng...
The purpose of the PR was to load bit-exact compatible results with libspng and libpng. To test this,
Imgcodecs_Png_PngSuite
was improved. Files containing gamma correction were moved to a separate test calledImgcodecs_Png_PngSuite_Gamma
because the logic created for the other files did not apply to those with gamma correction. As a result, libspng now works in bit-exact compatibility with libpng. The code can be refactored later.Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.