November 2018
Intermediate to advanced
492 pages
12h 19m
English
With scipy.convolve2d(), we can sharpen an RGB image as well. We have to apply the convolution separately for each image channel.
Let's use the tajmahal.jpg image, with the emboss kernel and the schar edge detection complex kernel:
im = misc.imread('../images/tajmahal.jpg')/255 # scale each pixel value in [0,1]print(np.max(im))print(im.shape)emboss_kernel = np.array([[-2,-1,0],[-1,1,1],[0,1,2]])edge_schar_kernel = np.array([[ -3-3j, 0-10j, +3 -3j], [-10+0j, 0+ 0j, +10+0j], [ -3+3j, 0+10j, +3 +3j]])im_embossed = np.ones(im.shape)im_edges = np.ones(im.shape)for i in range(3): im_embossed[...,i] = np.clip(signal.convolve2d(im[...,i], emboss_kernel, mode='same', boundary="symm"),0,1)for i in range(3): ...Read now
Unlock full access