public function deskew($backgroundColor = -1, $precisionLevel = true, $debugMode = false) {
		// detect the background color
		if($backgroundColor < 0) {
			$backgroundColor = hexdec($this->getBackgroundColor(1, $precisionLevel === true)->getHexValue());
		}

		// calculate a Hough matrix and get the skew angle
        if($precisionLevel === false || $precisionLevel === 2) {
            $precisionLevel = 256;
        } else if($precisionLevel === 3) {
            $precisionLevel = 512;
        } else if($precisionLevel === 4) {
            $precisionLevel = 1024;
        } else {
            $precisionLevel = 128;
        }
        
		$angles = $this->getSkewAngle($debugMode ? 1 : 8, $precisionLevel, $debugMode);

		$this->rotate($angles[0]['degrees'], $backgroundColor);
		return $this;
	}