本文整理汇总了C++中OutputArray::createSameSize方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputArray::createSameSize方法的具体用法?C++ OutputArray::createSameSize怎么用?C++ OutputArray::createSameSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputArray
的用法示例。
在下文中一共展示了OutputArray::createSameSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeBinaryMap
bool StaticSaliency::computeBinaryMap( InputArray _saliencyMap, OutputArray _binaryMap )
{
Mat saliencyMap = _saliencyMap.getMat();
Mat labels = Mat::zeros( saliencyMap.rows * saliencyMap.cols, 1, 1 );
Mat samples = Mat_<float>( saliencyMap.rows * saliencyMap.cols, 1 );
Mat centers;
TermCriteria terminationCriteria;
terminationCriteria.epsilon = 0.2;
terminationCriteria.maxCount = 1000;
terminationCriteria.type = TermCriteria::COUNT + TermCriteria::EPS;
int elemCounter = 0;
for ( int i = 0; i < saliencyMap.rows; i++ )
{
for ( int j = 0; j < saliencyMap.cols; j++ )
{
samples.at<float>( elemCounter, 0 ) = saliencyMap.at<float>( i, j );
elemCounter++;
}
}
kmeans( samples, 5, labels, terminationCriteria, 5, KMEANS_RANDOM_CENTERS, centers );
Mat outputMat = Mat_<float>( saliencyMap.size() );
int intCounter = 0;
for ( int x = 0; x < saliencyMap.rows; x++ )
{
for ( int y = 0; y < saliencyMap.cols; y++ )
{
outputMat.at<float>( x, y ) = centers.at<float>( labels.at<int>( intCounter, 0 ), 0 );
intCounter++;
}
}
//Convert
outputMat = outputMat * 255;
outputMat.convertTo( outputMat, CV_8U );
// adaptative thresholding using Otsu's method, to make saliency map binary
_binaryMap.createSameSize(outputMat, outputMat.type());
Mat BinaryMap = _binaryMap.getMat();
threshold( outputMat, BinaryMap, 0, 255, THRESH_BINARY | THRESH_OTSU );
return true;
}