Beispiel #1
0
Image2<Vec2f> GradientSobel::gradient33(const Image2Grey& img_in) const
{
    Image2<Vec2f> img_out(img_in.getWidth(), img_in.getHeight());
    for(unsigned int x=0; x<img_in.getWidth(); x++)
    {
        for(unsigned int y=0; y<img_in.getHeight(); y++)
        {
            img_out.setPixel(_directionOf3(img_in, (int)x, (int)y), x, y);
        }
    }
    return img_out;
}
bool pat2img(const std::string & patfilein,
             const std::string & imgfileout) {
  std::vector<std::string> lines;
  StringUtils::retrieve_file_split(patfilein, lines);
  unsigned int nlines = lines.size(), row = 0;
  if (nlines == 0) {
    printf("Cant read '%s', file non existing or empty.\n", patfilein.c_str());
    return false;
  }

  // determine number of cols
  while (row < nlines && lines[row].size() > 0) {
    ++row;
  } // end loop row
  if (row % 3 != 0) {
    printf("The first empty line (#%i) is not a multiple of 3!\n", row);
  }
  unsigned int nrows = row / 3;
  printf("nrows:%i\n", nrows);

  // now read each line
  std::vector<int> r, g, b;
  cv::Mat3b img_out(nrows, nrows);
  img_out.setTo(0);
  for (row = 0; row < nrows; ++row) {
    cv::Vec3b* data = img_out.ptr<cv::Vec3b>(row);
    for (unsigned int col = 0; col < nrows; ++col) {
      if (!read_line(lines, row, nrows, r, g, b))
          continue;
      data[col][0] = b[col];
      data[col][1] = g[col];
      data[col][2] = r[col];
    } // end loop col
  } // end loop row
  cv::Mat3b img_big(256, 256);
  cv::resize(img_out, img_big, img_big.size(), 0, 0, CV_INTER_NN);

  printf("Written img '%s'\n", imgfileout.c_str());
  cv::imshow("img_big", img_big); cv::imshow("img_out", img_out); cv::waitKey(0);
  return true;
}
Beispiel #3
0
void main(void) {
byte i,bear_count,dog_count;

	M8C_DisableGInt;

	PORTA = 0x00;
	DDRA  = 0x00;
	PORTB = 0x00;
	DDRB  = 0x00;
	PORTC = 0x00; //m103 output only
	DDRC  = 0x00;
	PORTD = 0x00;
	DDRD  = 0x00;

	MCUCR = 0x00;
	GICR  = 0x00;

	GLCD_SHDN_Dir	|= GLCD_SHDN_bit;
	GLCD_RES_Dir	|= GLCD_RES_bit;

	GLCD_DC_Dir		|= GLCD_DC_bit;
	GLCD_CS_Dir		|= GLCD_CS_bit;
	GLCD_WR_Dir		|= GLCD_WR_bit;
	GLCD_EN_Dir		|= GLCD_EN_bit;

	GLCD_SHDN_oPort	&= ~GLCD_SHDN_bit;
	GLCD_RES_oPort	|= GLCD_RES_bit;

	GLCD_DC_oPort	&= ~GLCD_DC_bit;
	GLCD_CS_oPort	|= GLCD_CS_bit;
	GLCD_WR_oPort	|= GLCD_WR_bit;
	GLCD_EN_oPort	|= GLCD_EN_bit;

	OLED_interface = BS_iPort & (BS_2|BS_1);

	SPIM_1_Start(SPIM_1_SPIM_MODE_3); // Init
///	SPI1M_Speed(1); // 1-250, 2-62, 3-31
	SPI1M_Speed(0); // 1-250, 2-62, 3-31
	GLCD_Data_oPort = 0; GLCD_Data_Dir = 0;

	M8C_EnableGInt;
	GLCD_Data_Dir |= 0xFF;
	GLCD_WR_oPort &= ~GLCD_WR_bit;		// WR=0 - write
	oled_init();

	while (1) {
		bear_count++; if (bear_count >= 13) bear_count = 0;
		img_out(32,8,&bear[bear_count][0]);
		delay_ms(100);
		dog_count++;
		if (dog_count < 20) i = 0; else
		if (dog_count < 21) i = 1; else
		if (dog_count < 27) i = 2; else
		if (dog_count < 28) i = 3; else
		if (dog_count < 29) i = 4; else
		if (dog_count < 54) i = 5; else
		if (dog_count < 55) i = 6; else
		if (dog_count < 56) i = 7; else
		if (dog_count < 57) i = 7; else dog_count = 0;
		img_out(0,14,&dog[i][0]);
		delay_ms(100);
	}
}
Beispiel #4
0
int extract_images_from_pdf(char* filename,
                            char* target,
                            char* owner_password,
                            char* user_password,
                            char* range,
                            char* format,
                            int jpg_quality,
                            GBool dump_jpg,
                            GBool tiff_jpg)
{
    if (user_cancelled)
        return gpret_user_cancelled;

    // load config
    xpdf_rc xrc;

    // open file
    xpdf_doc xdoc(filename, owner_password, user_password);
    PDFDoc* doc = xdoc.get_doc();
    if (!doc->isOk())
        return doc->getErrorCode() == errEncrypted ?
               gpret_pdf_encrypted :
               gpret_cant_open_pdf;

    // check for copy permission
    // if (!doc->okToCopy())
    //	 return gpret_dont_allow_copy;

    // get page range
    page_range range_list(range);
    if (*range == '\0')
    {
        range_list.add_item(range_item(1, doc->getNumPages()));
    }

    if (user_cancelled)
        return gpret_user_cancelled;

    // write image files
    fi_loader fi;
    int progress = 0;
    image_extractor img_out(target, dump_jpg, format, jpg_quality, tiff_jpg);
    for (int i = 0; i < range_list.item_count(); i++)
    {
        range_item& item = range_list.get_item(i);
        for (int pg = item.first;
                pg <= min(item.last, doc->getNumPages());
                pg++)
        {
            if (user_cancelled)
                return gpret_user_cancelled;
            doc->displayPage(&img_out, pg, 72, 72, 0, gFalse, gTrue, gFalse);
            printf("progress: %d\n",
                   ++progress * 100 / range_list.page_count());
        }
    }

    printf("image count: %d\n", img_out.get_image_number());

    return gpret_success;
}
Beispiel #5
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[])
{
   
    double angs[3];
    const double *p_angs=mxGetPr(prhs[1]);
    angs[0]=(double)p_angs[0];
    angs[1]=(double)p_angs[1];
    angs[2]=(double)p_angs[2];

    Matrix1D<double> axis;
    getMatrix1D(prhs[2],axis);

    Matrix2D<double> A3D, A2D;
    
    bool wrap = (bool)mxGetScalar(prhs[5]);
    mwSize ndims = mxGetNumberOfDimensions(prhs[0]);
    

    /*mode: 1 euler, 2 align_with_Z, 3 axis, 4 tform*/
    switch ((int)mxGetScalar(prhs[3])) {
        case 1:
            Euler_angles2matrix(angs[0], angs[1], angs[2], A3D, true);
            break;
        case 2:
            alignWithZ(axis,A3D);
            break;
        case 3:
            rotation3DMatrix(angs[0], axis, A3D);
            A2D.resize(3,3);
            A2D(0,0)=A3D(0,0); A2D(0,1)=A3D(0,1); A2D(0,2)=A3D(0,2);
            A2D(1,0)=A3D(1,0); A2D(1,1)=A3D(1,1); A2D(1,2)=A3D(1,2);
            A2D(2,0)=A3D(2,0); A2D(2,1)=A3D(2,1); A2D(2,2)=A3D(2,2);
            break;
        case 4:
            getMatrix2D(prhs[6],A2D);
            A3D = A2D;
            break;
    }
    
    if (ndims == 2)
    {
        Image<double> img, img_out;
        getMatrix2D(prhs[0],img());
        if (MAT_XSIZE(A2D) != 0)
        {
			applyGeometry(BSPLINE3,img_out(), img(), A2D, IS_NOT_INV, wrap);
			setMatrix2D(img_out(),plhs[0]);
        }
        else 
        {
            setMatrix2D(img(),plhs[0]);
        }
    }
    else
    {
        Image<double> vol, vol_out;
        getMatrix3D(prhs[0],vol());
		applyGeometry(BSPLINE3, vol_out(), vol(), A3D, IS_NOT_INV, wrap);
		setMatrix3D(vol_out(),plhs[0]);
    }
}