January 2018
Intermediate to advanced
268 pages
6h 20m
English
We now know how to create a vignette filter that focuses on the center of the image. Let's say we want to achieve the same vignette effect, but we want to focus on a different region in the image, as shown in the following figure:

All we need to do is build a bigger Gaussian kernel, and make sure that the peak coincides with the region of interest. Following is the code to achieve this:
import cv2 import numpy as np img = cv2.imread('images/input.jpg') rows, cols = img.shape[:2] # generating vignette mask using Gaussian kernels kernel_x = cv2.getGaussianKernel(int(1.5*cols),200) kernel_y = cv2.getGaussianKernel(int(1.5*rows),200) ...Read now
Unlock full access