mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #26836 from chacha21:thresholding_compute_threshold_only
Add cv::THRESH_DRYRUN flag to get adaptive threshold values without thresholding #26836 A first proposal for #26777 Adds a `cv::THRESH_DRYRUN` flag to let cv::threshold() compute the threshold (useful for OTSU/TRIANGLE), but without actually running the thresholding. This flags is a proposal instead of a new function cv::computeThreshold() - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [X] There is a reference to the original bug report and related work - [X] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -502,6 +502,25 @@ BIGDATA_TEST(Imgproc_Threshold, huge)
|
||||
ASSERT_EQ((uint64)nz, n / 2);
|
||||
}
|
||||
|
||||
TEST(Imgproc_Threshold, threshold_dryrun)
|
||||
{
|
||||
Size sz(16, 16);
|
||||
Mat input_original(sz, CV_8U, Scalar::all(2));
|
||||
Mat input = input_original.clone();
|
||||
std::vector<int> threshTypes = {THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV};
|
||||
std::vector<int> threshFlags = {0, THRESH_OTSU, THRESH_TRIANGLE};
|
||||
for(int threshType : threshTypes)
|
||||
{
|
||||
for(int threshFlag : threshFlags)
|
||||
{
|
||||
const int _threshType = threshType | threshFlag | THRESH_DRYRUN;
|
||||
cv::threshold(input, input, 2.0, 0.0, _threshType);
|
||||
EXPECT_MAT_NEAR(input, input_original, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(Imgproc_Threshold, regression_THRESH_TOZERO_IPP_16085)
|
||||
{
|
||||
Size sz(16, 16);
|
||||
|
||||
Reference in New Issue
Block a user