Uses median filter to reduce image noise.

@param int $maskWidth Width of the median mask (default: 3)
@param int $maskHeight Height of the median mask (default: 3)
@return Image This image.
507390
public function useMedian($maskWidth = 3, $maskHeight = 3) {
		// initialize scanline buffer
		$scanLines = array();

		// precalculate some variables for better performance
		$maskWidth2 = (int)($maskWidth / 2);
		$maskHeight2 = (int)($maskHeight / 2);
		$maskMiddle = (int)(($maskWidth * $maskHeight) / 2);
		$maxY = $this->height - $maskHeight2;
		$maxX = $this->width - $maskWidth2;

		// scan every line of the image
		for($y = $maskHeight2; $y < $maxY; ++$y) {
			$medianY = $y + $maskHeight2;
			$maxI = $y + $maskHeight2 + 1;
			$minI = $y <= $maskHeight2 ? 0 : $y + 1;
			// cache few image lines in advance, to speed up further access.
			for($i = $minI; $i < $maxI; ++$i) {
				for($j = 0; $j < $this->width; ++$j) {
					$scanLines[$i][$j] = imagecolorat($this->image, $j, $i);
				}
			}
			// unset old image lines from the cache.
			unset($scanLines[$medianY - $maskHeight]);

			for($x = $maskWidth2; $x < $maxX; ++$x) {
				$medianX = $x + $maskWidth2;
				$median = array();
				for($n = 0; $n < $maskHeight; ++$n) {
					for($m = 0; $m < $maskWidth; ++$m) {
						$median[] = $scanLines[$medianY - $n][$medianX - $m];
					}
				}
				sort($median, SORT_NUMERIC);
				imagesetpixel($this->image, $x, $y, $median[$maskMiddle]);
			}
		}
		return $this;
	}
429799
function applyMask(mask) {
    var x, y, r3x, r3y;

    switch (mask) {
      case 0:
        for (y = 0; y < width; y++) {
          for (x = 0; x < width; x++) {
            if (!((x + y) & 1) && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 1:
        for (y = 0; y < width; y++) {
          for (x = 0; x < width; x++) {
            if (!(y & 1) && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 2:
        for (y = 0; y < width; y++) {
          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) r3x = 0;

            if (!r3x && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 3:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) r3y = 0;

          for (r3x = r3y, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) r3x = 0;

            if (!r3x && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 4:
        for (y = 0; y < width; y++) {
          for (r3x = 0, r3y = ((y >> 1) & 1), x = 0; x < width; x++, r3x++) {
            if (r3x === 3) {
              r3x = 0;
              r3y = !r3y;
            }

            if (!r3y && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 5:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) r3y = 0;

          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) r3x = 0;

            if (!((x & y & 1) + !(!r3x | !r3y)) && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 6:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) r3y = 0;

          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) r3x = 0;

            if (!(((x & y & 1) + (r3x && (r3x === r3y))) & 1) && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 7:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) r3y = 0;

          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) r3x = 0;

            if (!(((r3x && (r3x === r3y)) + ((x + y) & 1)) & 1) && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
    }
  }
544222
public static INDArray reshapeTimeSeriesMaskToVector(INDArray timeSeriesMask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType) {
        if (timeSeriesMask.rank() != 2)
            throw new IllegalArgumentException("Cannot reshape mask: rank is not 2");

        if (timeSeriesMask.ordering() != 'f' || !Shape.hasDefaultStridesForShape(timeSeriesMask))
            timeSeriesMask = workspaceMgr.dup(arrayType, timeSeriesMask, 'f');

        return workspaceMgr.leverageTo(arrayType, timeSeriesMask.reshape('f', timeSeriesMask.length(), 1));
    }
812674
protected function applyIpMask(string $ip, int $maskLength): string
    {
        if (empty($ip) || $maskLength === 0) {
            return $ip;
        }

        // IPv4 or mapped IPv4 in IPv6
        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
            return $this->applyIpV4Mask($ip, $maskLength);
        }

        return $this->applyIpV6Mask($ip, $maskLength);
    }
634860
protected function resizeLandscape(ImageInterface $image, $width, $height)
    {
        // @codeCoverageIgnoreStart
        if (empty($width)) {
            throw new InvalidArgumentException(
                'Width value for portrait resize is empty. This may be caused by unfixed EXIF-rotated images.'
            );
        }
        // @codeCoverageIgnoreEnd

        $optimalHeight = $this->getSizeByFixedWidth($image, $width);

        $dimensions = $image->getSize()
            ->widen($width)
            ->heighten($optimalHeight);

        $image = $image->resize($dimensions);

        return $image;
    }
1069779
function maskString(srcStr, mask, start, length) {
      var str = String(srcStr), ptn = /[^\u4e00-\u9fa5]/mg, ptn_ = /[\u4e00-\u9fa5]/mg;
      if (isNum(mask)) {
        length = start, start = mask, mask = '*';
      } else if (!isStr(mask)) {
        mask = '*';
      }
      var maskStr = str.substr(start, length).replace(ptn, mask).replace(ptn_, mask + mask);
      return str.substr(0, start) + maskStr + (isUdf(length) ? '' : str.substr(start + length));
    }
599697
def buildMaskImage(rootname, bitvalue, output, extname='DQ', extver=1):
    

    # If no bitvalue is set or rootname given, assume no mask is desired
    # However, this name would be useful as the output mask from
    # other processing, such as MultiDrizzle, so return it anyway.
    #if bitvalue == None or rootname == None:
    #    return None

    # build output name
    maskname = output

    # If an old version of the maskfile was present, remove it and rebuild it.
    if fileutil.findFile(maskname):
        fileutil.removeFile(maskname)

    # Open input file with DQ array
    fdq = fileutil.openImage(rootname, mode='readonly', memmap=False)
    try:
        _extn = fileutil.findExtname(fdq, extname, extver=extver)
        if _extn is not None:
            # Read in DQ array
            dqarr = fdq[_extn].data
        else:
            dqarr = None

        # For the case where there is no DQ array,
        # create a mask image of all ones.
        if dqarr is None:
            # We need to get the dimensions of the output DQ array
            # Since the DQ array is non-existent, look for the SCI extension
            _sci_extn = fileutil.findExtname(fdq,'SCI',extver=extver)
            if _sci_extn is not None:
                _shape = fdq[_sci_extn].data.shape
                dqarr = np.zeros(_shape,dtype=np.uint16)
            else:
                raise Exception
        # Build mask array from DQ array
        maskarr = buildMask(dqarr,bitvalue)
        #Write out the mask file as simple FITS file
        fmask = fits.open(maskname, mode='append', memmap=False)
        maskhdu = fits.PrimaryHDU(data = maskarr)
        fmask.append(maskhdu)

        #Close files
        fmask.close()
        del fmask
        fdq.close()
        del fdq

    except:
        fdq.close()
        del fdq
        # Safeguard against leaving behind an incomplete file
        if fileutil.findFile(maskname):
            os.remove(maskname)
        _errstr = "\nWarning: Problem creating MASK file for "+rootname+".\n"
        #raise IOError, _errstr
        print(_errstr)
        return None

    # Return the name of the mask image written out
    return maskname
502468
def maskQuality(self, umi, umi_quals):
        ''''''
        masked_umi = mask_umi(umi, umi_quals,
                              self.quality_encoding,
                              self.quality_filter_mask)
        if masked_umi != umi:
            self.read_counts['UMI masked'] += 1
            return masked_umi
        else:
            return umi
426155
def mask_by_value(self, nodata):
        
        return self.copy_with(image=np.ma.masked_array(self.image.data, mask=self.image.data == nodata))
422508
def set_fixed_mask(self, image):
        
        if not isinstance(image, iio.ANTsImage):
            raise ValueError('image must be ANTsImage type')

        if image.dimension != self.dimension:
            raise ValueError('image dim (%i) does not match metric dim (%i)' % (image.dimension, self.dimension))

        self._metric.setFixedImage(image.pointer, True)
        self.fixed_mask = image
614860
public static String mask(final String mask, final String value)
    {
        return maskFormat(mask).format(value);
    }
145587
def interpret_maskval(paramDict):
    
    # interpret user specified final_maskval value to use for initializing
    # output SCI array...
    if 'maskval' not in paramDict:
        return 0
    maskval = paramDict['maskval']
    if maskval is None:
        maskval = np.nan
    else:
        maskval = float(maskval) # just to be clear and absolutely sure...
    return maskval
44335
public function setDefaultMessageMask($mask) {
        if(class_exists($mask)) {
            $this->default_message_mask = $mask;

            return $this;
        }

        throw new MaskNotFoundException("Unknown mask provided: ".$mask);
    }
691810
function initMasks() {
	var i, mask,
	    result = new Uint8Array( 0x10000 );

	for ( i = 0; i < 0x10000; i++ ) {
		mask = 3;
		if ( i & 0x2 ) {
			// right
			mask <<= 2;
		}
		if ( i & 0x40 ) {
			// bottom
			mask <<= 4;
		}

		result[ i ] = mask;
	}

	return result;
}
462532
public static function maskString($val, $mask)
    {
        if (empty($val)) {
            return $val;
        }
        $maskared = '';
        $k = 0;
        if (is_numeric($val)) {
            $val = sprintf('%0' . mb_strlen(preg_replace('/[^#]/', '', $mask)) . 's', $val);
        }
        for ($i = 0; $i <= mb_strlen($mask) - 1; $i++) {
            if ($mask[$i] == '#') {
                if (isset($val[$k])) {
                    $maskared .= $val[$k++];
                }
            } else {
                if (isset($mask[$i])) {
                    $maskared .= $mask[$i];
                }
            }
        }

        return $maskared;
    }
69618
public function getBannerImageSizeNew($oldWidth,$oldHeight,$newWidth=0,$newHeight=0)
	{
		$Width   = $oldWidth;  //Default, and flash require this
		$Height  = $oldHeight; //Default, and flash require this
		$oriSize = true;       //Attribute for images without conversion
		
		if ($newWidth > 0 && $newHeight > 0) 
		{
			$Width   = $newWidth;
			$Height  = $newHeight;
			$oriSize = false;
		}
		elseif ($newWidth > 0)
		{
			$Width   = $newWidth;
			$Height  = ceil($newWidth * $oldHeight / $oldWidth);
			$oriSize = false;
		}
		elseif ($newHeight > 0)
		{
			$Width   = ceil($newHeight * $oldWidth / $oldHeight);
			$Height  = $newHeight;
			$oriSize = false;
		}
		return array($Width,$Height,$oriSize);
	}
613576
private function getMaskNumber($matrixContent)
    {
        $mask   = new Mask($matrixContent, $this->getMaxModulesOneSide(), $this->getByteNumber());

        return $mask->getNumber();
    }