March 2020
Intermediate to advanced
366 pages
9h 8m
English
The last step is to combine the two previously achieved effects. Simply fuse the two effects together into a single image using cv2.bitwise_and. The complete function is as follows:
def cartoonize(rgb_image, *, num_pyr_downs=2, num_bilaterals=7): # STEP 1 -- Apply a bilateral filter to reduce the color palette of # the image. downsampled_img = rgb_image for _ in range(num_pyr_downs): downsampled_img = cv2.pyrDown(downsampled_img) for _ in range(num_bilaterals): filterd_small_img = cv2.bilateralFilter(downsampled_img, 9, 9, 7) filtered_normal_img = filterd_small_img for _ in range(num_pyr_downs): filtered_normal_img = cv2.pyrUp(filtered_normal_img) # make sure resulting image has the same ...
Read now
Unlock full access