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


C++ KSpace::uDim方法代码示例

本文整理汇总了C++中KSpace::uDim方法的典型用法代码示例。如果您正苦于以下问题:C++ KSpace::uDim方法的具体用法?C++ KSpace::uDim怎么用?C++ KSpace::uDim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KSpace的用法示例。


在下文中一共展示了KSpace::uDim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char**argv)
{

  // parse command line ----------------------------------------------
  po::options_description general_opt ( "Allowed options are: " );
  general_opt.add_options()
    ( "help,h", "display this message." )
    ( "input,i", po::value<std::string>(), "Input vol file." )
    ("thresholdMin,m",  po::value<int>()->default_value(0), "threshold min (excluded) to define binary shape" )
    ("thresholdMax,M",  po::value<int>()->default_value(255), "threshold max (included) to define binary shape" );
  bool parseOK=true;
  po::variables_map vm;


  
  try{
    po::store(po::parse_command_line(argc, argv, general_opt), vm);  
  }catch(const std::exception& ex){
    parseOK=false;
    trace.info()<< "Error checking program options: "<< ex.what()<< endl;
  }
  po::notify ( vm );
  if (!parseOK || vm.count ( "help" ) ||argc<=1 )
    {
      trace.info() << "Compute the Euleur Characteristic of  a vol to a 8-bit raw file. The vol file is first binarized using interval [m,M[ thresholds and the Eucler characteristic is given from the cubical complex"<<std::endl
                   << std::endl << "Basic usage: "<<std::endl
                   << "\eulerCharacteristic --input <volFileName> -m <minlevel> -M <maxlevel> "<<std::endl
                   << general_opt << "\n";
      return 0;
    }

  //Parse options
  if ( ! ( vm.count ( "input" ) ) ) missingParam ( "--input" );
  std::string filename = vm["input"].as<std::string>();
  int thresholdMin = vm["thresholdMin"].as<int>();
  int thresholdMax = vm["thresholdMax"].as<int>();
 
  //Importing the Vol
  trace.beginBlock("Loading the vol file");
  typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char>  MyImageC;
  MyImageC  imageC = VolReader< MyImageC >::importVol ( filename );
  trace.info()<<imageC<<std::endl;
  trace.endBlock();  

  //Constructing the cubical complex
  trace.beginBlock("Construting the cubical complex");
  KSpace::CellSet myCellSet;
  KSpace  ks;
  bool space_ok = ks.init( imageC.domain().lowerBound(), imageC.domain().upperBound(), true );
  if (!space_ok)
    {
      trace.error() << "Error in the Khamisky space construction."<<std::endl;
      return 2;
    }
  functors::IntervalForegroundPredicate<MyImageC> interval(imageC, thresholdMin,thresholdMax);  
  for(MyImageC::Domain::ConstIterator it =imageC.domain().begin(), itend= imageC.domain().end();
      it != itend; ++it)
    {
      if (interval( *it ))
        {
          Domain dom( 2*(*it), 2*(*it) + Point::diagonal(2));
          for(Domain::ConstIterator itdom = dom.begin(), itdomend = dom.end(); itdom != itdomend; ++itdom)
            myCellSet.insert( ks.uCell( *itdom) );
        }
    }
  trace.info() << "Got "<< myCellSet.size()<< " cells"<<std::endl;
  trace.endBlock();

  trace.beginBlock("Computing the characteristics");
  std::vector<int> cells(4,0);
  
  for(KSpace::CellSet::const_iterator it = myCellSet.begin(), itend = myCellSet.end(); it !=itend; ++it)
    cells[ ks.uDim(*it) ] ++; 
  
  trace.info() << "Got "<< cells[0]<< " pointels "<<cells[1]<<" linels  "<< cells[2]<<" surfels and "<<cells[3]<<"  bells"<<std::endl;
  trace.endBlock();

  trace.info() << "Volumetric Euler Characteristic = "<<cells[0] - cells[1] + cells[2] - cells[3]<<std::endl;

  return 0;
}
开发者ID:fabienbaldacci,项目名称:DGtalTools,代码行数:81,代码来源:eulerCharacteristic.cpp


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