A new constant in adaptivethreshold is created to calculate
gaussianBlur with CV_32F. hence rouding error are avoided
This commit is contained in:
@@ -326,7 +326,9 @@ enum AdaptiveThresholdTypes {
|
|||||||
window) of the \f$\texttt{blockSize} \times \texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$
|
window) of the \f$\texttt{blockSize} \times \texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$
|
||||||
minus C . The default sigma (standard deviation) is used for the specified blockSize . See
|
minus C . The default sigma (standard deviation) is used for the specified blockSize . See
|
||||||
cv::getGaussianKernel*/
|
cv::getGaussianKernel*/
|
||||||
ADAPTIVE_THRESH_GAUSSIAN_C = 1
|
ADAPTIVE_THRESH_GAUSSIAN_C = 1,
|
||||||
|
/** Like ADAPTIVE_THRESH_GAUSSIAN_C except that GaussianBlur use CV_32F for blurring to avoid rounding error*/
|
||||||
|
ADAPTIVE_THRESH_GAUSSIAN_C_FLOAT = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
//! cv::undistort mode
|
//! cv::undistort mode
|
||||||
|
@@ -1295,11 +1295,19 @@ void cv::adaptiveThreshold( InputArray _src, OutputArray _dst, double maxValue,
|
|||||||
if( src.data != dst.data )
|
if( src.data != dst.data )
|
||||||
mean = dst;
|
mean = dst;
|
||||||
|
|
||||||
if( method == ADAPTIVE_THRESH_MEAN_C )
|
if (method == ADAPTIVE_THRESH_MEAN_C)
|
||||||
boxFilter( src, mean, src.type(), Size(blockSize, blockSize),
|
boxFilter( src, mean, src.type(), Size(blockSize, blockSize),
|
||||||
Point(-1,-1), true, BORDER_REPLICATE );
|
Point(-1,-1), true, BORDER_REPLICATE );
|
||||||
else if( method == ADAPTIVE_THRESH_GAUSSIAN_C )
|
else if (method == ADAPTIVE_THRESH_GAUSSIAN_C)
|
||||||
GaussianBlur( src, mean, Size(blockSize, blockSize), 0, 0, BORDER_REPLICATE );
|
GaussianBlur(src, mean, Size(blockSize, blockSize), 0, 0, BORDER_REPLICATE);
|
||||||
|
else if (method == ADAPTIVE_THRESH_GAUSSIAN_C_FLOAT)
|
||||||
|
{
|
||||||
|
Mat srcfloat,meanfloat;
|
||||||
|
src.convertTo(srcfloat,CV_32F);
|
||||||
|
meanfloat=srcfloat;
|
||||||
|
GaussianBlur(srcfloat, meanfloat, Size(blockSize, blockSize), 0, 0, BORDER_REPLICATE);
|
||||||
|
meanfloat.convertTo(dst, src.type());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
CV_Error( CV_StsBadFlag, "Unknown/unsupported adaptive threshold method" );
|
CV_Error( CV_StsBadFlag, "Unknown/unsupported adaptive threshold method" );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user