# Multi-Photon Correlation Statistics¶

In [1]:
from PIL import Image as IM
import numpy as np
import random
import matplotlib.pyplot as plt

%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'



## Tuning Hyperparameters¶

In [2]:
# Load a standard photo

In [3]:
# Convert it to gray-scale image
im = im.convert("L")
plt.imshow(im, cmap = plt.cm.gray_r)
plt.show()

In [4]:
# Check image size
print(im.size)

(1024, 1024)

In [5]:
# rotate 0 degrees
rot = im.rotate(0)
plt.imshow(rot, cmap = plt.cm.gray_r)
plt.show()

In [6]:
# mask(left, upper, right, lower) CAUTION: Delta's should be ingeters!
mask = (445, 384, 625, 520)
plt.imshow(region, cmap = plt.cm.gray_r)
plt.show()

# Detailed check:

# Num of Rows and Cols
NUM_R, NUM_C = 4, 5
# Delta length of Height and Width
plt.title("first row")
plt.imshow(region.crop((0,0,DELTA_W*NUM_C,DELTA_H)), cmap = plt.cm.gray_r)
plt.show()
plt.title("first col")
plt.imshow(region.crop((0,0,DELTA_W,DELTA_H*NUM_R)), cmap = plt.cm.gray_r)
plt.show()
plt.title("last row")
plt.imshow(region.crop((0,DELTA_H*(NUM_R-1),DELTA_W*NUM_C,DELTA_H*NUM_R)), cmap = plt.cm.gray_r)
plt.show()
plt.title("last col")
plt.imshow(region.crop((DELTA_W*(NUM_C-1),0,DELTA_W*NUM_C,DELTA_H*NUM_R)), cmap = plt.cm.gray_r)
plt.show()

In [7]:
# Filters
from PIL import ImageFilter

def filter(img):
#     fimg = img.filter(ImageFilter.EDGE_ENHANCE)
fimg = img.filter(ImageFilter.MedianFilter(3))
#     fimg = fimg.filter(ImageFilter.SHARPEN)
return fimg

imfilter = filter(region)
plt.imshow(imfilter, cmap = plt.cm.gray_r)
plt.show()