Gets the correction angle based on the image's orientation
977591
private int getRotationAngle(final ExifInterface exifInterface) {
    return JfifUtil.getAutoRotateAngleFromOrientation(
        Integer.parseInt(exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION)));
  }
964659
def exif_orientation(im):
    
    try:
        exif = im._getexif()
    except Exception:
        # There are many ways that _getexif fails, we're just going to blanket
        # cover them all.
        exif = None
    if exif:
        orientation = exif.get(0x0112)
        if orientation == 2:
            im = im.transpose(Image.FLIP_LEFT_RIGHT)
        elif orientation == 3:
            im = im.transpose(Image.ROTATE_180)
        elif orientation == 4:
            im = im.transpose(Image.FLIP_TOP_BOTTOM)
        elif orientation == 5:
            im = im.transpose(Image.ROTATE_270).transpose(Image.FLIP_LEFT_RIGHT)
        elif orientation == 6:
            im = im.transpose(Image.ROTATE_270)
        elif orientation == 7:
            im = im.transpose(Image.ROTATE_90).transpose(Image.FLIP_LEFT_RIGHT)
        elif orientation == 8:
            im = im.transpose(Image.ROTATE_90)
    return im
415175
function getBackgroundPositionInPercent(image) {
	var x = 100 * (image.coordinates.x) / (image.properties.width - image.coordinates.width);
	var y = 100 * (image.coordinates.y) / (image.properties.height - image.coordinates.height);
	var template = _.template('<%= (x ? x + "%" : x) %> <%= (y ? y + "%" : y) %>');
	return template({x: x, y: y});
}
1355866
def angle(self, v):
        ''''''
        return acos((self * v) / (self.length() * v.length()))
86334
def get_rotated(self, angle):
        
        result = self.copy()
        result.rotate(angle)
        return result
823862
public function correctOrientation()
    {
        try {
            $exif = exif_read_data($this->file);
        } catch (\Exception $e) {
            return $this;
        }
        if (!empty($exif['Orientation'])) {
            switch ($exif['Orientation']) {
                case 8:
                    $this->image = imagerotate($this->image, 90, 0);
                    break;
                case 3:
                    $this->image = imagerotate($this->image, 180, 0);
                    break;
                case 6:
                    $this->image = imagerotate($this->image, -90, 0);
                    break;
            }
        }
        return $this;
    }
655557
def get_image_ratio(self, image):
        
        x, y = self.get_image_size(image)
        return float(x) / y
495529
def correct(self, image, keepSize=False, borderValue=0):
        '''
        
        '''
        image = imread(image)
        (h, w) = image.shape[:2]
        mapx, mapy = self.getUndistortRectifyMap(w, h)
        self.img = cv2.remap(image, mapx, mapy, cv2.INTER_LINEAR,
                             borderMode=cv2.BORDER_CONSTANT,
                             borderValue=borderValue
                             )
        if not keepSize:
            xx, yy, ww, hh = self.roi
            self.img = self.img[yy: yy + hh, xx: xx + ww]
        return self.img
186008
def image_coordinates(self, point):
        ''''''
        # the dragpos is the top left position in image coordinates
        ret = wx.Point(int(self.dragpos.x + point.x/self.zoom),
                       int(self.dragpos.y + point.y/self.zoom))
        return ret
271037
def apparent_dip_correction(axes):
    
    a1 = axes[0].copy()
    a1[-1] = 0
    cosa = angle(axes[0],a1,cos=True)
    _ = 1-cosa**2
    if _ > 1e-12:
        sina = N.sqrt(_)
        if cosa < 0:
            sina *= -1
        # Construct rotation matrix
        R= N.array([[cosa,sina],[-sina,cosa]])
    else:
        # Small angle, don't bother
        # (small angles can lead to spurious results)
        R = N.identity(2)
    #if axes[0,0] < 0:
    #    return R.T
    #else:
    return R
78427
public static int getOrientation(InputStream is) {
    try {
      int length = moveToAPP1EXIF(is);
      if (length == 0) {
        return ExifInterface.ORIENTATION_UNDEFINED;
      }
      return TiffUtil.readOrientationFromTIFF(is, length);
    } catch (IOException ioe) {
      return ExifInterface.ORIENTATION_UNDEFINED;
    }
  }
1260623
def pmt_angles(self):
        """"""
        if self._pmt_angles == []:
            mask = (self.pmts.du == 1) & (self.pmts.floor == 1)
            self._pmt_angles = self.pmts.dir[mask]
        return self._pmt_angles
108995
def get_orientation_degrees(self):
        

        orientation = self.get_orientation_radians()
        for key, val in orientation.items():
            deg = math.degrees(val)  # Result is -180 to +180
            orientation[key] = deg + 360 if deg < 0 else deg
        return orientation
779369
private function tiltAndCompare(Image $otherImage, $minAngle = -20, $maxAngle = 20, $backgroundColor = 0xffffff, &$minDimension) {
		if($minAngle > $maxAngle) {
			$tmp = $maxAngle;
			$maxAngle = $minAngle;
			$minAngle = $tmp;
		}

		$quantization = new Quantizator();
		$vector = $otherImage->getVector(new Point(0, 0), $otherImage->getDimensions(), false, 0);
		//$vector->normalize();
		$quantization->addGlyph($vector, 1);
		$otherImageDimensions = $otherImage->getDimensions();

		$foundObject = $this;
		$minDimension = 1000000000000;

		for($angle = $minAngle; $angle <= $maxAngle; $angle += 1) {
			$copy = $this->getCopy();
			$copy->rotate($angle, $backgroundColor);
			// find object in object - this is a smart autocropping of binary images.
			//$objects = $copy->findObjects();
			$objects[0] = $copy;
			// we want only the first detected object (only one should be detected anyway!;)
			list($width, $height) = $objects[0]->getSize();
			// object must be resized before quantization in order to match the other image dimensions.
			$objects[0]->resize($otherImageDimensions, null, false)->toBinary();
			$vector = $objects[0]->getVector(new Point(0, 0), $otherImageDimensions, false, 0);
			//$vector->normalize();
			$result = $quantization->findNearestEuklid($vector);
			if($result[1] < $minDimension) {
				$minDimension = $result[1];
				$foundObject = $objects[0];
			}
		}
		return $foundObject;
	}
456537
function(p1, p2) {

      var s = this['SCALE'];
      var angle = (TAU + Math.atan2(p2[1] - p1[1], p2[0] - p1[0])) % TAU;

      return angle / TAU * s;
    }
1221651
def validate_orientation(dicoms):
    
    first_image_orient1 = numpy.array(dicoms[0].ImageOrientationPatient)[0:3]
    first_image_orient2 = numpy.array(dicoms[0].ImageOrientationPatient)[3:6]
    for dicom_ in dicoms:
        # Create affine matrix (http://nipy.sourceforge.net/nibabel/dicom/dicom_orientation.html#dicom-slice-affine)
        image_orient1 = numpy.array(dicom_.ImageOrientationPatient)[0:3]
        image_orient2 = numpy.array(dicom_.ImageOrientationPatient)[3:6]
        if not numpy.allclose(image_orient1, first_image_orient1, rtol=0.001, atol=0.001) \
                or not numpy.allclose(image_orient2, first_image_orient2, rtol=0.001, atol=0.001):
            logger.warning('Image orientations not consistent through all slices')
            logger.warning('---------------------------------------------------------')
            logger.warning('%s %s' % (image_orient1, first_image_orient1))
            logger.warning('%s %s' % (image_orient2, first_image_orient2))
            logger.warning('---------------------------------------------------------')
            raise ConversionValidationError('IMAGE_ORIENTATION_INCONSISTENT')
459594
private void prepareForOutput(Polygon2D_F64 imageShape, Result result) {
		// the rotation estimate, apply in counter clockwise direction
		// since result.rotation is a clockwise rotation in the visual sense, which
		// is CCW on the grid
		int rotationCCW = (4-result.rotation)%4;
		for (int j = 0; j < rotationCCW; j++) {
			UtilPolygons2D_F64.shiftUp(imageShape);
		}

		// save the results for output
		FoundFiducial f = found.grow();
		f.id = result.which;

		for (int i = 0; i < 4; i++) {
			Point2D_F64 a = imageShape.get(i);
			undistToDist.compute(a.x, a.y, f.distortedPixels.get(i));
		}
	}