Bit-exact Nearest Neighbor Resizing#18053
Conversation
|
@Yosshi999 Could you please check the |
|
I thought x2 or x0.5 resizing is bit-exact even if the method is non-exact version because multiplication by 0.5 or 2 will not modify fraction fields of floating point data. But it seems I have a misunderstanding. |
modules/imgproc/src/resize.cpp
Outdated
| std::cout << "ifx: " << std::hex << ifx.raw() << std::endl; | ||
| for( int x = 0; x < dsize.width; x++ ) | ||
| { | ||
| int sx = int32_t( ((ifx * static_cast<uint32_t>(x)) >> 32) << 32 ); // equivalent to cvFloor |
There was a problem hiding this comment.
It seems (x >> 32) << 32 is optimized to x in the windows build.
abad80b to
cb99256
Compare
modules/imgproc/perf/perf_resize.cpp
Outdated
| testing::Combine( | ||
| testing::Values(CV_8UC1, CV_8UC2, CV_8UC4), | ||
| testing::Values(szVGA, szqHD, sz720p, sz1080p, sz2160p), | ||
| testing::Values(2.4, 3.4, 1.3) |
There was a problem hiding this comment.
Need to fix scope of perf tests.
NN resize is usually used for downscaling (instead of upscaling), include 0.5: 0.25, 0.5, 2 should be enough.
Please also reduce tested sizes (there are no significant changes in implementation) - sz720p, sz1080p is enough.
Add 8UC3 type as frequently used case. Remove 8UC2.
|
@Yosshi999, thank you for the contribution! |
This is completely different algorithm. Bit-exact implementation should follow this rule and must provide minimal possible difference between:
Without changing of the base NN implementation this should not be called bit-exact. |
|
According to the discussion in #17068, it seems that there are some options:
In these cases above, I will remove the suffix Or:
I will vote for the second one. |
|
I prefer the first option. From my point of view |
terfendail
left a comment
There was a problem hiding this comment.
Implementation looks fine for me. The only thing to discuss is the name of the method enum. However it is outside of this PR intention scope.
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.