Play with some images. I want to make a point about the meaning of 'resolution'.
Let's say that these properties are the 3 horsemen of resolution.
import numpy as np
#from numpy.fft import fft, fftfreq
from scipy.fftpack import fft, rfft, irfft, fftfreq, rfftfreq
import scipy.signal
import matplotlib.pyplot as plt
%matplotlib inline
import scipy.ndimage
im = np.zeros((20, 20))
im[5:-5, 5:-5] = 1
im = scipy.ndimage.distance_transform_bf(im)
im_noise = im + 0.2 * np.random.randn(*im.shape)
im_med = scipy.ndimage.median_filter(im_noise, 3)
plt.imshow(im_med, interpolation="none", cmap="Greys")
plt.show()
Start by reading the red channel of an astronomical photograph from a file.
m32 = scipy.ndimage.imread("m32.jpg")[...,0]
m32.shape
(866, 866)
plt.imshow(m32, interpolation="none", cmap="gray")
<matplotlib.image.AxesImage at 0x111f19050>
m32_med = scipy.ndimage.median_filter(m32, 5)
plt.imshow(m32_med, interpolation="none", cmap="Greys")
plt.show()
m32_gss = scipy.ndimage.gaussian_filter(m32, 5)
plt.imshow(m32_gss, interpolation="none", cmap="Greys")
plt.show()
m32.shape
(866, 866)
m32
array([[ 7, 6, 5, ..., 24, 25, 24], [ 9, 5, 2, ..., 31, 27, 28], [10, 8, 4, ..., 28, 21, 26], ..., [16, 15, 17, ..., 40, 49, 49], [17, 23, 33, ..., 41, 46, 46], [17, 24, 34, ..., 43, 46, 46]], dtype=uint8)
Let's look for another image
import requests
from StringIO import StringIO
from PIL import Image
a = requests.get("http://svs.gsfc.nasa.gov/vis/a010000/a010400/a010485/M31_Wide.jpg")
m31 = np.array(Image.open(StringIO(a.content))) # ndimage can't work with this object
plt.imshow(m31)
<matplotlib.image.AxesImage at 0x11629afd0>
m32 = m31[5200:6000,3700:4500,0]
plt.imshow(m32, interpolation="none", cmap="gray")
<matplotlib.image.AxesImage at 0x1163ec390>