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


C++ MyImage类代码示例

本文整理汇总了C++中MyImage的典型用法代码示例。如果您正苦于以下问题:C++ MyImage类的具体用法?C++ MyImage怎么用?C++ MyImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MyImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 image file name (any 2D image format accepted by DGtal::GenericReader)")
    ("output,o", po::value<std::string>(), "output image file name (any 2D image format accepted by DGtal::GenericWriter)")
    ("angle,a", po::value<double>()->default_value(0.0), "Angle in radian")  ;
  
  bool parseOK=true;
  po::variables_map vm;
  try{
    po::store(po::parse_command_line(argc, argv, general_opt), vm);  
  }catch(const std::exception& ex){
    trace.info()<< "Error checking program options: "<< ex.what()<< std::endl;
    parseOK=false;
  }
  po::notify(vm);    
  if(vm.count("help")||argc<=1|| !parseOK)
    {
      trace.info()<< "Rotate an image by a given angle a binary object with 0 values as background points and values >0 for the foreground ones." <<std::endl << "Basic usage: "<<std::endl
      << "\t imgRotate [options] --input <imageName> --output <outputImage> --angle 0.3"<<std::endl
      << general_opt << "\n";
      return 0;
    }
  
  //Parameters
  if ( ! ( vm.count ( "input" ) ) ) missingParam ( "--input" );
  const std::string input = vm["input"].as<std::string>();
  if ( ! ( vm.count ( "output" ) ) ) missingParam ( "--output" );
  const std::string  output = vm["output"].as<std::string>();
  const double angle = vm["angle"].as<double>();
  
  typedef functors::IntervalForegroundPredicate<MyImage> Binarizer;
  MyImage image = GenericReader<MyImage>::import( input );
  trace.info() <<"Input image: "<< image<<std::endl;
  
  typedef functors::BackwardRigidTransformation2D<Z2i::Space> RotateFunctor;
  Z2i::RealPoint center = image.domain().upperBound();
  center -= image.domain().lowerBound();
  center /= 2.0;
  
  RotateFunctor rotationFunctor(center,
                                angle,
                                Z2i::RealPoint(0.0,0.0));
  
  functors::Identity idD;
  typedef functors::DomainRigidTransformation2D<MyImage::Domain, RotateFunctor> MyDomainTransformer;
  MyDomainTransformer rotDomain(rotationFunctor);
  typedef MyDomainTransformer::Bounds Bounds;
  Bounds newdomain = rotDomain( image.domain());
  MyImage::Domain transformedDomain ( newdomain.first, newdomain.second );
  typedef ConstImageAdapter<MyImage, MyImage::Domain, RotateFunctor, MyImage::Value, functors::Identity > MyImageBackwardAdapter;
  MyImageBackwardAdapter backwardImageAdapter ( image, transformedDomain , rotationFunctor, idD );
  
  backwardImageAdapter >> output;
  
  return 0;
}
开发者ID:rmonat,项目名称:princess-or-frog,代码行数:60,代码来源:imgRotate.cpp

示例2: result

MyImage ReverseProcessor::preProcessImage(const MyImage& image) const
{
  QImage *resultImage = ImageAlgorithm::reverse(image.getImage());
  MyImage result(*resultImage, image.getType());
  delete resultImage;
  return result;
}
开发者ID:SidneyTTW,项目名称:ImageProcessor,代码行数:7,代码来源:reverseprocessor.cpp

示例3: main

int main(int, char**){

    MyImage image;
    
    //Set up parameters for the triangl

    vec2 v0(100, 100);
    vec2 v1(200, 300);
    vec2 v2(400, 50);

    float TotalArea = triangleArea(v0, v1, v2);
    //rasterize the triangle   
    for (int row = 0; row < image.rows; ++row) {
        for (int col = 0; col < image.cols; ++col) {
            vec2 pt(col, row);

            /// Calculate the barycentric coordinates using the triangle area

       }
    }

   
    image.show();
    // image.save("output.png"); ///< Does not work on Windows!

    return EXIT_SUCCESS;
}
开发者ID:amitahire,项目名称:icg,代码行数:27,代码来源:main.cpp

示例4: testImageCopyShort

bool testImageCopyShort()
{
  unsigned int nbok = 0;
  unsigned int nb = 0;

  trace.beginBlock ( "Testing smart copy of Image..." );
  typedef ImageContainerBySTLVector<Z2i::Domain, int> VImage;
  typedef Image<VImage > MyImage;
  BOOST_CONCEPT_ASSERT(( CImage< MyImage > ));

  Z2i::Point a(0,0);
  Z2i::Point b(32,32);
  Z2i::Point c(12, 14);

  Z2i::Domain domain(a,b);

  MyImage image(  new VImage(domain) );
  trace.info() << "Image constructed: "<< image <<std::endl;

  VImage myImageC( domain );
  MyImage imageFromConstRef ( myImageC );
  trace.info() << "Image constructed (from constRef): "<< imageFromConstRef <<std::endl;
  nbok += (imageFromConstRef.getPointer().count()== 2) ? 1 : 0;
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
         << "unique" << std::endl;

  MyImage image3;
  trace.info() << "Image constructed (degulat): "<< image3 <<std::endl;


  trace.info() <<  "default: "<< image3 <<std::endl;
  image3 = image;
  nbok += (image3.getPointer().count()== 3) ? 1 : 0;
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
         << "true == true" << std::endl;
  trace.info() <<  "assignment: "<< image3 <<std::endl;
  nbok += (image3.getPointer().count()== 3) ? 1 : 0;
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
        << "true == true" << std::endl;

  image3.setValue(Z2i::Point(1,1), 4);
  trace.info() <<  "setValue on assigned: "<< image3 <<std::endl;
  nbok += (image3.getPointer().count()== 2) ? 1 : 0;
  nb++;

  MyImage image4(image3);
  trace.info() << "Image constructed (copy): "<< image4 <<std::endl;
  nbok += (image4.getPointer().count()== 3) ? 1 : 0;
  nb++;


  trace.info() << "(" << nbok << "/" << nb << ") "
         << "true == true" << std::endl;

  return nbok == nb;
}
开发者ID:alinemartin,项目名称:DGtal,代码行数:59,代码来源:testImageSimple.cpp

示例5: diff_pic

int diff_pic(unsigned char *logo_img_sample, int pyr_i, const MyImage &img_pic, int start_r, int start_c, int end_r, int end_c)
{
	unsigned char *Ybuf_pic = img_pic.getYbuf();
	int block_unit = 8;
	int block_len = pyr_i * BLOCK_SIZE;

	int error = 0;
	for(int i = start_r; i < end_r; i += block_unit) {
		for(int j = start_c; j < end_c; j += block_unit) {
	
			int min_mse = (1 << 31) - 1;
			for(int row = 0; row < block_len; row += block_unit) {
				for(int col = 0; col < block_len; col += block_unit) {

					int block_err = 0;
					for(int blc_i = 0; blc_i < block_unit; blc_i++) {
						for(int blc_j = 0; blc_j < block_unit; blc_j++) {
							int diff = logo_img_sample[(row + blc_i) * block_len + col + blc_j] - Ybuf_pic[(i + blc_i) * img_pic.getWidth() + j + blc_j];
							block_err += diff * diff;
						}
					}
					if(block_err < min_mse) min_mse = block_err;
				}
			}
			error += min_mse;
		}
	}
	return error / (block_len / 8) / (block_len / 8);
}
开发者ID:hypersaltla,项目名称:ImageMatch,代码行数:29,代码来源:ImageMatching.cpp

示例6: processImage

MyImage HistogramEqualizationProcessor::preProcessImage(const MyImage& image) const
{
  QImage *resultImage = processImage(image.getImage());
  MyImage result(*resultImage, MyImage::Gray);
  delete resultImage;
  return result;
}
开发者ID:SidneyTTW,项目名称:ImageProcessor,代码行数:7,代码来源:histogramequalizationprocessor.cpp

示例7: result

MyImage ToGrayProcessor::preProcessImage(const MyImage& image) const
{
  QImage *resultImage = ImageAlgorithm::convertToGrayScale(image.getImage(),
                                                           _type);
  MyImage result(*resultImage, MyImage::Gray);
  delete resultImage;
  return result;
}
开发者ID:SidneyTTW,项目名称:ImageProcessor,代码行数:8,代码来源:tograyprocessor.cpp

示例8: MyImage

MyImage* MyImage::LoadImage(string path) {
    GLuint texture;
    unsigned char *data;
    int width, height;

    MyImage *image = new MyImage();

    string ext;
    ext = path.substr( path.find_last_of('.') );
    
    if( ext.compare("tga") == 0 ) {
        if( ! image->InitWithFileTGA(path) ) {
            delete image;
            return NULL;
        }
        
        return image;
    }
    else if( ext.compare("png") == 0 ) {
        // not supported
        delete image;
        return NULL;
    }

    
    // else formats ...
    texture = SOIL_load_OGL_texture(path.c_str(),
                                    SOIL_LOAD_AUTO,
                                    SOIL_CREATE_NEW_ID,
                                    SOIL_FLAG_INVERT_Y,
                                    &data,
                                    &width,
                                    &height);
    if( texture == 0 ) {
        return NULL;
    }
    
    image = new MyImage( texture, data, width, height );
    return image;
}
开发者ID:byjo,项目名称:graphics-practice,代码行数:40,代码来源:MyImage.cpp

示例9: newImage

MyImage MyImage::over(MyImage& image, int posx, int posy){
	MyImage newImage(image.to4ChannelsImage());

	for(int y = 0; y< height && (y+posy)< newImage.height ; y++){
		for(int x = 0; x< width && (x+posx< newImage.width ); x++){
			for(int c = 0; c< 3; c++){
				newImage.data[c + (x+posx) *4 + (y+posy)*newImage.width*4]=
				newImage.data[c + (x+posx) *4 + (y+posy)*newImage.width*4] * (255-data[3+x*4+y*width*4])/255+data[c+ x*4 + y*width*4]*(data[3+x*4+y*width*4])/255;
				 
			}
		
		}
	}
	return newImage;

}
开发者ID:sylvanchil,项目名称:6040,代码行数:16,代码来源:myimage.cpp

示例10: compareImage_basic

bool compareImage_basic(const MyImage &img_logo, const MyImage &img_pic)
{
	int *his_logo = getHistogram_H(img_logo, 0, 0, img_logo.getHeight(), img_logo.getWidth());
	int *his_pic = getHistogram_H(img_pic, 0, 0, img_pic.getHeight(), img_pic.getWidth());
	print_arr(his_logo, H_N);
    print_arr(his_pic, H_N);
    int total_pixel = img_logo.getWidth() * img_logo.getHeight();
	retainMajority(his_logo, 0.9, H_N);
	TRACE("After retaining majority\n");
	print_arr(his_logo, H_N);
	filter(his_logo, his_pic, H_N);
	TRACE("After filtering\n");
	print_arr(his_pic, H_N);
	double *norm_his_logo = normalize(his_logo, H_N);
	double *norm_his_pic = normalize(his_pic, H_N);
	double diff = differ(norm_his_logo, norm_his_pic, H_N);
    TRACE("ecu diff: %lf\n", diff);
    delete his_logo;
    delete his_pic;
    delete norm_his_logo;
    delete norm_his_pic;

	return diff <= THRESHOLD;
}
开发者ID:hypersaltla,项目名称:ImageMatch,代码行数:24,代码来源:ImageMatching.cpp

示例11: QDialog

ToBlackAndWhiteDialog::ToBlackAndWhiteDialog(const MyImage& image,
                                             const Area& area,
                                             QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ToBlackAndWhiteDialog),
    _area(area)
{
  ui->setupUi(this);

  _image = image.getImage();

  changing = false;
  single = true;
  black = true;
  singleThreshold = 0;

  thresholdItem = new ThresholdItem();
  plot = new BasicStatisticPlot(
      ImageAlgorithm::getStatistic(image.getImage(), ImageAlgorithm::Green));
  ui->widget_2->layout()->addWidget(plot);
  plot->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
  thresholdItem->attach(plot);
  QVector<int> thresholds;
  thresholds.push_back(0);
  thresholdItem->setThresholds(thresholds);
  connect(thresholdItem,
          SIGNAL(thresholdChanged(QVector<int>)),
          this,
          SLOT(multipleChanged(QVector<int>)));
  xPlotPicker = new XPlotPicker(QwtPlot::xBottom,
                                QwtPlot::yLeft,
                                QwtPlotPicker::VLineRubberBand,
                                QwtPicker::AlwaysOn,
                                plot->canvas());
  xPlotPicker->setRubberBandPen(QColor(0, 0, 255, 160));
  xPlotPicker->setTrackerPen(QColor(0, 0, 255, 160));
  xPlotPicker->setEnabled(true);
  connect(xPlotPicker, SIGNAL(pressAt(int)), this, SLOT(singleChanged(int)));
  connect(ui->thresholdSpinBox,
          SIGNAL(valueChanged(int)),
          this,
          SLOT(singleChanged(int)));
  marker = new QwtPlotMarker();
  marker->setValue(0.0, 0.0);
  marker->setLineStyle(QwtPlotMarker::VLine);
  marker->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
  marker->setLinePen(QPen(Qt::green, 0, Qt::DashDotLine));
  marker->attach(plot);

  connect(ui->thresholdsEdit,
          SIGNAL(textEdited(QString)),
          this,
          SLOT(multipleTextChanged(QString)));
  connect(ui->blackButton,
          SIGNAL(toggled(bool)),
          this,
          SLOT(startWithBlack(bool)));
  connect(ui->whiteButton,
          SIGNAL(toggled(bool)),
          this,
          SLOT(startWithWhite(bool)));
  resetPreview();
}
开发者ID:SidneyTTW,项目名称:ImageProcessor,代码行数:63,代码来源:toblackandwhitedialog.cpp

示例12: display

//callback in glut loop
void display(void)
{
	std::cout << imageToBeOutput.getWidth() << " " << imageToBeOutput.getHeight() << " " << imageToBeOutput.getChannels()<<std::endl;

	glClear(GL_COLOR_BUFFER_BIT);
	glDrawPixels(imageToBeOutput.getWidth(), imageToBeOutput.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, display_data);
	glFlush();
}
开发者ID:sylvanchil,项目名称:6040,代码行数:9,代码来源:main.cpp

示例13: handleKey

//keyboard handle function to implement image manipulation
void handleKey(unsigned char key, int x, int y){
  switch(key){


//use key 'w' or 'W' to write image
      case 'w':	
      case 'W':
      if (writename != NULL)
      {
          Image.ImageWrite(writename);

      }

      //if the second parameter is not specified in command line, output the message 'cannot write the image'
      else{
          std::cout << "You cannot write the image because you didn't specify a filename." << std::endl;
      }
      break;

//use key 'q' or 'Q' to quit the program      
    case 'q':		// q - quit
    case 'Q':
    case 27:		// esc - quit
      exit(0);
      
    default:		// not a valid key -- just ignore it
      return;
  }
}
开发者ID:SiqiwuStella,项目名称:Computer-Graphic-Images,代码行数:30,代码来源:alphamask.cpp

示例14: sendDecodeSequentialMode

void sendDecodeSequentialMode(void* storage){
	TwoByte* st = (TwoByte*) storage;

	int h = workingImage.getHeight();
	int w = workingImage.getWidth();
										
	Byte* imgd = workingImage.getImageData();
	
	unsigned int q = 1<<quantizationLevel;

	TwoByte* tblock = new TwoByte[192];
	Byte* idctblock = new Byte[192];

	for(int y = 0; y < h; y+=8){
		for(int x = 0; x < w; x+=8){
			for(int yy= 0; yy < 8; yy++){
				for(int xx = 0; xx < 8; xx++){
					int src = ((y + yy)*w + (x + xx))*3;
					int dest = (yy*8 + xx)*3;
					tblock[dest] = st[src]*q;
					tblock[dest + 1] = st[src + 1]*q;  
					tblock[dest + 2] = st[src + 2]*q;  
				}
			}

			doIDCT(tblock, idctblock);
			
			for(int yy= 0; yy < 8; yy++){
				for(int xx = 0; xx < 8; xx++){
					int dest = ((y + yy)*w + (x + xx))*3;
					int src = (yy*8 + xx)*3;
					imgd[dest]  = idctblock[src];					
					imgd[dest + 1] = idctblock[src + 1];					
					imgd[dest + 2] = idctblock[src + 2];  					
				}
			}
			drawImage(&workingImage, nextStart);
			Sleep(latency);
		}
	}
		
	delete[] tblock;
	delete[] idctblock;
	MessageBox(NULL, "DECODING DONE", "Status", NULL);
}
开发者ID:atulkum,项目名称:imageProcessing,代码行数:45,代码来源:Image.cpp

示例15: decodeProgressiveModeSpectralSelection

void decodeProgressiveModeSpectralSelection(TwoByte* st){
	int h = workingImage.getHeight();
	int w = workingImage.getWidth();
										
	Byte* imgd = workingImage.getImageData();
	
	unsigned int q = 1<<quantizationLevel;

	TwoByte* tblock = new TwoByte[192];
	Byte* idctblock = new Byte[192];

	memset(tblock, 0x00, sizeof(TwoByte)*192);
	memset(idctblock, 0x00, sizeof(Byte)*192);

	for(int y = 0; y < h; y+=8){
		for(int x = 0; x < w; x+=8){
			for(int yy= 0; yy < 8; yy++){
				for(int xx = 0; xx < 8; xx++){
					int src = ((y + yy)*w + (x + xx))*3;
					int dest = (yy*8 + xx)*3;
					tblock[dest] = st[src]*q;
					tblock[dest + 1] = st[src + 1]*q;  
					tblock[dest + 2] = st[src + 2]*q;  
				}
			}

			doIDCT(tblock, idctblock);
			
			for(int yy= 0; yy < 8; yy++){
				for(int xx = 0; xx < 8; xx++){
					int dest = ((y + yy)*w + (x + xx))*3;
					int src = (yy*8 + xx)*3;
					imgd[dest]  = idctblock[src];					
					imgd[dest + 1] = idctblock[src + 1];					
					imgd[dest + 2] = idctblock[src + 2];  					
				}
			}
		}
	}
		
	delete[] tblock;
	delete[] idctblock;
	drawImage(&workingImage, nextStart);		
}
开发者ID:atulkum,项目名称:imageProcessing,代码行数:44,代码来源:Image.cpp


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