code: function(threshold) {
        var source = this.getSource(),
            average = (source[0] * 0.3 + source[1] * 0.59 + source[2] * 0.11).toFixed(0),
            currentAlpha = source[3],
            threshold = threshold || 127;
  
        average = (Number(average) < Number(threshold)) ? 0 : 255;
        this.setSource([average, average, average, currentAlpha]);
        return this;
      }
docs: Transforms color to its black and white representation
  @method toGrayscale
  @return {fabric.Color} thisArg