Raw Image -> (Gaussian | Median) blur -> Sharpening Filters -> Enhanced Image
It is used to change the sharpness of image to smooth , also removed noise.
- kernel size x , y -> must be odd pair { (3,3) : light blur , (9,9) : strong , (21,21) : Super strong }
- sigma -> how strong you want the effect
Now let me explain this kernel thing in more simpler terms: Consider the kernel size to be (3 x 3) grid so what it will do is that it will first finds out the center pixel then it takes the average of all 9 pixels and whatever the answer comes up it replaces the center value with that average.
What this will do is the sudden spikes in pixel values are removed now and we achieve smoothness.
Here we can clean the image by replacing each pixel value with a middle value.
How its going to work?
- First it will find out the group of pixels.
- Then it will sort them according to their brightness values.
- Lastly it will find the median out of it.
A little difference between Gaussian Blur & Median Blur
Gaussian -> Average of Neighbor values for smoothening and softening images Median -> Finding the middle values to remove random black and white dots
It basically highlights the edges in the images , boosts the contrast between the pixels , shows the outlines clearly.
Picks every pixel -> compares with its neighbor -> boosts the center pixel -> subtracts the outside so that contrast can increase.
Sharpening Kernel
0 -1 0 -1 5 -1 0 -1 0
Here, 5 -> is boosted to stand out of all -1 -> to have lower effect 0 -> at corners to have no effect on them
ddepth stands for desired depth , setting it to -1 will give us the same depth as input image, you can also try out different values for it like -
- cv2.CV_8U β 8-bit unsigned int (0 to 255).
- cv2.CV_16S, cv2.CV_32F, etc. β Other explicit depths.