In [2]:
from photutils import Background2D, SigmaClip, MedianBackground
from skimage import color
from skimage import exposure
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [4]:
afmdata = np.genfromtxt('../NaRWHAL/Data/UnbackgroundedTXT/500nmGood-0')
afmdata= afmdata*(10**9)
height, width = afmdata.shape
In [5]:
plt.matshow(afmdata, origin='lower', cmap = 'viridis')
Out[5]:
In [6]:
sigma_clip = SigmaClip(sigma=3., iters=10)
bkg_estimator = MedianBackground()
bkg = Background2D(afmdata, (50, 50), filter_size=(3, 3), sigma_clip=sigma_clip, bkg_estimator=bkg_estimator)
In [7]:
plt.matshow(bkg.background, origin='lower', cmap = 'viridis')
Out[7]:
In [8]:
plt.matshow(afmdata - bkg.background, origin='lower', cmap = 'viridis')
Out[8]:
In [9]:
### This is the Backgrounded image shown two frames up. The frame below is super pale because I'm working
### on the histogram normalization
backgrounded = afmdata - bkg.background
plt.matshow(backgrounded, origin = 'lower', cmap = 'viridis')
Out[9]:
In [11]:
sigma_clip = SigmaClip(sigma=3., iters=10)
bkg_estimator = MedianBackground()
bkg1 = Background2D(backgrounded, (50, 50), filter_size=(3, 3), sigma_clip=sigma_clip, bkg_estimator=bkg_estimator)
In [12]:
plt.matshow(bkg1.background, origin='lower', cmap = 'viridis')
Out[12]:
In [13]:
plt.matshow(backgrounded - bkg1.background, origin='lower', cmap = 'viridis')
Out[13]:
In [ ]:
In [14]:
fig = plt.figure(figsize = (8, 8))
fig.add_subplot(131)
plt.matshow(afmdata, origin = 'lower', cmap = 'viridis')
plt.title('Raw Data File')
fig.add_subplot(132)
plt.matshow(backgrounded, origin = 'lower', cmap = 'viridis')
plt.title('Backgounded')
plt.show()
In [ ]:
In [ ]: