Ejemplo n.º 1
0
void PortraitCut::mutualInit() {
  //_cgradsComputed = false;
  _th_frame = NULL;
  _cuttype = C_NORMAL; //C_GRAD2; 


  indeces_a = (PtrImage) imNew(IMAGE_PTR, _w, _h);
  D_a = (DoubleImage) imNew(IMAGE_DOUBLE, _w, _h);


  
  //allocateComputeAllCGrads(); // 
}
void Match::InitSubPixel()
{
	if (params.sub_pixel && im_left && !im_left_min)
	{
		im_left_min  = (GrayImage) imNew(IMAGE_GRAY, im_size.x, im_size.y);
		im_left_max  = (GrayImage) imNew(IMAGE_GRAY, im_size.x, im_size.y);
		im_right_min = (GrayImage) imNew(IMAGE_GRAY, im_size.x, im_size.y);
		im_right_max = (GrayImage) imNew(IMAGE_GRAY, im_size.x, im_size.y);

		if (!im_left_min || !im_left_max || !im_right_min || !im_right_max)
		{ fprintf(stderr, "Not enough memory!\n"); exit(1); }

		SubPixel(im_left,  im_left_min,  im_left_max);
		SubPixel(im_right, im_right_min, im_right_max);
	}
	if (params.sub_pixel && im_color_left && !im_color_left_min)
	{
		im_color_left_min  = (RGBImage) imNew(IMAGE_RGB, im_size.x, im_size.y);
		im_color_left_max  = (RGBImage) imNew(IMAGE_RGB, im_size.x, im_size.y);
		im_color_right_min = (RGBImage) imNew(IMAGE_RGB, im_size.x, im_size.y);
		im_color_right_max = (RGBImage) imNew(IMAGE_RGB, im_size.x, im_size.y);

		if (!im_color_left_min || !im_color_left_max || !im_color_right_min || !im_color_right_max)
		{ fprintf(stderr, "Not enough memory!\n"); exit(1); }

		SubPixelColor(im_color_left,  im_color_left_min,  im_color_left_max);
		SubPixelColor(im_color_right, im_color_right_min, im_color_right_max);
	}
}
Ejemplo n.º 3
0
void PortraitCut::saveLabels(const char* name) {
  fprintf(_fp, "Trying to save file %s\n",name); fflush(_fp);
  GrayImage im = (GrayImage) imNew(IMAGE_GRAY, _w, _h);
  int i,  j,index=0;
  for (j=0; j<_h; j++)
    for (i=0; i<_w; i++, ++index) { 
      Coord p(i,j);
      IMREF(im,p) = (unsigned char) _labels[index];
    }

  imSave(im,name);
  imFree(im);
}
Ejemplo n.º 4
0
void PortraitCut::saveComp(char* name) {
  RGBImage im = (RGBImage) imNew(IMAGE_RGB, _w, _h);
    int i,  j,index=0;
  for (j=0; j<_h; j++)
    for (i=0; i<_w; i++, ++index) { 
      Coord p(i,j);
      unsigned char* cref = _imptr(_labels[index], p);
      IMREF(im,p).r = cref[0];
      IMREF(im,p).g = cref[1];
      IMREF(im,p).b = cref[2];
    }

  int res = imSave(im,name);
  assert(res==0);
  imFree(im);
}