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


C++ ImageType类代码示例

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


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

示例1:

void
pcl::pcl_2d::convolution_2d::conv  (ImageType &output, ImageType &kernel, ImageType &input){
  int rows = input.size ();
  int cols = input[0].size ();
  int k_rows = kernel.size ();
  int k_cols = kernel[0].size ();

  /*default boundary option : zero padding*/
  output.resize (input.size ());
  for (int i = 0; i < rows; i++)
  {
    output[i].resize (cols);
    for (int j = 0; j < cols; j++)
    {
      output[i][j] = 0;
      for (int k = 0; k < k_rows; k++)
      {
        for (int l = 0; l < k_cols; l++)
        {
          if ((i + k - k_rows / 2) < 0 || (i + k - k_rows / 2) >= rows || (j + l - k_cols / 2) < 0 || (j + l - k_cols / 2) >= cols)
          {
            continue;
          }
          else
          {
            output[i][j] += kernel[k][l] * input[i + k - k_rows / 2][j + l - k_cols / 2];
          }
        }
      }
    }
  }
}
开发者ID:daviddoria,项目名称:PCLMirror,代码行数:32,代码来源:convolution_2d.hpp

示例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:

template <unsigned dim,typename T> void
itkPhilipsRECDataImageReader::applyCorrection(FloatImageType::PointType correctorigin,
                                              FloatImageType::DirectionType correctdirection)
{
    // To take care of dimensions 3 and 4,
    // we need new direction and point types.
    typedef itk::Image<T,dim> ImageType;
    typedef typename ImageType::DirectionType correctDirectionType;
    typedef typename ImageType::PointType correctPointType;


    correctDirectionType direction;
    direction.SetIdentity();
    for (unsigned int i=0; i<3; i++)
        for (unsigned int j=0; j<3; j++)
            direction[i][j] = correctdirection[i][j];
    correctPointType origin;
    origin.Fill(0.0);
    for (unsigned int i=0; i<3; i++)
        origin[i] = correctorigin[i];

    ImageType* img = (ImageType *) (data()->data());
    img->SetDirection(direction);
    img->SetOrigin(origin);
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例4: 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

示例5: verifyImagePixels

    void verifyImagePixels(const ImageType& image,
            ImageFunction expectedPixels) {
        auto width = image.getWidth();
        auto height = image.getHeight();

        verifyImagePixels(image, width, height, expectedPixels);
    }
开发者ID:jvff,项目名称:mestrado-implementacao,代码行数:7,代码来源:OpenCLFilterKernelTests.hpp

示例6: getLocalWorkSize

    cl::NDRange getLocalWorkSize(const ImageType&,
            const ImageType& destinationImage) const override {
        auto width = destinationImage.getWidth();
        auto height = destinationImage.getHeight();

        return cl::NDRange(width / 2, height / 2);
    }
开发者ID:jvff,项目名称:mestrado-implementacao,代码行数:7,代码来源:OpenCLFilterOnImageQuarters.hpp

示例7: createXipImageSingle

static SoXipDataImage *
createXipImageSingle(SoItkDataImage * xipItkImage, SbXipImage::DataType typeFlag,
		     int bitsPerComp, SbXipImage::ComponentLayoutType compLayout)
{
    typedef typename itk::Image<Type, nDims> ImageType;
    ImageType * itkImage = reinterpret_cast<ImageType *>(xipItkImage->getPointer());

    typename ImageType::RegionType region = itkImage->GetBufferedRegion();

    SbXipImageDimensions dimensions(1, 1, 1);

    for (unsigned int i = 0; i < nDims; ++ i)
    {
	dimensions[i] = region.GetSize()[i];
    }

    SbXipImage* image =
	new SbXipImage(dimensions, typeFlag, bitsPerComp,
		       itkImage->GetBufferPointer(), nComps,
		       SbXipImage::INTERLEAVED, compLayout,
		       xipItkImage->getModelMatrix());

    if (!image) return 0;

    SoXipDataImage * xipImage = new SoXipDataImage;
    xipImage->ref();
    xipImage->addRef(xipItkImage);
    xipImage->set(image);

    return xipImage;
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:31,代码来源:SoItkConvertItkImageToXipImage.cpp

示例8:

void
pcl::pcl_2d::edge::ComputeDerivativeXCentral (ImageType &output, ImageType &input){
  ImageType kernel;
  kernel.resize (3);
  kernel[0].resize (1); kernel[1].resize (1); kernel[2].resize (1);
  kernel[0][0] = -1; kernel[1][0] = 0; kernel[2][0] = 1;
  conv_2d->convolve  (output, kernel, input);
}
开发者ID:daviddoria,项目名称:PCLMirror,代码行数:8,代码来源:edge.hpp

示例9: 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

示例10: write_output

void write_output (const VectorType& data,
                   const vector<vector<int> >& mask_indices,
                   ImageType& image) {
  for (size_t i = 0; i < mask_indices.size(); i++) {
    for (size_t dim = 0; dim < image.ndim(); dim++)
      image.index(dim) = mask_indices[i][dim];
    image.value() = data[i];
  }
}
开发者ID:MRtrix3,项目名称:mrtrix3,代码行数:9,代码来源:mrclusterstats.cpp

示例11: ImageType

bool GtPlusAccumulatorImageTriggerGadget::storeImage(const ISMRMRD::ImageHeader& imgHeader, const hoNDArray<ValueType>& img, const ISMRMRD::MetaContainer& attrib, ImageBufferType& buf)
{
    try
    {
        long long cha = attrib.as_long(GADGETRON_CHA, 0);

        size_t slc = imgHeader.slice;

        long long e2 = attrib.as_long(GADGETRON_E2, 0);

        size_t con = imgHeader.contrast;
        size_t phs = imgHeader.phase;
        size_t rep = imgHeader.repetition;
        size_t set = imgHeader.set;
        size_t ave = imgHeader.average;

        // create image
        ImageType* storedImage = new ImageType();
        GADGET_CHECK_RETURN_FALSE(storedImage!=NULL);

        storedImage->from_NDArray(img);
        storedImage->attrib_ = attrib;
        GADGET_CHECK_RETURN_FALSE(gtPlus_util_.setMetaAttributesFromImageHeaderISMRMRD(imgHeader, storedImage->attrib_));

        storedImage->attrib_.set(GADGETRON_PASS_IMMEDIATE, (long)0);
        buf(cha, slc, e2, con, phs, rep, set, ave) = storedImage;

        if ( pass_image_immediate_ )
        {
            Gadgetron::GadgetContainerMessage<ImageBufferType>* cm1 = new Gadgetron::GadgetContainerMessage<ImageBufferType>();

            ImageBufferType& imgBuf = *(cm1->getObjectPtr());

            std::vector<size_t> dim2D(num_of_dimensions_, 1);
            imgBuf.create(dim2D);

            imgBuf(0) = new ImageType();
            *imgBuf(0) = *storedImage;

            // set the pass_image flag, so next gadget knows
            imgBuf(0)->attrib_.set(GADGETRON_PASS_IMMEDIATE, (long)1);

            if (this->next()->putq(cm1) < 0) 
            {
                cm1->release();
                return false;
            }
        }
    }
    catch(...)
    {
        GERROR_STREAM("Error happens in GtPlusAccumulatorImageTriggerGadget::storeImage(const ISMRMRD::ImageHeader& imgHeader, const hoNDArray<ValueType>& img, const ISMRMRD::MetaContainer& attrib, ImageBufferType& buf) ... ");
        return false;
    }

    return true;
}
开发者ID:ACampbellWashburn,项目名称:gadgetron,代码行数:57,代码来源:GtPlusAccumulatorImageTriggerGadget.cpp

示例12:

void
pcl::keypoint::hessianBlob (ImageType &output, ImageType &input, const float sigma, bool SCALED){
  /*creating the gaussian kernels*/
  ImageType kernel, cornerness;
  conv_2d.gaussianKernel  (5, sigma, kernel);

  /*scaling the image with differentiation scale*/
  ImageType smoothed_image;
  conv_2d.convolve  (smoothed_image, kernel, input);

  /*image derivatives*/
  ImageType I_x, I_y;
  edge_detection.ComputeDerivativeXCentral  (I_x, smoothed_image);
  edge_detection.ComputeDerivativeYCentral  (I_y, smoothed_image);

  /*second moment matrix*/
  ImageType I_xx, I_yy, I_xy;
  edge_detection.ComputeDerivativeXCentral  (I_xx, I_x);
  edge_detection.ComputeDerivativeYCentral  (I_xy, I_x);
  edge_detection.ComputeDerivativeYCentral  (I_yy, I_y);
  /*Determinant of Hessian*/
  const size_t height = input.size ();
  const size_t width = input[0].size ();
  float min = std::numeric_limits<float>::max();
  float max = std::numeric_limits<float>::min();
  cornerness.resize (height);
  for (size_t i = 0; i < height; i++)
  {
    cornerness[i].resize (width);
    for (size_t j = 0; j < width; j++)
    {
      cornerness[i][j] = sigma*sigma*(I_xx[i][j]+I_yy[i][j]-I_xy[i][j]*I_xy[i][j]);
      if(SCALED){
        if(cornerness[i][j]  < min)
          min = cornerness[i][j];
        if(cornerness[i][j] > max)
          max = cornerness[i][j];
      }
    }

    /*local maxima*/
    output.resize (height);
    output[0].resize (width);
    output[height-1].resize (width);
    for (size_t i = 1; i < height - 1; i++)
    {
      output[i].resize (width);
      for (size_t j = 1; j < width - 1; j++)
      {
        if(SCALED)
          output[i][j] = ((cornerness[i][j]-min)/(max-min));
        else
          output[i][j] = cornerness[i][j];
      }
    }
  }
}
开发者ID:5irius,项目名称:pcl,代码行数:57,代码来源:keypoint.hpp

示例13: newIntImage

static jobject newIntImage(JNIEnv* env, ImageType& image) {
	jclass cls = safeFindClassMacro(cls, "Lcom/intel/vpg/IntImage;")
	jmethodID clsCons = safeFindMethodMacro(clsCons, cls, "<init>", "(II)V")
	jobject jintImage = env->NewObject(cls, clsCons, image.getWidth(),
			image.getHeight());
	jfieldID dataField = env->GetFieldID(cls, "data", "[I");
	jintArray jdata = (jintArray) env->GetObjectField(jintImage, dataField);
	arrayCopyToJNIMacro(data, Int, jint, image.getData())
	return jintImage;
}
开发者ID:fayhot,项目名称:gradworks,代码行数:10,代码来源:NativeCode.cpp

示例14: img

std::unique_ptr<Image<OpenCVColorType>> OpenCVImageDenoiser::denoise(const ImageType& image) const
{
	cv::Mat img(image.height(), image.width(), CV_8UC3);
	for (int i = 0; i < img.rows; ++i)
		for (int j = 0; j < img.cols; ++j)
			img.at<cv::Vec3b>(i, j) = image[{i, j}];
//	cv::cvtColor(img, img, CV_BGR2GRAY);
	cv::Mat res(img.rows, img.cols, CV_8UC3);
	cv::fastNlMeansDenoisingColored(img, res);
	return std::make_unique<OpenCVImage>(res);
}
开发者ID:NightCodersss,项目名称:obtuse-waffle,代码行数:11,代码来源:opencv_image_denoiser.cpp

示例15: 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


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