2017-09-08 1 views
1

파이썬에서 회전 변환을 찾고 있는데, 원래 이미지를 반전시킬 수 있습니다. 나는 결과가이미지의 뒤집을 회전

,369과 같은 reflect를 사용하여 동일한 할 경우 지금까지 나는

import skimage.transform as tf 
import scipy 
im = scipy.misc.ascent() 

Original, unrotated image

r1 = tf.rotate(im, 10, mode='wrap') 

Image rotated 10 degrees

r2 = tf.rotate(r1, -10, mode='wrap') 

Rotated Image inversely rotated

을 사용하고 있습니다

Result using 'reflect'

possibilty은 angle하여 이미지를 회전하고 그 결과가 -angle에 의해 다시 회전 및 원본 이미지와 끝까지 간단하게 할 수 있습니까?

답변

1

문제의 가능한 해결책은 을 사용하고 resizeTrue으로 설정 한 다음 최종 결과를 자르는 것입니다. 원래의 화상 사이에 약간의 차이가있을 것이다

import skimage.transform as tf 
import scipy 
import matplotlib.pyplot as plt 

im = scipy.misc.ascent() 

r1 = tf.rotate(im, 10, mode='wrap', resize=True) 
plt.imshow(r1) 

r2 = tf.rotate(r1, -10, mode='wrap', resize=True) 
plt.imshow(r2) 

# Get final image by cropping 
imf = r2[int(np.floor((r2.shape[0] - im.shape[0])/2)):int(np.floor((r2.shape[0] + im.shape[0])/2)),int(np.floor((r2.shape[1] - im.shape[1])/2)):int(np.floor((r2.shape[1] + im.shape[1])/2))] 

plt.imshow(imf) 

인해 회전 기능의 내부 동작을 두 번 회전하지만 눈에 동일한 보인다.

+0

바로 그게 내가 찾고 있던 것입니다. 고맙습니다. 물론 보간으로 인해 이미지가 약간 다를 수 있지만 이것이 방법입니다. – Dschoni

관련 문제