Skip to content

Project 3 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
276 changes: 276 additions & 0 deletions .ipynb_checkpoints/template_matching-checkpoint.ipynb

Large diffs are not rendered by default.

279 changes: 279 additions & 0 deletions .ipynb_checkpoints/wheres_waldo_final-checkpoint.ipynb

Large diffs are not rendered by default.

Binary file added __pycache__/imageprocessing.cpython-37.pyc
Binary file not shown.
44 changes: 44 additions & 0 deletions imageprocessing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import numpy as np
import math as mt

def sum_squared_error(D1, D2):
if(D1.shape == D2.shape):
return np.sum((((D1-np.mean(D1))/np.std(D1)) - ((D2-np.mean(D2))/np.std(D2)))**2)
else:
return np.inf

def gauss_kernal(size, var):
'''Returns a gauss kernal with the given size and variance'''

kernel = np.zeros(shape=(size,size))
for i in range(size):
for j in range(size):
kernel[i][j] = mt.exp( -((i - (size-1)/2)**2 + (j - (size-1)/2)**2 )/(2*var*var))

kernel = kernel / kernel.sum()

return kernel

def convolve(g,h):
'''Convolves image g with kernal h'''

I_gray_copy = g.copy()
x,y = h.shape
xl = int(x/2)
yl = int(y/2)
for i in range(xl,len(g[:,1])-xl):
for j in range(yl, len(g[i,:])-yl):

f = g[i-xl:i+(xl+1), j-yl:j+(yl+1)]

total = h*f

I_gray_copy[i][j] = sum(sum(total))

return I_gray_copy

def gauss_blur(image):
'''Returns the image blurred with a gauss kernel of variance 1'''
g_kernal = gauss_kernal(3,1)
g_blur = convolve(image, g_kernal)
return g_blur
Binary file added imageprocessing.pyc
Binary file not shown.
219 changes: 216 additions & 3 deletions template_matching.ipynb

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import matplotlib.pyplot as plt
import numpy as snp

image = plt.imread("waldo_1.jpg")
plt.imshow(image)
plt.show()
337 changes: 337 additions & 0 deletions wheres_waldo_final.ipynb

Large diffs are not rendered by default.