Add rotate function
use OpenCV for fastest rotation
This commit is contained in:
parent
a240bf83e8
commit
17e0cc3fd8
1 changed files with 9 additions and 0 deletions
9
utils.py
9
utils.py
|
@ -1,4 +1,5 @@
|
|||
from astropy.io.fits import open
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
global_i = 0
|
||||
|
@ -202,3 +203,11 @@ def last_consecutive( list_ ):
|
|||
else: # if inside the consecutive list and last element, every element is consecutive
|
||||
break
|
||||
return i
|
||||
def rotate( image , angle ):
|
||||
"""
|
||||
rotate the following image by the given angle
|
||||
"""
|
||||
height , width = image.shape[ : 2 ]
|
||||
cX , cY = ( width // 2 , height // 2 )
|
||||
matrix = cv2.getRotationMatrix2D( ( cX , cY ) , angle , 1 )
|
||||
return cv2.warpAffine( image , matrix , ( width , height ) , flags = cv2.INTER_LINEAR )
|
||||
|
|
Loading…
Reference in a new issue