function median (size) {
  if (!is.defined(size)) {
    // No arguments: default to 3x3
    this.options.medianSize = 3;
  } else if (is.integer(size) && is.inRange(size, 1, 1000)) {
    // Numeric argument: specific sigma
    this.options.medianSize = size;
  } else {
    throw is.invalidParameterError('size', 'integer between 1 and 1000', size);
  }
  return this;
}
Apply median filter.
When used without parameters the default window is 3x3.

@example
const output = await sharp(input).median().toBuffer();

@example
const output = await sharp(input).median(5).toBuffer();

@param {number} [size=3] square mask size: size x size
@returns {Sharp}
@throws {Error} Invalid parameters