Beispiel #1
0
void DrImage::Cut(){
  char cImage[160];
  sprintf(cImage,"Small.png");
  double pixel[4];
  double xBound[2] = {.5,.75};
  double yBound[2] = {.2,.45};
  int xNBound[2];
  int yNBound[2];
  for(int d=0;d<2;d++){
    xNBound[d] = (int)(xBound[d]*NWidth);
    yNBound[d] = (int)(yBound[d]*NHeight);
    printf("%d %d %d %d\n",xNBound[d],NWidth,yNBound[d],NHeight);
  }
  int Dx = xNBound[1]-xNBound[0];
  int Dy = yNBound[1]-yNBound[0];
  double *Plot = new double[Dx*Dy];
  Matematica *Mat = new Matematica;
  //VarData *Var = new VarData;
  Matrice *ImIn = new Matrice(Dx,Dy);
  pngwriter ImageOut(xNBound[1]-xNBound[0],yNBound[1]-yNBound[0],1.0,cImage);
  double Average = 0.;
  double Count = 0.;
  for(int h=yNBound[0];h<yNBound[1];h++){
    for(int w=xNBound[0];w<xNBound[1];w++){
      int hh = h -yNBound[0];
      int ww = w -xNBound[0];
      double Sum = data[0][h*NWidth+w]+data[1][h*NWidth+w]+data[2][h*NWidth+w];
      //Sum *= .5;
      // ImageOut.plot(ww,hh,data[0][h*NWidth+w],data[1][h*NWidth+w],data[2][h*NWidth+w]);
      ImIn->Set(ww,hh,Sum);
      Plot[hh*Dx+ww] = Sum;
    }
  }


  for(int h=0;h<Dy;h++){
    for(int w=0;w<Dx;w++){
      //if(ImIn->Val(w,h) >= 0.)
      ImageOut.plot(w,h,10.*ImIn->Val(w,h),ImIn->Val(w,h),ImIn->Val(w,h));
    }
  }
  ImageOut.close();
  delete [] Plot;
}