int BeautyCompetition(YsRawPngDecoder &image1,YsRawPngDecoder &image2) {//get input from user interface
    unsigned int m,n;
        
                        //calculate the grayscale of each iamge
            m=GrayScale(0,0,image1.wid,image1.hei,image1.wid,image1.rgba);


            n=GrayScale(0,0,image2.wid,image2.hei,image2.wid,image2.rgba);


    
    return Compare(m,n);                   //compare two scales and return a value
}
Example #2
0
void	OldPhoto(TiBitmapData& bitmap)
{
	//灰度化
	GrayScale(bitmap);

	//添加红色通道 减少蓝色通道 使得图片泛黄
	BalanceColor(bitmap,34,0,-87,TINYIMAGE_TRANSFERMODE_MIDTONES,false);
	
}
Example #3
0
shared_ptr<FrameState<Dtype> > Environment<Dtype>::GetFrame() {
  CHECK( !GameOver() );
  const ALEScreen & screen = ale_->getScreen();
  
  CHECK_EQ( screen.height(), SCREEN_HEIGHT );
  CHECK_EQ( screen.width(), SCREEN_WIDTH );
  GetFrameGrayScale( screen.getArray() );
  
  const double xRatio = (double)SCREEN_HEIGHT / CROP_HEIGHT;    
  const double yRatio = (double)SCREEN_WIDTH / CROP_WIDTH;
  
  static Dtype pixels[CROP_SIZE];
  for ( int i = 0; i < CROP_HEIGHT; ++i ) {
    for ( int j = 0; j < CROP_WIDTH; ++j ) {
      int xL = int(i * xRatio);
      int xR = int((i + 1) * xRatio);
      int yL = int(j * yRatio);
      int yR = int((j + 1) * yRatio);
      double result = 0.0;
#define GET_WEIGHT( i, x, ratio, l, r, weight ) \
  weight = 1.0; \
  if ( x == l ) weight = x + 1 - i * ratio; \
  else if ( x == r ) weight = (i + 1) * ratio - x; \
  CHECK_LE( 0.0, weight ); \
  CHECK_LE( weight, 1.0 );
      double xWeight, yWeight;
      for ( int x = xL; x <= xR; ++x ) {
        GET_WEIGHT( i, x, xRatio, xL, xR, xWeight );
        for ( int y = yL; y <= yR; ++y ) {
          GET_WEIGHT( j, y, yRatio, yL, yR, yWeight );
          Dtype grayScale = GrayScale( x, y );
          result += (xWeight / xRatio) * (yWeight / yRatio) * grayScale;
        }
      }
#undef GET_WEIGHT
      pixels[i * CROP_WIDTH + j] = result;
    }
  }
  FrameState<Dtype>* frame = new FrameState<Dtype>( pixels, CROP_SIZE );
  //frame->inspect( "Environment::Getframe" );
  return shared_ptr<FrameState<Dtype> >( frame );
}