mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #25509 from savuor:rv/hal_otsu
HAL added for Otsu threshold #25509 fixes #25393 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [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. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
parent
ce642e994d
commit
bc95f27e56
@ -856,6 +856,25 @@ inline int hal_ni_threshold(const uchar* src_data, size_t src_step, uchar* dst_d
|
||||
#define cv_hal_threshold hal_ni_threshold
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
@brief Performs threshold filtering using threshold estimated by Otsu algorithm
|
||||
@param src_data Source image data
|
||||
@param src_step Source image step
|
||||
@param dst_data Destination image data
|
||||
@param dst_step Destination image step
|
||||
@param width Source image width
|
||||
@param height Source image height
|
||||
@param depth Depths of source and destination image
|
||||
@param maxValue Value assigned to the pixels for which the condition is satisfied
|
||||
@param thresholdType Thresholding type
|
||||
@param thresh Calculated threshold value
|
||||
*/
|
||||
inline int hal_ni_threshold_otsu(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int depth, double maxValue, int thresholdType, double* thresh) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
//! @cond IGNORED
|
||||
#define cv_hal_threshold_otsu hal_ni_threshold_otsu
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
@brief Calculate box filter
|
||||
@param src_data Source image data
|
||||
|
@ -1545,6 +1545,10 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
|
||||
ocl_threshold(_src, _dst, thresh, maxval, type), thresh)
|
||||
|
||||
Mat src = _src.getMat();
|
||||
|
||||
_dst.create( src.size(), src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
int automatic_thresh = (type & ~cv::THRESH_MASK);
|
||||
type &= THRESH_MASK;
|
||||
|
||||
@ -1553,6 +1557,10 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
|
||||
{
|
||||
int src_type = src.type();
|
||||
CV_CheckType(src_type, src_type == CV_8UC1 || src_type == CV_16UC1, "THRESH_OTSU mode");
|
||||
|
||||
CALL_HAL_RET(thresholdOtsu, cv_hal_threshold_otsu, thresh, src.data, src.step, dst.data, dst.step,
|
||||
src.cols, src.rows, src_type, maxval, type);
|
||||
|
||||
thresh = src.type() == CV_8UC1 ? getThreshVal_Otsu_8u( src )
|
||||
: getThreshVal_Otsu_16u( src );
|
||||
}
|
||||
@ -1562,9 +1570,6 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
|
||||
thresh = getThreshVal_Triangle_8u( src );
|
||||
}
|
||||
|
||||
_dst.create( src.size(), src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
if( src.depth() == CV_8U )
|
||||
{
|
||||
int ithresh = cvFloor(thresh);
|
||||
|
Loading…
Reference in New Issue
Block a user