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


C++ Array2D::width方法代码示例

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


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

示例1: testBilateralFilter

void testBilateralFilter( const Array2D< float >& input,
	float ss, float sr,
	Array2D< float >& output )
{
	BilateralFilter bf( input.width(), input.height(), ss, sr );
	
	int nIterations = 100;

    
	bf.setInput( input );
	StopWatch sw;

	for( int i = 0; i < nIterations; ++i )
	{
		bf.apply( );
		cudaDeviceSynchronize();
	}

	float ms = sw.millisecondsElapsed();
	bf.getOutput( output );
	printf( "image size: %d x %d\n", input.width(), input.height() );
	printf( "ss = %f, sr = %f\n", ss, sr );
	printf( "Total time = %f ms, ms on average: %f\n",
		ms, ms / nIterations );
}
开发者ID:autumnm1981,项目名称:Halide,代码行数:25,代码来源:main2.cpp

示例2: d8_flow_directions

void d8_flow_directions(
  const Array2D<T> &elevations,
        Array2D<U> &flowdirs
){
  ProgressBar progress;

  std::cerr<<"A D8 Flow Directions"<<std::endl;
  std::cerr<<"C TODO"<<std::endl;

  std::cerr<<"p Setting up the flow directions matrix..."<<std::endl;
  flowdirs.resize(elevations);
  flowdirs.setAll(NO_FLOW);
  flowdirs.setNoData(FLOWDIR_NO_DATA);

  std::cerr<<"p Calculating D8 flow directions..."<<std::endl;
  progress.start( elevations.width()*elevations.height() );
  #pragma omp parallel for
  for(int y=0;y<elevations.height();y++){
    progress.update( y*elevations.width() );
    for(int x=0;x<elevations.width();x++)
      if(elevations(x,y)==elevations.noData())
        flowdirs(x,y) = flowdirs.noData();
      else
        flowdirs(x,y) = d8_FlowDir(elevations,x,y);
  }
  std::cerr<<"t Succeeded in = "<<progress.stop()<<" s"<<std::endl;
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例3: TA_CTI

void TA_CTI(
  const Array2D<T> &flow_accumulation,
  const Array2D<U> &riserun_slope,
        Array2D<V> &result
){
  Timer timer;

  RDLOG_ALG_NAME<<"d8_CTI";

  if(flow_accumulation.width()!=riserun_slope.width() || flow_accumulation.height()!=riserun_slope.height())
    throw std::runtime_error("Couldn't calculate CTI! The input matricies were of unequal dimensions!");

  RDLOG_PROGRESS<<"Setting up the CTI matrix..."<<std::flush;
  result.resize(flow_accumulation);
  result.setNoData(-1);  //Log(x) can't take this value of real inputs, so we're good
  RDLOG_PROGRESS<<"succeeded.";

  RDLOG_PROGRESS<<"Calculating CTI..."<<std::flush;
  timer.start();
  #pragma omp parallel for collapse(2)
  for(int x=0;x<flow_accumulation.width();x++)
    for(int y=0;y<flow_accumulation.height();y++)
      if(flow_accumulation(x,y)==flow_accumulation.noData() || riserun_slope(x,y)==riserun_slope.noData())
        result(x,y)=result.noData();
      else
        result(x,y)=log( (flow_accumulation(x,y)/flow_accumulation.getCellArea()) / (riserun_slope(x,y)+0.001) );
  RDLOG_TIME_USE<<"succeeded in "<<timer.stop()<<"s.";
}
开发者ID:r-barnes,项目名称:richdem,代码行数:28,代码来源:terrain_attributes.hpp

示例4: matrix_multiply

Array2D matrix_multiply(const Array2D &M1,const Array2D &M2) {
	if (M1.height()!=M2.width()) return Array2D();
	Array2D ret(M1.width(),M2.height());
	for (int j=0; j<ret.height(); j++)
	for (int i=0; i<ret.width(); i++) {
		double val=0;
		for (int k=0; k<M1.height(); k++) {
			val+=M1.value(i,k)*M2.value(k,j);
		}
		ret.setValue(val,i,j);
	}
	return ret;
}
开发者ID:magland,项目名称:saladsort,代码行数:13,代码来源:array2d.cpp

示例5: TerrainProcessor

static inline void TerrainProcessor(F func, const Array2D<T> &elevations, const float zscale, Array2D<float> &output){
  if(elevations.getCellLengthX()!=elevations.getCellLengthY())
    RDLOG_WARN<<"Cell X and Y dimensions are not equal!";

  output.resize(elevations);
  ProgressBar progress;

  progress.start(elevations.size());
  #pragma omp parallel for
  for(int y=0;y<elevations.height();y++){
    progress.update(y*elevations.width());
    for(int x=0;x<elevations.width();x++)
      if(elevations.isNoData(x,y))
        output(x,y) = output.noData();
      else
        output(x,y) = func(elevations,x,y,zscale);
  }
  RDLOG_TIME_USE<<"Wall-time = "<<progress.stop();
}
开发者ID:r-barnes,项目名称:richdem,代码行数:19,代码来源:terrain_attributes.hpp

示例6: GetNumberOfRadiusSegments

int SpotLightFallOFFIntensityCalculator::GetNumberOfRadiusSegments(const Array2D<Rgba>& inputImage_, const Point2D<int>& corePoint_) {
    
    //Get Max distance from core point to all points in image
    int max1 = std::sqrt(powf(corePoint_.x, 2) + powf(corePoint_.y, 2));
    int max2 = std::sqrt(powf(corePoint_.x - inputImage_.width(), 2) + powf(corePoint_.y - inputImage_.height(), 2));
    int max3 = std::sqrt(powf(corePoint_.x - inputImage_.width(), 2) + powf(corePoint_.y, 2));
    int max4 = std::sqrt(powf(corePoint_.x, 2) + powf(corePoint_.y - inputImage_.height(), 2));
    
    int max = std::max(std::max(std::max(max1, max2), max3), max4);
    return (int)(max/BLOCKSIZE);
}
开发者ID:pratheba,项目名称:Archis,代码行数:11,代码来源:SpotLightFallOFFIntensityCalculator.cpp

示例7: dinf_flow_flats

void dinf_flow_flats(
    const Array2D<int32_t> &flat_resolution_mask,
    const Array2D<int32_t> &groups,
    Array2D<float> &flowdirs
) {
    ProgressBar progress;

    std::cerr<<"\n###Dinf Flow Flats"<<std::endl;

    std::cerr<<"%%Calculating Dinf flow directions using flat mask..."<<std::endl;
    progress.start( flat_resolution_mask.width()*flat_resolution_mask.height() );
    #pragma omp parallel for
    for(int x=1; x<flat_resolution_mask.width()-1; x++) {
        progress.update( x*flat_resolution_mask.height() );
        for(int y=1; y<flat_resolution_mask.height()-1; y++)
            if(flat_resolution_mask(x,y)==flat_resolution_mask.noData())
                continue;
            else if(flowdirs(x,y)==NO_FLOW)
                flowdirs(x,y)=dinf_masked_FlowDir(flat_resolution_mask,groups,x,y);
    }
    std::cerr<<"Succeeded in "<<progress.stop()<<"s."<<std::endl;
}
开发者ID:r-barnes,项目名称:richdem,代码行数:22,代码来源:flat_resolution_dinf.hpp

示例8: testCrossBilateralFilter

void testCrossBilateralFilter( const Array2D< float >& data, const Array2D< float >& edge,
	float ss, float sr,
	Array2D< float >& output )
{
	BilateralFilter cbf( data.width(), data.height(), ss, sr, 0.f, 1.f, true );
	
	int nIterations = 100;

	StopWatch sw;

	for( int i = 0; i < nIterations; ++i )
	{
		cbf.applyCross( data, edge, output );
		cudaDeviceSynchronize();
	}

	float ms = sw.millisecondsElapsed();
	printf( "image size: %d x %d\n", data.width(), data.height() );
	printf( "ss = %f, sr = %f\n", ss, sr );
	printf( "Total time = %f ms, ms on average: %f\n",
		ms, ms / nIterations );
}
开发者ID:autumnm1981,项目名称:Halide,代码行数:22,代码来源:main2.cpp

示例9: dinf_flow_directions

void dinf_flow_directions(const Array2D<T> &elevations, Array2D<float> &flowdirs){
  ProgressBar progress;

  std::cerr<<"\nA Dinf Flow Directions"<<std::endl;
  std::cerr<<"C Tarboton, D.G. 1997. A new method for the determination of flow directions and upslope areas in grid digital elevation models. Water Resources Research. Vol. 33. pp 309-319."<<std::endl;

  std::cerr<<"p Setting up the Dinf flow directions matrix..."<<std::endl;
  flowdirs.resize(elevations);
  flowdirs.setNoData(dinf_NO_DATA);
  flowdirs.setAll(NO_FLOW);

  std::cerr<<"p Calculating Dinf flow directions..."<<std::endl;
  progress.start( elevations.size() );
  #pragma omp parallel for
  for(int y=0;y<elevations.height();y++){
    progress.update( y*elevations.width() );
    for(int x=0;x<elevations.width();x++)
      if(elevations(x,y)==elevations.noData())
        flowdirs(x,y) = flowdirs.noData();
      else
        flowdirs(x,y) = dinf_FlowDir(elevations,x,y);
  }
  std::cerr<<"t Succeeded in = "<<progress.stop()<<" s"<<std::endl;
}
开发者ID:,项目名称:,代码行数:24,代码来源:

示例10: threshold

int threshold(int th, Array2D &im) {
  int w = im.width();
  int h = im.height();
  int cnt=0;
  for (int i=0; i<h; ++i) {
    for (int j=0; j<w; ++j) {
      if (im[i][j] < th) {
	im[i][j] = 0;
      } else {
	im[i][j] = 255;
	++cnt;
      }
    }
  }
  return cnt;
}
开发者ID:XeryusTC,项目名称:handwritingrecog,代码行数:16,代码来源:threshold.cpp

示例11: GridPerimToArray

void GridPerimToArray(const Array2D<U> &grid, std::vector<U> &vec){
  assert(vec.size()==0); //Ensure receiving array is empty

  std::vector<U> vec2copy;

  vec2copy = grid.getRowData(0);                         //Top
  vec.insert(vec.end(),vec2copy.begin(),vec2copy.end());

  vec2copy = grid.getColData(grid.width()-1);        //Right
  vec.insert(vec.end(),vec2copy.begin()+1,vec2copy.end());
  
  vec2copy = grid.getRowData(grid.height()-1);       //Bottom
  vec.insert(vec.end(),vec2copy.begin(),vec2copy.end()-1);
  
  vec2copy = grid.getColData(0);                         //Left
  vec.insert(vec.end(),vec2copy.begin()+1,vec2copy.end()-1);
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例12: saveArrayAsImage

void saveArrayAsImage( const Array2D< float >& array, QString prefix, float ss, float sr )
{
	Image4f im( array.width(), array.height() );

	for( int y = 0; y < im.height(); ++y )
	{
		for( int x = 0; x < im.width(); ++x )
		{
			float v = array( x, y );
			im.setPixel( x, y, Vector4f( v, v, v, 1 ) );
		}
	}

	QString filename = QString( "%1_%2_%3.png" ).arg( prefix ).arg( ss ).arg( sr );
	printf( "saving output: %s...", qPrintable( filename ) );
	im.flipUD().save( filename );
	printf( "done.\n\n" );
}
开发者ID:autumnm1981,项目名称:Halide,代码行数:18,代码来源:main2.cpp

示例13: FindFlats

void FindFlats(
  const Array2D<T>   &elevations,
  Array2D<int8_t>    &flats
){
  flats.resize(elevations);
  flats.setNoData(FLAT_NO_DATA);

  ProgressBar progress;

  progress.start( elevations.size() );

  #pragma omp parallel for
  for(int y=0;y<elevations.height();y++)
  for(int x=0;x<elevations.width();x++){
    if(elevations.isNoData(x,y)){
      flats(x,y) = FLAT_NO_DATA;
      continue;
    }

    if(elevations.isEdgeCell(x,y)){
      flats(x,y) = NOT_A_FLAT;
      continue;
    }

    //We'll now assume that the cell is a flat unless proven otherwise
    flats(x,y) = IS_A_FLAT;

    for(int n=1;n<=8;n++){
      const int nx = x+dx[n];
      const int ny = y+dy[n];
      if(elevations(nx,ny)<elevations(x,y) || elevations.isNoData(nx,ny)){
        flats(x,y) = NOT_A_FLAT;
        break;
      }
    }

    //We handled the base case just above the for loop
  }

  RDLOG_TIME_USE<<"Succeeded in = "<<progress.stop()<<" s";
}
开发者ID:r-barnes,项目名称:richdem,代码行数:41,代码来源:find_flats.hpp

示例14: GetLightFallOffPointsfromCorePoints_UsingGradientEstimation

void SpotLightFallOFFIntensityCalculator::GetLightFallOffPointsfromCorePoints_UsingGradientEstimation(const Array2D<Rgba>& inputImage_, const Point2D<int>& corePoint_) {
 
    int imageHeight = (int)inputImage_.height();
    int imageWidth  = (int)inputImage_.width();
    
    UtilityClass* util = new UtilityClass();
    Rgba* outputPixels = util->GetImagePixelsToWrite(imageWidth, imageHeight);
    Array2D<Rgba> outputImage(imageHeight,imageWidth);
    Array2D<Rgba> outputImage1(imageHeight,imageWidth);
    
    ImageFilterFactoryClass* imageFilterFactoryClass = new ImageFilterFactoryClass();
    ImageFilterClass* imageFilterClass = imageFilterFactoryClass->GetImageFilterClass(inputImage_, 5, FILTERTYPE::GAUSSIAN);
    imageFilterClass->ProcessImage(inputImage_, outputImage);
    
    imageFilterClass = imageFilterFactoryClass->GetImageFilterClass(outputImage, 1, FILTERTYPE::SOBEL);
    imageFilterClass->ProcessImage(outputImage,outputImage1);
    
//    imageFilterClass = imageFilterFactoryClass->GetImageFilterClass(inputImage_, 2, FILTERTYPE::GAUSSIAN);
//    imageFilterClass->ProcessImage(outputImage1, outputImage);
//    
//    imageFilterClass = imageFilterFactoryClass->GetImageFilterClass(outputImage, 1, FILTERTYPE::SOBEL);
//    imageFilterClass->ProcessImage(outputImage,outputImage1);
    
    for (int row = 0; row < (imageHeight); ++row) {
        for (int col = 0; col < (imageWidth); ++col) {
            int i = row * imageWidth + col;
            outputPixels[i] = outputImage1[row][col];
        }
    }
    
    util->WriteImage2DArrayPixels("../../Output/LOG1.exr", outputPixels, imageWidth, imageHeight);
    
    delete util;
    delete imageFilterFactoryClass;
   
}
开发者ID:pratheba,项目名称:Archis,代码行数:36,代码来源:SpotLightFallOFFIntensityCalculator.cpp

示例15:

void Array2DPrivate::copy_from(const Array2D &X) {	
	allocate(X.width(),X.height());
	long N=X.width()*X.height();
	for (long ii=0; ii<N; ii++)
		m_data[ii]=X.d->m_data[ii];
}
开发者ID:magland,项目名称:saladsort,代码行数:6,代码来源:array2d.cpp


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