Ejemplo n.º 1
0
/**
 * 
 * @param col
 * @param raw
 * @return 
 */
uint8_t AsciiFilter::findBestMatch(ADMImage *source,int col,int row,int &luma)
{
  int minDelta=0xfffffff;
  int candidate=-1;
  int stride=source->GetPitch (PLANAR_Y);
  uint8_t *p=source->GetReadPtr(PLANAR_Y)+col*REDUCE_WIDTH+row*REDUCE_HEIGHT*stride;
  // 1- create bitmask
  uint16_t bitMask[REDUCE_WIDTH*REDUCE_HEIGHT];
  createBitMask(bitMask,p,stride,luma);
  
  // 32..127
  for(int tries=32;tries<128;tries++)
    {
      int delta=computeDelta(tries,bitMask);
      if(delta<minDelta)
        {
          minDelta=delta;
          candidate=tries;
        }
    }
  if(candidate==-1) 
    {
      luma=128;
      return '*';
    }
  else 
    return candidate;
}
 unsigned int getNumberOfMasks() {
     return createBitMask(width * height);
 }