当前位置: 首页>>代码示例>>C++>>正文


C++ OutputArray::createSameSize方法代码示例

本文整理汇总了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;

}
开发者ID:AmbroiseMoreau,项目名称:opencv_contrib,代码行数:47,代码来源:staticSaliency.cpp


注:本文中的OutputArray::createSameSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。