DEV Community

Nilesh
Nilesh

Posted on

Day 2

Let's have some Image Processing today:

So I have this course, COMP 6721 which covers the fundamental of Image Processing and today I learnt a few concepts of Image Transformation and Image Filtering.

Image Transformation Operations

Image Transformation can be done in following two major ways:

  1. Spatial Image Transformation
  2. Histogram Image Transformation

In the previous lecture, I covered basic concepts of Image Transformations, like image rotation, scaling, translation, flip, affine transformation, wrap/swirl.

What's a Spatial Image Transformation?

A spatial transformation of an image is a geometric transformation of the image coordinate system.
There are certain ways we can perform Spatial Image Transformation, to list some of these:

  1. Linear Point Transformation
  2. Log Transformation
  3. Gamma Transformation
  4. Piece-Wise Linear Transformation

Log transformations are mainly used in the MRI and Gamma transformation uses a Gamma function to convert the image to dark or light depending on the Input Intensity Levels.

What is Histogram Transformation?

A histogram transformation is a pixel-by-pixel intensity transformation defined by five parameters in PixInsight: Clipping points.
Now we can define the transformation using the Bars also.
Ex: Consider an image of 64x64 pixel values, then each pixel will have different pixel value from 0...255.
Here, value of pixel 0 means --> darkest
and value of pixel 255 means --> brightest

Now, let's say we have 2 pixels who has value of 0, then we will make a bar in the graph, where:
x-axis = pixel value (Ex: x-axis --> 0)
y-axis = frequency of that pixel (Ex: y-axis --> 2)

And hence, simply plot the graph now.

We call, each of these bars created as BINS. These bins not necessarily have to store only the fixed value, rather it can store the range of the pixel values.
Example: pixel values in the range 0-15 can be in Bin b1, and pixel values in the range of 245-255 can be in bin b16 and so and so forth.

What is a Contrast?

Contrast is the difference in luminance or color that makes an object distinguishable from other objects in the same field of view.
A low contrast image has the objects which are hard to identify in the image and hence we sometimes do an auto-contrast function to fix the image contrast and make the objects in the image clearly distinct-able.

Now Contrast Enhancement can be done by two ways:

  1. Linear method
    • Contrast Stretching
  2. Non-Linear method
    • Histogram Equalization
    • To enhance the image's contrast, it spreads out the most frequent pixel intensity values or stretches out the intensity range of the image.
    • Gaussian Stretch

Image Filtering

When we talk about Image Filtering then we are talking about images in the spatial domain, and hence we will deal with pixels here.

So to filter an image, we filter every pixel of the input image and to do so, we use filters which are known as Kernel Filters or we also call them as Spatial Filters.
This filter has to be unique across rows and columns and it looks like following:

(It is usually an odd dimension m x n, where m=n=2n+1)

Example:

Input image --> 8x8 image
[0, 65,231, 87, 2, 7, 255...m8]
[nk ... mk]
[n8 ... m8]
Kernel --> 3x3 matrix
[1,0,1]
[2,0,2]
[1,0,1]

And to calculate the output image, just multiply the Kernel with the input image pixels over that dimension with a stride of 1.
What's stride?
Stride is basically how many pixel values you will be jumping/traversing in each calculation.

So basically, we have image kernels, which determine the output of the image and depending on the kernel we are using, we will get a certain output.

And there are certain set of kernel values already defined using which we can generate the "Convolved Image".

Major operations in Image Filtering are:

  1. Image Smoothing using Low-Pass Filters
    • Box Filter
    • Gaussian Filter
  2. Image Sharpening using High-Pass Filters
    • Laplacian Filter

... to be continued to day 3

What's next?
I will be completing this lecture along with the code examples.
And we will solve few coding problems as well (Arrays, Strings, HashMaps)

Thank you!

Happy hacking ^_^

Top comments (0)