You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To avoid code duplication, and keep performance when no mask is used, inner implementation always propagate the const cv::Mat& mask, but they use a template parameter that let the compiler optimize out unecessary tests when the mask is not to be used.
To avoid code duplication, and keep performance when no mask is used, inner implementation always propagate the const cv::Mat& mask, but they use a template<bool useMask> parameter that let the compiler optimize out unecessary tests when the mask not to be used.
When therere were non-vectorized pixels remaining, the mask pointer was not properly reset
that was a memory fault (not always triggered), and the test case only hit the case when that last pixel was greater than the threshold
new strategy to load masks and duplicate bytes to match src.elemSize()
instead of complex byte duplication in loaded mask vector elements, use vx_lut() instead with sliding indices
ocl should have failed before for the case cn>1
somehow, the ocl currently does not fail as expected even when trying to corrupt the output by setting stupid values to dst in the kernel
The test is not reliable, and I don't know why
We need "clear" definition what values should be used as result outside of the mask.
Al least, this is why cv::compare() doesn't have mask support.
Yes, that's what I thought when I started working on the feature.
My most useful usecase is to leave outliers untouched. This assumes that the dst image was pre-existing, otherwise they will be undefined pixel values after being allocated by cv::threshold()
I use such a feature to apply different binarizations to different (non rectangular) parts of an image according to some criteria.
@chacha21 Could you list use-cases for the PR?
The proposal was discussed on weekly core team meeting and the team has doubt if we need the change. Alexander's concern is on of reasons.
@chacha21 Could you list use-cases for the PR? The proposal was discussed on weekly core team meeting and the team has doubt if we need the change. Alexander's concern is on of reasons.
Ok. First of all, no problem to decline the PR, I won't try to force push it.
Here are my two use cases :
case 1
A gray-level image with different areas (not rectangular) having different lighting conditions
not a single threshold will binarize the whole image, there must be one threshold (from OTSU) per area
currently, I have to use multiple masks and combinations to build to final image, and computing the OTSU threshold for a non rectangular area is a problem because of outliers pixels
case 2
a gray-level image is displayed to the user
the user can draw non-rectangular ROIs (e.g. RotatedRect areas) and want to binarize inside those areas in order to preview how binarization will highlight information of interest
Hello @chacha21 Sorry for delay. We discussed to the PR on the Core team meeting and we are ready to merge the PR with several fixes:
The new function dst should be defined as InputoutputArray and the function should check that the output buffer is pre-allocated and has enough size. Document the behaviour.
The dst value with mask==0 should not be modified as you in your proposal. The behaviour is documented.
HAL is not needed here. The case is too exotic.
We recommend to use another name like thresholdWithMask to reduce chance of API collision in Python and Java.
Add python test for the new function to ensure it's wrapped correctly.
The fixes are proposed to get rid of undefined behaviour for the case where mask==0 and wrap things to Python, Java, etc correctly.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposal for #26777
To avoid code duplication, and keep performance when no mask is used, inner implementation always propagate the const cv::Mat& mask, but they use a template parameter that let the compiler optimize out unecessary tests when the mask is not to be used.
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.