%pylab inline
rcParams['figure.figsize'] = (10, 4) #wide graphs by default
from __future__ import print_function
from __future__ import division
from scipy.signal import correlate2d
Populating the interactive namespace from numpy and matplotlib
i = imread('22.png')
i = sum(i.astype(float), axis=2)/4.0
i = where(i > 0.9, -1, 1)
imshow(i, cmap='gray')
<matplotlib.image.AxesImage at 0x110a9ba50>
o = imread('7.png')
o = o.astype(float).sum(axis=-1)/3
o = where(o > 0.9, -1, 1)
imshow(o, cmap=cm.gray, interpolation='nearest')
<matplotlib.image.AxesImage at 0x1232a3bd0>
from scipy.signal import correlate2d
from scipy.ndimage.filters import maximum_filter
cc = correlate2d(i, o)
imshow(cc, cmap = 'gray')
colorbar()
gcf().set_figheight(8)
subplot(131)
imshow(where(cc > 1000, 1, 0), interpolation='nearest', cmap=cm.gray)
subplot(132)
imshow(i, cmap=cm.gray)
subplot(133)
imshow(maximum_filter(cc, (10,10)))
<matplotlib.image.AxesImage at 0x124e43510>
o = imread('6.png')
o = o.astype(float).sum(axis=-1)/3
o = where(o > 0.9, -1, 1)
imshow(o, cmap=cm.gray, interpolation='nearest')
<matplotlib.image.AxesImage at 0x125f08050>
from scipy.signal import correlate2d
cc = correlate2d(i, o)
imshow(cc, cmap = 'gray')
colorbar()
gcf().set_figheight(8)
subplot(131)
imshow(where(cc > 950, 1, 0), interpolation='nearest', cmap=cm.gray)
subplot(132)
imshow(i, cmap=cm.gray)
subplot(133)
imshow(maximum_filter(cc, (10,10)))
<matplotlib.image.AxesImage at 0x126801b50>
o = imread('3.png')
o = o.astype(float).sum(axis=-1)/3
o = where(o > 0.9, -1, 1)
imshow(o, cmap=cm.gray, interpolation='nearest')
<matplotlib.image.AxesImage at 0x12110ef50>
cc = correlate2d(i, o)
imshow(cc, cmap = 'gray')
colorbar()
gcf().set_figheight(8)
subplot(131)
imshow(where(cc > 800, 1, 0), interpolation='nearest', cmap=cm.gray)
subplot(132)
imshow(i, cmap=cm.gray)
subplot(133)
imshow(maximum_filter(cc, (10,10)))
<matplotlib.image.AxesImage at 0x121b986d0>
o = imread('4.png')
o = o.astype(float).sum(axis=-1)/3
o = where(o > 0.9, -1, 1)
imshow(o, cmap=cm.gray, interpolation='nearest')
<matplotlib.image.AxesImage at 0x1215f0ed0>
cc = correlate2d(i, o)
imshow(cc, cmap = 'gray')
colorbar()
gcf().set_figheight(8)
subplot(131)
imshow(where(cc > 800, 1, 0), interpolation='nearest', cmap=cm.gray)
subplot(132)
imshow(i, cmap=cm.gray)
subplot(133)
imshow(maximum_filter(cc, (10,10)))
<matplotlib.image.AxesImage at 0x1228b03d0>