Пример #1
0
FeatureItem SIFT::CalculateSiftDescriptorFromFile( const string& filename, int gridSpacing, int patchSize, int maxImSize, float nrml_threshold )
{
	//Mat img = imread("009_0002.jpg", CV_LOAD_IMAGE_GRAYSCALE);

	try
	{
		Mat iplImg = imread(filename, 0 /*CV_LOAD_IMAGE_GRAYSCALE*/);
		//IplImage* GrayImage = cvCreateImage(cvGetSize(iplImg),IPL_DEPTH_8U,1);
		//cvCvtColor(iplImg,GrayImage,CV_RGB2GRAY);

		Mat result;
		iplImg.convertTo(result, CV_32FC1); /*cvCreateMat(iplImg->height,iplImg->width,CV_32FC1 );*/
		//cvConvert(GrayImage,mat);
		iplImg.release();

		Mat Img=im2double(result);
		result.release();
		printf("Loaded image %s\n", filename.c_str());

		return CalculateSiftDescriptor(Img, gridSpacing, patchSize, maxImSize, nrml_threshold);
	}catch (cv::Exception e)
	{
		printf("Exception happened in file %s\n",filename.c_str());
		printf("%s\n", e.msg.c_str());
		return FeatureItem();
	}
}
Пример #2
0
int main(int argc,char * argv[])
{

  if(argc != 2){
    printf("Input image name");
    exit(-1);
  }

  char *ifname;
  double *I;
  uint8_t *_I;
  unsigned int *L;
  double *E;
  uint8_t *_E;
  double *B;
  uint8_t *_B;
  unsigned int sy,sx,dim,mode;
  unsigned int npix,nelem;
  std::vector<point> sam;

  ifname = argv[1];
  imread(&_I,&sy,&sx,&dim,&mode,ifname);

  npix  = sy*sx;
  nelem = npix*dim;

  zeros( &I, nelem, "double" );
  zeros( &L, npix, "unsigned" );
  zeros( &E, nelem, "double" );
  zeros( &B, nelem, "double" );
  im2double(I,_I,nelem);

  binary(I,nelem);
  edge(I,E,B,sx,sy,dim);
  sample(sy,sx,B);

  zeros(&_E,nelem,"uint8");
  zeros(&_B,nelem,"uint8");
  im2uint8(_B,B,nelem);
  imwrite(_B,sy,sx,dim,mode,"../hack/hoge.pgm");

  return 0;
}