Starting with Image processing

I am assuming that you are familiar with what images are and how they are represented. You can read more about images, color in my previous blogs or just google what is new to you and is not explained :)

Histogram:

Histogram is how frequently gray level or R,G,B values occurs in the image.

Derivatives

Lets start with what derivatives are , derivatives are rate of change with respect to something which mathematically translates to image.png but in the world of images which to computers are multidimensional arrays of numbers, whats the smallest dx (delta x to be more precise are in our case its discrete derivative)? It turns out to be 1 :), as its the smallest step which you can take in arrays in either direction. Therefore derivative in context of image processing looks like

image.png So we can get three discrete derivatives like backward difference, forward difference and central difference as follows:

image.png

So for example lets say we have a f(x) = 10, 15, 10, 10, 25, 20, 20, 20. So f'(x) using backward difference will be 0, 5, -5, 0, 15, -5, 0, 0. It becomes easy to find derivatives using different derivative masks like if we want to calculate backward difference mask will be like [-1 1], for forward difference it will be like [1, -1] and for central difference it will be [-1 0 1]

Acoordingly we can calculate the derivative masks for 2d arrays ie images (grayscale to be precise). As the function has two dimensions we will be getting two gradient ie one with respect to x and the other with respect to y (assuming the function to f(x,y)), we can also calculate the magnitude of gradient and direction of graident

image.png

Correlation vs Convolution

In correlation one does the summation of element-wise multiplication with the filter and in convolution we flip the filter in both the axis and then do summation of the element-wise multiplication.

Filtering

Modifying pixels based on some function of the neighbourhood.

Edge

Discontinuity of intensity in the image. Various types of edges like (a) step, (b) ramp, (c) spike and (d)roof.

image.png

Edge detectors

As the edges are somewhat abrupt changes in the intensities, derivative of intensity values in the image will give edges. Examples : 1) Gradient Operators (Prewitt and sobel) 2) Laplacian of Gaussian 3) Gradient of Gaussian (Canny)

What you will find in the implementations out there is that before applying gradient operators we do a little smoothening of the image (remember edges are discontinuity of intensities in the image, but every image has some noise which will respond strongly to the gradient operators), so as the noise is generally some high random value we want to average (it can be just average, weighted average or gaussian average) out the neighbourhood and thats what filtering does. After applying any gradient operator we apply a threshold to get the edges

Prewitt edge detector:

66D01BE1-5F29-4906-AC63-4C499C4B104D.png

Sobel edge detector:

194A334D-B26D-4907-B4EC-C8A18B05BB78.jpeg

Overall process of edge detection (using sobel edge detector):

0DEC84F3-BD89-4CB7-938A-C3A600E0BD70.jpeg

In the upcoming blogs I will be writing about more edge detectors, SIFT, SURF, Optical Flow etc so stay tuned.

Did you find this article valuable?

Support Himanshu Maurya by becoming a sponsor. Any amount is appreciated!