code: public static int scanright(Color color, int height, int width, int col, PixelsExtractor f, int tolerance) {
          if (col == width || !PixelTools.colorMatches(color, tolerance, f.apply(new Area(col, 0, 1, height))))
              return col;
          else
              return scanright(color, height, width, col + 1, f, tolerance);
      }
docs: Starting with the given column index, will return the first column index
  which contains a colour that does not match the given color.