In [1]:
%run common.ipynb
from __future__ import division
img = smooth(img, 5).astype(int)
gimshow(img)
In [2]:
mask = [[ 1, 1, 1],
[ 1,-8, 1],
[ 1, 1, 1]]
lap_img = ndimage.convolve(img, mask)
view_lap = scale(lap_img)
lap_img[lap_img < 0] = 0
histshow(lap_img)
gimshow(lap_img, title="Laplace")
histshow(view_lap)
gimshow(view_lap, title="Scaled Laplace")
In [3]:
def f(threshold, c):
add_img = np.copy(lap_img)
add_img[add_img < threshold] = 0
add_img = scale(add_img)
add_img *= c
combined_img = img + add_img
gimshow(add_img)
gimshow(combined_img)
interact(f, threshold=(0,255,1), c=1.0)
In [100]:
lap2_img = np.zeros(img.shape)
ndimage.laplace(img, lap2_img)
lap2_img = lap2_img.astype(int)
view_lap2 = scale(lap2_img)
lap2_img[lap2_img < 0] = 0
histshow(lap2_img)
gimshow(lap2_img)
histshow(view_lap2)
gimshow(view_lap2)