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


C++ ImageType::getImageInfo方法代码示例

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


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

示例1: testSkinRecogWithThreshold

void testSkinRecogWithThreshold(const std::vector<double> &mean, const Matrix &cov, ImageType &image, std::string out){

    RGB white(255,255,255);
    RGB black(0,0,0);

    int height, width, levels;
    image.getImageInfo(height,width,levels);

    RGB val;
    std::vector<double> pc(2); // pure color

    double thR, thG;
    for(int row = 0; row < height; row++){
     for(int col = 0; col < width; col++){
       image.getPixelVal(row, col, val);

       pc[0] = val.r/float(val.r+val.g+val.b);
       pc[1] = val.g/float(val.r+val.g+val.b);

       thR = exp(-(cov[0][0] * pow((pc[0] - mean[0]),2) +  cov[0][1] * (pc[0]- mean[0])));
       thG = exp(-(cov[1][0] * (pc[1] - mean[1]) + cov[1][1] * pow((pc[1] - mean[1]),2)));

       if((thR >= .9 && thG >= 1.0 && thG < 1.2)
         || (thR <= .8 && thR >= .7 && thG > 1.1)){
         image.setPixelVal(row, col, white);
       }
       else{
         image.setPixelVal(row, col, black);
       }
      }
     } // end outer for loop

    writeImage(out.c_str(), image);
}
开发者ID:YutaMiyake,项目名称:PatternRecognition,代码行数:34,代码来源:driver.cpp

示例2: expandImage

/*
Expand image function
Writen by: Jeremiah Berns
Dependincies, image.cpp, image.h
Discription: Will accept the shrunken image, the grow size of the image, and then
	     expand the image back to 256x256
*/
void expandImage(ImageType oldImage, ImageType& newImage, int growVal, string newImageName)
{
  //Variable decliration
    int rows, cols, Q, tempValue;
	

  //Variable setting
    oldImage.getImageInfo(rows, cols, Q);

    for(int i=0;i<rows;i++)
      {
	for(int j=0;j<cols;j++)
	  {
	  oldImage.getPixelVal(i,j, tempValue);
	  for(int k=0;k<growVal;k++)
	    {
	      for(int l=0;l<growVal;l++)
	        {
		newImage.setPixelVal(i*growVal+k,j*growVal+l,tempValue);
		}
	    }
	  }
      }

  writeImage(newImageName, newImage);
}
开发者ID:BigMacStorm,项目名称:imageProcessing,代码行数:33,代码来源:one.cpp

示例3: crop

void crop(ImageType& image)
{
    if(imageLoaded(image))
        {
                // initialize to -1 for input validation
                int ULr = -1, ULc = -1, LRr = -1, LRc = -1;
                int N, M, Q;
                int errorCode = 0;

                // get values
                image.getImageInfo(N,M,Q);

                // get inputs
                cout << "Enter the upper left corner's row: ";
                cin >> ULr;             

                cout << endl << "Enter the upper left corner's column: ";
                cin >> ULc;

                cout << endl << "Enter the lower right corner's row: ";
                cin >> LRr;

                cout << endl << "Enter the lower right corner's column: ";
                cin >> LRc;

                // check for errors
                if(ULr < 0 || ULc < 0 || LRr < 0 || LRc < 0)
                        errorCode = 1;
                        
                else if(ULr > N || LRr > N || ULc > M || LRc > M)
                        errorCode = 2;

                else if(ULr >= LRr || ULc >= LRc)
                        errorCode = 3;

                switch(errorCode)
                {
                        case 1:
                                cout << "ERROR: All inputs must be non-negative.";
                                break;
                        case 2:
                                cout << "ERROR: All crop boundaries must be within image boundaries.";
                                break;
                        case 3:
                                cout << "ERROR: All crop boundaries must be in the correct order.";
                                break;
                }
                
                // crop image if no error was found
                if(errorCode == 0)
                {
                        image.getSubImage(ULr, ULc, LRr, LRc, image);
                        cout << endl << endl << "Image has been cropped successfully.";
                }
        
                pressEnterToContinue();
        }
}               
开发者ID:nishokyadav,项目名称:schoolprojects,代码行数:58,代码来源:driver.cpp

示例4: testSkinRecognition

void testSkinRecognition(const BayesianClassifier &classifier, ImageType &image, ImageType &ref, std::string out, bool YCbCr){

    int height, width, levels;
    image.getImageInfo(height,width,levels);
    ImageType outImg(height,width,levels);

    RGB val1, val2;
    int label;
    std::vector<double> color(2);
    int TP = 0, TN = 0, FN = 0, FP = 0;
    RGB white(255,255,255);
    RGB black(0,0,0);

    for(int row = 0; row < height; row++){
      for(int col = 0; col < width; col++){
        image.getPixelVal(row, col, val1);
        ref.getPixelVal(row, col, val2);

        if(YCbCr == true){
          color[0] = -0.169*val1.r - 0.332*val1.g+ 0.500*val1.b;
          color[1] = 0.500*val1.r - 0.419*val1.g - 0.081*val1.b;
        }
        else{
          color[0] = val1.r/float(val1.r+val1.g+val1.b);
          color[1] = val1.g/float(val1.r+val1.g+val1.b);
        }

        label = classifier.predict(color);

        if(label == 0){
          outImg.setPixelVal(row, col, white);
          if(val2 != black){ TP++; } else{ FP++; }
        }
        else{
          outImg.setPixelVal(row, col, black);
          if(val2 == black){ TN++; } else{ FN++; }
        }
      }
    }  // end outer for loop

    std::cout << std::endl
              << "TP: " << TP << std::endl
              << "TN: " << TN << std::endl
              << "FP: " << FP << std::endl
              << "FN: " << FN << std::endl;

    /*std::stringstream ss;
    ss << FP << " " << FN;
    Debugger debugger("Data_Prog2/errors3a.txt",true);
    debugger.debug(ss.str());
    */

    writeImage(out.c_str(), outImg);
}
开发者ID:YutaMiyake,项目名称:PatternRecognition,代码行数:54,代码来源:driver.cpp

示例5: makeColorMatrices

void makeColorMatrices(ImageType& img, ImageType& ref, Matrix &sk_cols,
  Matrix &nsk_cols, bool YCbCr)
{
  int height1, width1, levels1;
  int height2, width2, levels2;
  img.getImageInfo(height1, width1, levels1);
  ref.getImageInfo(height2, width2, levels2);

  assert(height1 == height2);
  assert(width1 == width2);
  assert(levels1 == levels2);

  RGB val1, val2;
  std::vector<double> color(2);
  RGB black(0,0,0);

  for(int row = 0; row < height1; row++){
    for(int col = 0; col < width1; col++){
      img.getPixelVal(row, col, val1);
      ref.getPixelVal(row, col, val2);

      if(YCbCr == true){
        color[0] = -0.169*val1.r - 0.332*val1.g+ 0.500*val1.b;
        color[1] = 0.500*val1.r - 0.419*val1.g - 0.081*val1.b;
      }
      else{
        color[0] = val1.r/float(val1.r+val1.g+val1.b);
        color[1] = val1.g/float(val1.r+val1.g+val1.b);
      }

      if(val2 != black){
        sk_cols.push_back(color);
      }
      else{
        nsk_cols.push_back(color);
      }
    }
  }
}
开发者ID:YutaMiyake,项目名称:PatternRecognition,代码行数:39,代码来源:driver.cpp

示例6: writeImage

void writeImage(const char fname[], ImageType& image)
/* write PPM image */
{
    int i, j;
    int N, M, Q;
    unsigned char *charImage;
    ofstream ofp;

    image.getImageInfo(N, M, Q);

    // make space for PPM
    charImage = (unsigned char *) new unsigned char [3*M*N];

    // convert the RGB  to unsigned char
    RGB val;
    for(i=0; i<N; i++) {
        for(j=0; j<3*M; j+=3) {
            image.getPixelVal(i, j/3, val);
            charImage[i*3*M+j]=(unsigned char)val.r;
            charImage[i*3*M+j+1]=(unsigned char)val.g;
            charImage[i*3*M+j+2]=(unsigned char)val.b;
        }
    }

    ofp.open(fname, ios::out | ios::binary);

    if (!ofp) {
        cout << "Can't open file: " << fname << endl;
        exit(1);
    }

    ofp << "P6" << endl;
    ofp << M << " " << N << endl;
    ofp << Q << endl;

    ofp.write( reinterpret_cast<char *>(charImage), (3*M*N)*sizeof(unsigned char));

    if (ofp.fail()) {
        cout << "Can't write image " << fname << endl;
        exit(0);
    }

    ofp.close();

    delete [] charImage;

}
开发者ID:YutaMiyake,项目名称:PatternRecognition,代码行数:47,代码来源:WriteImage.cpp

示例7: histogramEq

/*
Histogram Equalization function
Written by: Jeremiah Berns
Dependincies:image.h, image.cpp
Discription:  This function will perform the histogram equalization algorithem to the oldImage
             and will output the newImage with the given newImageName.  
*/
void histogramEq(ImageType oldImage, ImageType& newImage, string newImageName)
{
  int rows, cols, Q, pixelValue, pixelCount;
  oldImage.getImageInfo(rows,cols,Q);
  pixelCount = rows*cols;
  int adjustedHistogram[Q];
  double histogramArray[Q], equalizedHistogram[Q];
  double probabilityArray[Q], cumulativeProbability[Q], probTotal=0;
 

  for (int i = 0; i<Q;i++)
    {
    histogramArray[i] = 0;
    equalizedHistogram[i] = 0;

    }

  for(int i=0; i<rows;i++)
    {
      for(int j=0; j<cols;j++)
        {
	  oldImage.getPixelVal(i,j,pixelValue);
  	  histogramArray[pixelValue]+=1;
	}
    }

  for(int i=0;i<Q;i++)
    {
     probTotal+= histogramArray[i]/pixelCount;
    
     cumulativeProbability[i] = probTotal;
     cumulativeProbability[i] = cumulativeProbability[i]*255;
     adjustedHistogram[i] = cumulativeProbability[i];
     cout<<adjustedHistogram[i]<<endl;
    }

  for(int i=0; i<rows;i++)
    {
      for(int j=0; j<cols;j++)
        {
	  oldImage.getPixelVal(i,j,pixelValue);
  	  newImage.setPixelVal(i,j,adjustedHistogram[pixelValue-1]);
	}
    }

  writeImage(newImageName, newImage);
}
开发者ID:BigMacStorm,项目名称:imageProcessing,代码行数:54,代码来源:three.cpp

示例8: displayInfo

void displayInfo(ImageType& image)
{
    if(imageLoaded(image))
        {
                int N, M, Q;
                
                // get values
                image.getImageInfo(N,M,Q);

                cout << "Height           : " << N << endl
                         << "Width            : " << M << endl
                         << "Max Pixel Value  : " << Q << endl
                         << "Mean Gray Value  : " << image.meanGray();

                pressEnterToContinue();
        }
}
开发者ID:nishokyadav,项目名称:schoolprojects,代码行数:17,代码来源:driver.cpp

示例9: writeImage

void writeImage(string fname, ImageType& image){
	int i, j;
	int N, M, Q;
	unsigned char *charImage;
	ofstream ofp;

	image.getImageInfo(N, M, Q);

	charImage = (unsigned char *) new unsigned char [M*N];

	// convert the integer values to unsigned char

	int val;

	for(i=0; i<N; i++){
		for(j=0; j<M; j++){
			image.getPixelVal(i, j, val);
			charImage[i*M+j]=(unsigned char)val;
		}
	}

	ofp.open(fname.c_str(), ios::out | ios::binary);

	if (!ofp) {
		cout << "Can't open file: " << fname << endl;
		exit(1);
	}

	ofp << "P5" << endl;
	ofp << M << " " << N << endl;
	ofp << Q << endl;

	ofp.write( reinterpret_cast<char *>(charImage), (M*N)*sizeof(unsigned char));

	if (ofp.fail()) {
		cout << "Can't write image " << fname << endl;
		exit(0);
	}

	ofp.close();
}
开发者ID:BigMacStorm,项目名称:imageProcessing,代码行数:41,代码来源:one.cpp

示例10: shrinkImage

/*
shrink Image funtion.
Writen By Jeremiah Berns.
Dependincies: image.h, image.cpp
Discription: Will take in the old image, and the new image, and the pixel value
	    based apon the shrink value passed to it.  It will place that value
	    from the old image into the new image, then save the new image with
   	    the passed in file name. 
*/
void shrinkImage(ImageType oldImage, ImageType& newImage, int shrinkVal, string newImageFname)
{
	//Variable decliration
	int rows, col, Q, tempValue;
	

	//Variable setting
	oldImage.getImageInfo(rows, col, Q);

	for(int i=0; i<rows;i++)
	  {
	    for(int j=0;j<col;j++)
	      {
		if(i%shrinkVal == 0 && j%shrinkVal ==0)
		  {
		    oldImage.getPixelVal(i,j, tempValue);
		    newImage.setPixelVal(i/shrinkVal,j/shrinkVal,tempValue);
		  }
	      }
	    
	  }

	writeImage(newImageFname, newImage);
}
开发者ID:BigMacStorm,项目名称:imageProcessing,代码行数:33,代码来源:one.cpp


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