Skip to main content

How to change pixel size of an image

In [1]:
import numpy as np
import matplotlib.pyplot as plt
import pyfits
from scipy.ndimage.filters import gaussian_filter as gf

from scipy import interpolate'ggplot')
def Resample(data1,pixel_size_1,pixel_size_2):

 len_X = len(data1[1,:])
 len_Y = len(data1[:,1])
 p = pixel_size_2/pixel_size_1
 xnew = np.arange(0, len_X, p)
 ynew = np.arange(0,len_Y,p)
 f= interpolate.interp2d(np.arange(len_X), np.arange(len_Y),data1, kind='linear')
 resamp_data1 = f(xnew,ynew)
 return resamp_data1, resamp_data1.shape
In [ ]: