I want to use OpenCV in C++ to achieve gradual image blur effect, such as the one in this picture:
But i don't know how to do this.
I used cvSmooth()
function in OpenCV, but can't implement the gradual blur effect I want.
What should I do?
I want to use OpenCV in C++ to achieve gradual image blur effect, such as the one in this picture:
But i don't know how to do this.
I used cvSmooth()
function in OpenCV, but can't implement the gradual blur effect I want.
What should I do?
You could use GaussianBlur(). Assuming that you set values of SigmaX and SigmaY parameters to 0, the size of the filter kernel corresponds to the level of smoothing - larger kernel implies smoother image.
Now, you should divide your image into groups of rows (containing 1 or more rows), treat them as separate images and apply GaussianBlur() to each of them, decreasing its kernel size with each consecutive row or a group of rows.
Depending on the result you want to achieve, you have to tune up the parameters such as the initial and final kernel size, how fast the size decreases, number of rows in each group and whether each group of rows is of the same size (e.g. if the kernel at certain iteration is of size NxN, you could apply it to the group of N rows - then the group size would be variable and the top group would contain the highest number of rows). Also, remember to consider image boundaries as special cases.
Note: if you want to apply an NxN filter to an image strip consisting of N rows, you should take a ROI whose size is (2N-1)xN in order to include boundary pixels.