print "Usage: python time.py '1D'|'2D'" exit(1) method = argv[1] Image = imread("cameraman.png") timings = zeros((20)) timings[0] = 0 repeat = 3 temp = zeros((repeat)) if method == "2D": for i in xrange(1, 20): for j in xrange(0, repeat): start = time() Gs = gauss(i) G = convolve(Image, Gs, mode="nearest") stop = time() temp[j] = stop - start timings[i] = average(temp) elif method == "1D": for i in xrange(1, 20): for j in xrange(0, repeat): start = time() Gsx = gauss1(i, f1) G2 = convolve1d(Image, Gsx, axis=0, mode="nearest") G2 = convolve1d(G2, Gsx, axis=1, mode="nearest") stop = time() temp[j] = stop - start timings[i] = average(temp) else:
from mpl_toolkits.mplot3d import Axes3D from sys import argv, exit from gaussian_functions import gauss, gauss1, gD, f1, f1_1, f1_2 if len(argv) != 4: print "Usage: python gauss.py s '1D'|'2D'|'gD' 1|0 (1 shows output \ images, 0 does not)" exit(1) s = float(argv[1]) method = argv[2] show_out = int(argv[3]) Image = imread('cameraman.png') if method == '2D': Gs = gauss(s) G = convolve(Image, Gs, mode='nearest') elif method == '1D': Gsx = gauss1(s, f1) G2 = convolve1d(Image, Gsx, axis=0, mode='nearest') G2 = convolve1d(G2, Gsx, axis=1, mode='nearest') elif method == 'gD': iorder = 2 jorder = 2 result = gD(Image, s, iorder, jorder) else: print "Invalid method" exit(1) if show_out == 1: if method == '2D':