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


C++ ReadImage函数代码示例

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


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

示例1: ReadImage

inline int ReadImage(const char * path, Image<RGBAColor> * im)
{
    std::vector<unsigned char> ptr;
    int w, h, depth;
    int res = ReadImage(path, &ptr, &w, &h, &depth);
    if (depth !=4) return 0;
    if (res == 1) {
        RGBAColor * ptrCol = (RGBAColor*) &ptr[0];
        //convert raw array to Image
        (*im) = Eigen::Map<Image<RGBAColor>::Base>(ptrCol, h, w);
    }
    return res;
}
开发者ID:zhusa580999999,项目名称:openMVG,代码行数:13,代码来源:image_io.hpp

示例2: main

/* main function */
int main()
{
	// empty buffers
	memset(inputimage, 0, HEIGHT*WIDTH*sizeof(unsigned char));
	memset(outputimage, 0, HEIGHT*WIDTH*sizeof(unsigned char));

	// read image(s)
	ReadImage("testpattern.raw", inputimage);
	InitFilter();
	ProcessImage(inputimage, outputimage);
	WriteImage("smoothed.raw", outputimage);
	return 0;
}
开发者ID:hermana,项目名称:cs425,代码行数:14,代码来源:main.cpp

示例3: CheckSceneAverage

void CheckSceneAverage(const char *filename, float expected) {
  Point2i resolution;
  std::unique_ptr<RGBSpectrum[]> image = ReadImage(filename, &resolution);

  float delta = .02;
  float sum = 0;

  for (int i = 0; i < resolution.x * resolution.y; ++i)
    for (int c = 0; c < 3; ++c)
      sum += image[i][c];
  int nPixels = resolution.x * resolution.y * 3;
  EXPECT_NEAR(expected, sum / nPixels, delta);
}
开发者ID:tdapper,项目名称:pbrt-v3,代码行数:13,代码来源:analytic_scenes.cpp

示例4: ReadImage

void CControl::run_debug_forlist()
{
  cout<<"processing...."<<endl;
  for(int i=0;i<nImgList.size();i++)
    {
      String n_filename=nImgList.at(i);
      //read img in nrawimg
      ReadImage(n_filename);

      //check
      if(!nImgRaw.data)
	continue;

      //get lines in all direction;
      nLineSegExtractor.SetParamters(nImgRaw);
      vector<Point2f> n_linevct=nLineSegExtractor.GetLineSegments();
	     
      //get lines in specific direction
      vector<Point2f> n_filterlinevct;
      float n_angle=90;
      FilterLineAngle(n_linevct,n_filterlinevct,n_angle,nControlOptions.nAngleThhold);

      //get ransac lines;
      vector<Point3f> n_linecoef;
      nRansacExtractor.GetRansacLines(n_linecoef,n_filterlinevct,nControlOptions.nInterval,nControlOptions.nRansacThreshold,nControlOptions.nRansacMininlier);
      if(nIfDebug)
	{
	  // cout<<"angle: "<<n_angle<<' '<<"threshold: "<<nControlOptions.nAngleThhold<<endl;
	  // cout<<"get filter line: "<<n_filterlinevct.size()<<endl;
	  // cout<<"get ransac lines: "<<n_linecoef.size()<<endl;
	  //   Draw_debug;
	  Mat n_img;
	  nImgRaw.copyTo(n_img);
	  Draw_debug(n_img,n_filterlinevct,"1");
	  Mat n_img2;
	  nImgRaw.copyTo(n_img2);
	  Draw_debug(n_img2,n_linevct,"2");
	}	    
      //evaluate;
      Mat n_img3;
      nImgRaw.copyTo(n_img3);
      CEvaluate n_evaluate;
      n_evaluate.SetLines(n_linecoef,n_filterlinevct);
      n_evaluate.GetNearestLines(5);
      cout<<"length: "<<n_evaluate.GetLengthVal()<<endl;
      cout<<"density: "<<n_evaluate.GetDensityVal()<<endl;
      n_evaluate.Draw_debug(n_img3,"passdirection");
    }

  cout<<"complete!!"<<endl;
}
开发者ID:junwangcas,项目名称:Taxi,代码行数:51,代码来源:CControl.cpp

示例5: TestImageModifierStack

void TestImageModifierStack(void)
{
	BeginTests();

	CImage					cImage;
	CImageModifierStack		cStack;
	BOOL					bResult;
	CImageRGBToGrey*		pcGrey;
	CImageHeightToNormals*	pcNormals;
	CImageResampler*		pcSmall;
	CImage					cBak;

	bResult = ReadImage(&cBak, "Input/Adelle.png");
	AssertBool(TRUE, bResult);

	cImage.Copy(&cBak);
	cStack.Init(&cImage);

	pcGrey = cStack.AddModifier<CImageRGBToGrey>();
	pcGrey->Init(RGBTGS_UseRed);
	cStack.ApplyAll();

	WriteImage(&cImage, "Output/AdelleGrey.raw");
	AssertFileMemory("Input/AdelleGrey.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	pcNormals = cStack.AddModifier<CImageHeightToNormals>();
	pcNormals->Init(IMAGE_DIFFUSE_GREY);
	cImage.Copy(&cBak);
	cStack.ApplyAll();

	WriteImage(&cImage, "Output/AdelleNormal.raw");
	AssertFileMemory("Input/AdelleNormal.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	pcSmall = cStack.AddModifier<CImageResampler>();
	pcSmall->Init(IR_NearestNeighbour, 21, 16);
	cImage.Copy(&cBak);
	cStack.ApplyAll();

	WriteImage(&cImage, "Output/AdelleSmall.raw");
	AssertFileMemory("Input/AdelleSmall.raw", cImage.GetData(), cImage.GetByteSize());
	AssertInt(3, cStack.NumModifiers());

	cStack.Kill();
	cImage.Kill();

	cBak.Kill();

	TestStatistics();
}
开发者ID:chrisjaquet,项目名称:Codaphela.Test,代码行数:51,代码来源:TestImageModifierStack.cpp

示例6: Light

GonioPhotometricLight::GonioPhotometricLight(const Transform &light2world,
        const Spectrum &intensity, const string &texname)
    : Light(light2world) {
    lightPos = LightToWorld(Point(0,0,0));
    Intensity = intensity;
    // Create _mipmap_ for _GonioPhotometricLight_
    int width, height;
    RGBSpectrum *texels = ReadImage(texname, &width, &height);
    if (texels) {
        mipmap = new MIPMap<RGBSpectrum>(width, height, texels);
        delete[] texels;
    }
    else mipmap = NULL;
}
开发者ID:3dglazer,项目名称:pbm,代码行数:14,代码来源:goniometric.cpp

示例7: UnformatImage

bool UnformatImage (const std::string &path, Range range)
{
	auto disk = std::make_shared<Disk>();
	if (!ReadImage(path, disk))
		return false;

	ValidateRange(range, MAX_TRACKS, MAX_SIDES, disk->cyls(), disk->heads());

	range.each([&] (const CylHead &cylhead) {
		if (!g_fAbort)
			disk->write_track(cylhead, Track());
	});

	return WriteImage(path, disk);
}
开发者ID:d235j,项目名称:samdisk,代码行数:15,代码来源:cmd_format.cpp

示例8: ReadMPEGImage

/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   R e a d M P E G I m a g e                                                 %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  ReadMPEGImage() reads an binary file in the MPEG video stream format
%  and returns it.  It allocates the memory necessary for the new Image
%  structure and returns a pointer to the new image.
%
%  The format of the ReadMPEGImage method is:
%
%      Image *ReadMPEGImage(const ImageInfo *image_info,
%        ExceptionInfo *exception)
%
%  A description of each parameter follows:
%
%    o image_info: the image info.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static Image *ReadMPEGImage(const ImageInfo *image_info,
                            ExceptionInfo *exception)
{
#define ReadMPEGIntermediateFormat "pam"

    Image
    *image,
    *images;

    ImageInfo
    *read_info;

    MagickBooleanType
    status;

    /*
      Open image file.
    */
    assert(image_info != (const ImageInfo *) NULL);
    assert(image_info->signature == MagickSignature);
    if (image_info->debug != MagickFalse)
        (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
                              image_info->filename);
    assert(exception != (ExceptionInfo *) NULL);
    assert(exception->signature == MagickSignature);
    image=AcquireImage(image_info);
    status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
    if (status == MagickFalse)
    {
        image=DestroyImageList(image);
        return((Image *) NULL);
    }
    (void) CloseBlob(image);
    (void) DestroyImageList(image);
    /*
      Convert MPEG to PAM with delegate.
    */
    read_info=CloneImageInfo(image_info);
    image=AcquireImage(image_info);
    (void) InvokeDelegate(read_info,image,"mpeg:decode",(char *) NULL,exception);
    image=DestroyImage(image);
    (void) FormatMagickString(read_info->filename,MaxTextExtent,"%s.%s",
                              read_info->unique,ReadMPEGIntermediateFormat);
    images=ReadImage(read_info,exception);
    (void) RelinquishUniqueFileResource(read_info->filename);
    read_info=DestroyImageInfo(read_info);
    return(images);
}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:75,代码来源:mpeg.c

示例9: assert

/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   R e a d T I L E I m a g e                                                 %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  ReadTILEImage tiles a texture on an image.  It allocates the
%  memory necessary for the new Image structure and returns a pointer to the
%  new image.
%
%  The format of the ReadTILEImage method is:
%
%      Image *ReadTILEImage(const ImageInfo *image_info,
%        ExceptionInfo *exception)
%
%  A description of each parameter follows:
%
%    o image_info: the image info.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static Image *ReadTILEImage(const ImageInfo *image_info,
  ExceptionInfo *exception)
{
  Image
    *image,
    *tile_image;

  ImageInfo
    *read_info;

  /*
    Initialize Image structure.
  */
  assert(image_info != (const ImageInfo *) NULL);
  assert(image_info->signature == MagickSignature);
  if (image_info->debug != MagickFalse)
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
      image_info->filename);
  assert(exception != (ExceptionInfo *) NULL);
  assert(exception->signature == MagickSignature);
  read_info=CloneImageInfo(image_info);
  SetImageInfoBlob(read_info,(void *) NULL,0);
  *read_info->magick='\0';
  tile_image=ReadImage(read_info,exception);
  read_info=DestroyImageInfo(read_info);
  if (tile_image == (Image *) NULL)
    return((Image *) NULL);
  image=AcquireImage(image_info,exception);
  if ((image->columns == 0) || (image->rows == 0))
    ThrowReaderException(OptionError,"MustSpecifyImageSize");
  if (*image_info->filename == '\0')
    ThrowReaderException(OptionError,"MustSpecifyAnImageName");
  image->colorspace=tile_image->colorspace;
  image->alpha_trait=tile_image->alpha_trait;
  if (image->alpha_trait == BlendPixelTrait)
    (void) SetImageBackgroundColor(image,exception);
  (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
  if (LocaleCompare(tile_image->magick,"PATTERN") == 0)
    {
      tile_image->tile_offset.x=0;
      tile_image->tile_offset.y=0;
    }
  (void) TextureImage(image,tile_image,exception);
  tile_image=DestroyImage(tile_image);
  if (image->colorspace == GRAYColorspace)
    image->type=GrayscaleType;
  return(GetFirstImageInList(image));
}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:75,代码来源:tile.c

示例10: ReadImage

GLuint Mesh::LoadTexture(char* Filename)
{
	GLint iWidth, iHeight, iComponents;
	GLubyte* m_pImage = ReadImage(Filename, GL_FALSE, &iWidth, &iHeight, &iComponents);
	GLuint m_textureObj;
	
	if(!m_pImage)return false;
    glGenTextures(1, &m_textureObj);
    glBindTexture(GL_TEXTURE_2D, m_textureObj);
    //glTexImage2D(m_textureTarget, 0, GL_RGB, m_pImage->columns(), m_pImage->rows(), 0, GL_RGBA, GL_UNSIGNED_BYTE, m_blob.data());
	glTexImage2D(GL_TEXTURE_2D, 0, iComponents, iWidth, iHeight, 0, iComponents, GL_UNSIGNED_BYTE, m_pImage);
	//gluBuild2DMipmaps(m_textureTarget, iComponents, iWidth, iHeight, iComponents, GL_UNSIGNED_BYTE, m_pImage);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);	
	return m_textureObj;
}
开发者ID:miguel28,项目名称:WatchDog,代码行数:16,代码来源:mesh.cpp

示例11: ReadImage

   static bool ReadImage( FileFormatInstance* instance, I& image )
   {
      if ( !image.IsShared() )
      {
         I tmp( (void*)0, 0, 0 );
         if ( !ReadImage( instance, tmp ) )
            return false;
         image.Assign( tmp );
         return true;
      }

      if ( (*API->FileFormat->ReadImage)( instance->handle, image.Allocator().Handle() ) == api_false )
         return false;
      image.Synchronize();
      return true;
   }
开发者ID:aleixpuig,项目名称:PCL,代码行数:16,代码来源:FileFormatInstance.cpp

示例12: assert

/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   R e a d T I L E I m a g e                                                 %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Method ReadTILEImage tiles a texture on an image.  It allocates the
%  memory necessary for the new Image structure and returns a pointer to the
%  new image.
%
%  The format of the ReadTILEImage method is:
%
%      Image *ReadTILEImage(const ImageInfo *image_info,ExceptionInfo *exception)
%
%  A description of each parameter follows:
%
%    o image:  Method ReadTILEImage returns a pointer to the image after
%      reading.  A null image is returned if there is a memory shortage or
%      if the image cannot be read.
%
%    o image_info: Specifies a pointer to a ImageInfo structure.
%
%    o exception: return any errors or warnings in this structure.
%
%
*/
static Image *ReadTILEImage(const ImageInfo *image_info,
  ExceptionInfo *exception)
{
  Image
    *image,
    *tile_image;

  ImageInfo
    *clone_info;

  RectangleInfo
    geometry;
    

  /*
    Initialize Image structure.
  */
  assert(image_info != (const ImageInfo *) NULL);
  assert(image_info->signature == MagickSignature);
  assert(exception != (ExceptionInfo *) NULL);
  assert(exception->signature == MagickSignature);

  clone_info=CloneImageInfo(image_info);
  clone_info->blob=(void *) NULL;
  clone_info->length=0;
  *clone_info->magick='\0';
  tile_image=ReadImage(clone_info,exception);
  DestroyImageInfo(clone_info);
  if (tile_image == (Image *) NULL)
    return((Image *) NULL);

  /*
    Adapt tile image to desired image type.
  */
  if (image_info->type != UndefinedType)
    (void) SetImageType(tile_image,image_info->type);

  /*
    Create tiled canvas image.
  */
  (void) GetGeometry(image_info->size,&geometry.x,&geometry.y,&geometry.width,
                     &geometry.height);
  image=ConstituteTextureImage(geometry.width,geometry.height,tile_image,exception);

  DestroyImage(tile_image);
  return(image);
}
开发者ID:CliffsDover,项目名称:graphicsmagick,代码行数:78,代码来源:tile.c

示例13: ReadImage

    //--------------------------------------------------------------
    Image::Ptr ReadImage(const std::string& filename, FileFormat::Enum ff, PixelFormat::Enum pf)
    {
        File::Ptr file = OpenFile(filename);

        if (!file) {
            return 0;
        }

        if (ff == FileFormat::AutoDetect) {
            ff = GetFileFormat(filename);
            if (ff == FileFormat::Unknown) {
                ff = FileFormat::AutoDetect;
            }
        }

        return ReadImage(file, ff, pf);
    }
开发者ID:kyuu,项目名称:azura,代码行数:18,代码来源:azura.cpp

示例14: ReadEXR

static bool ReadEXR(const char *name, float **rgba, int *width, int *height) {
    Point2i res;
    std::unique_ptr<RGBSpectrum[]> image = ReadImage(name, &res);
    if (!image) return false;
    *width = res.x;
    *height = res.y;
    *rgba = new float[4 * *width * *height];
    for (int i = 0; i < *width * *height; ++i) {
        Float rgb[3];
        image[i].ToRGB(rgb);
        for (int c = 0; c < 3; ++c) {
            (*rgba)[4 * i + c] = rgb[c];
        }
        (*rgba)[4 * i + 3] = 1.;
    }
    return true;
}
开发者ID:NickYang,项目名称:pbrt-v3,代码行数:17,代码来源:exravg.cpp

示例15: FormatLabel

static void FormatLabel(ImageInfo *image_info,char *label,
  const unsigned int width,unsigned int *font_height)
{
  Image
    *image;

  MonitorHandler
    handler;

  register char
    *p,
    *q;

  if (label == (const char *) NULL)
    return;
  if (*label == '\0')
    return;
  if (strchr(label,'\n') != (char *) NULL)
    return;
  /*
    Format label to fit within a specified width.
  */
  handler=SetMonitorHandler((MonitorHandler) NULL);
  p=label;
  for (q=p+1; *q != '\0'; q++)
  {
    (void) strcpy(image_info->filename,"label:");
    (void) strncat(image_info->filename+6,p,(int) (q-p+1));
    image=ReadImage(image_info);
    if (image == (Image *) NULL)
      break;
    if (image->columns > width)
      {
        while (!isspace((int) (*q)) && (q > p))
          q--;
        if (q == p)
          break;
        *q='\n';
        p=q+1;
      }
    if (image->rows > *font_height)
      *font_height=image->rows;
    DestroyImage(image);
  }
  (void) SetMonitorHandler(handler);
}
开发者ID:vgck,项目名称:opendr2,代码行数:46,代码来源:montage.c


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