public function getVector(Point $position = null, Dimensions $size = null, $round = false, $colorMask = 0) {
		if($position === null) {
			$position = new Point(0, 0);
		}
		if($size === null) {
			$size = $this->getDimensions();
		}
		$x = $position->x;
		$y = $position->y;
		$width = $size->width;
		$height = $size->height;

		$components = array();
		$d = 0;
		$maxX = $x + $width;
		$maxY = $y + $height;

		for($i = $y; $i < $maxY && $i < $this->height; ++$i) {
			for($j = $x; $j < $maxX && $j < $this->width; ++$j) {
				$rgb = imagecolorat($this->image, $j, $i);
				if($colorMask === 0) {
					$pixel = ($rgb >> 16) & 0xff;
					$pixel += ($rgb >> 8) & 0xff;
					$pixel += $rgb & 0xff;
					$d = $pixel / 768;
				} else {
					$count = $d = 0;

					if(($colorMask & Channel::RED) > 0) {
						$d += ($rgb >> 16) & 0xff;
						++$count;
					}

					if(($colorMask & Channel::GREEN) > 0) {
						$d += ($rgb >> 8) & 0xff;
						++$count;
					}

					if(($colorMask & Channel::BLUE) > 0) {
						$d += $rgb & 0xff;
						++$count;
					}

					$d /= (256 * $count);
				}
				if($round === false) {
					$components[] = 1 - $d;
				} else {
					$components[] = 1 - round($d);
				}
			}
		}

		return new Vector(count($components), -1, $components);
	}