Skip to content

threshold API : query threshold only, and masks #26777

@chacha21

Description

@chacha21

Describe the feature and motivation

Currently (OpenCV 4.11), cv::threshold() supports auto-threshold binarizations OTSU and TRIANGLE and returns the computed threshold value.
It's a pity that there is no API to only query that auto-threshold without actually performing the thresholding.

To avoid adding an API for that and do not duplicate any code, a very easy fix would be to add some flag cv::THRESH_DISABLE cv::THRESH_DRYRUN specifically for that purpose.

However, cv::threshold() also has a big limitation : it does not support masking. I would like to add such a cv::thresholdWithMask() (or a cv::threshold() overload with additional mask parameter). But if this new API is created, cv::THRESH_DISABLE cv::THRESH_DRYRUN could be irrelevant, replaced by a boolean parameter of the new function.

  • would a PR cv::thresholdWithMask() (or cv::threshold() overload) be accepted or is there a reason why thresholding does not support masking ?
  • which is better, cv::thresholdWithMask() or cv::threshold() overload ?
  • is the flag cv::THRESH_DISABLE cv::THRESH_DRYRUN a better idea than some cv::getThresholdAutoValue() ?
  • is the flag cv::THRESH_DISABLE cv::THRESH_DRYRUN a better idea than some specific boolean input parameter ?

[edit]
For future readers and contributors :
From reviewers :

We recommend to use another name like thresholdWithMask to reduce chance of API collision in Python and Java.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions