November 2018
Intermediate to advanced
492 pages
12h 19m
English
We can use the Python timeit module to compare the runtimes of the image domain and the frequency domain convolution functions. Since the frequency domain convolution involves a single matrix multiplication instead of a series of sliding window arithmetic computations, it is expected to be much faster. The following code compares the runtimes:
im = np.mean(misc.imread('../images/mandrill.jpg'), axis=2)print(im.shape)# (224, 225)gauss_kernel = np.outer(signal.gaussian(11, 3), signal.gaussian(11, 3)) # 2D Gaussian kernel of size 11x11 with σ = 3im_blurred1 = signal.convolve(im, gauss_kernel, mode="same")im_blurred2 = signal.fftconvolve(im, gauss_kernel, ...Read now
Unlock full access