static image<uchar> *imageRGBtoGRAY(image<rgb> *input) 
{
  int width = input->width();
  int height = input->height();
  image<uchar> *output = new image<uchar>(width, height, false);  for (int y = 0; y < height; y++)
  {
    for (int x = 0; x < width; x++)
{
      imRef(output, x, y) = (uchar)((( rgb *)imPtr(output, x, y))->r* RED_WEIGHT + (( rgb *)imPtr(output, x, y))->g * GREEN_WEIGHT +(( rgb *)imPtr(output, x, y))->b * BLUE_WEIGHT);
    }
  }
  return output;
}