Continuing the presentation series, the fourth part is about the blurring and sharpening of images. the manual method of doing the operations is given along with some functions for blurring. the next is about edge detection algorithms like Canny, Sobel, and Prewitt. also, the dilates and the eroded images are provided along with the canny ones.
I HAVE WORKED HARD FOR THIS PRESENTATION!! SO PLEASE SUPPORT GUYS!!!
2. Blurring and sharpening of images
• This segment is about the blurring and sharpening of the images.
• For this we are going to create a customized filter/kernel for blurring and
sharpening separately.
• These filters are nothing but an array of numbers.
• The numbers in the array of the filter determine the operation to be performed.
• The input image is nothing but an array of numbers.
• The numbers indicate the colour intensity of the pixels in the input image.
3. Contd…
• Any color in the universe can be expressed within 0 to 255 where 0 refers to black
and 255 refers to white.
• As a matter of fact, the grayscale images are two dimensional images since they
contain height and width only.
• Whereas the color images are three dimensional images since they contain height,
width and color channels. (BGR in the case of OpenCV).
• So an image is nothing but an array of numbers.
• The filter which we have assigned is also an array of numbers.
4. Convolution
• Hence there is an array operation that is going to take place when we apply a
kernel to an image.
• The operation is known as convolution which is indicated by the *.
• The convolution is the combination of addition and multiplication.
• First, there is a matrix multiplication between the image and the kernel.
• Then the product of all the values are then added to produce the final answer.
• In one way, the convolution operation reduces the dimension of the image.
5. Filter
• So the numbers present in the filter play a major role in determining the operation.
• To obtain a black image using filters, we can use the array filled with zeros.
• Zero multiplied with anything is zero and their sum is zero.
• The resultant is a zero and hence we obtain a black image.
• Similarly, there are other filters for other operations.
• We can play with the numbers in the filters to see how the output image looks like.
7. Filter for blurring
• The process of blurring is to make the details less clearer or to diminish the
intensity.
• This can be done by taking the average of the surrounding pixels and replacing it in
the original place.
• So the 3*3 filter for performing blurring operation looks like
• 1/9, 1/9, 1/9
• 1/9, 1/9, 1/9
• 1/9, 1/9, 1/9
8. Function
• This filter is made by using the array function from the numpy library.
• Then we have to mention two square brackets since the array is 2-D in nature.The
dimensions for the array and the elements to be filled are upto the choice of the user.
• The dimension determines the frequency of convolution (large dimension means lesser
times) and the numbers determine the operation.
• Finally the filter2D function in OpenCV is used to implement our customized filter.
• The first argument is the image location, the second is an number of -1 and the third is our
kernel.
10. Sharpening of images
• Image sharpening refers to any enhancement technique that highlights edges and fine
details in an image.
• Image sharpening is widely used in printing and photographic industries for increasing the
local contrast and sharpening the images.
• The filter used here is given below:-
• 0,-1,0
• -1,n,-1
• 0,-1,0
• The value n determines the amplitude of the sharpening.
13. Alternate for blurring
• The blurring done before was fixed.
• So to overcome this disadvantage and to make it variable we use a function called Gaussian Blur.
• The blurring is done by the gaussian function which is mathematical.
• The first argument is the location of the image.
• The second argument is the kernel range. It is important to give an odd and equal value like (3,3)
or (5,5) etc.
• The third argument is a number ranging from 0 to 1. 1 gives a clear image despite the kernel
applied.
• There are two other types of blurring called the median and bilateral blurring.
19. Edge detection-canny
• Edge detection is a technique of image processing used to identify points in a
digital image with discontinuities.
• It sharps the changes in the image brightness.These points where the image
brightness varies sharply are called the edges (or boundaries) of the image.
• The edge detection method used here is called as canny edge detection.
• It is essential that we use grayscale images to lower the computations.
• There are two threshold values in the canny function.
22. Sobel edge detection
• Another method for edge detection available in OpenCV is the sobel
method.
• This is also known as Sobel-Feldman operator or Sobel filter.
• By changing the dx and dy values we can get sobel features for x and y axes
separately.
26. Prewitt edge detection
• The third edge detection method is called as the prewitt method.
• This method uses specified filters for x and y axis and we have to manually
combine them.