project 2-image_processng by anish hemmady

19
Name-Anish Hemmady Project 2 Low level Image Processing I have applied following low level processing in python programming : 1) Histogram equalization 2) Log Transformation 3) Median Filter 4) Gaussian filter-1D and 2D both have been implemented 5) Image rotation 6) Noise experiments have been carried out using Gaussian and median filters 1) Histogram equalization: In histogram equalization we have to distribute the intensity values of given image since some intensity values are clustered as a group together which can contribute to more intensity in certain regions and less in others. We want to distribute these intensities equally that’s why we use histogram equalization method. We want to get more accurate information of certain regions which is made possible through histogram equalization. We make use of cumulative density function of histogram. Following are images output which have been generated without any external library usage for histogram equalization. Mine program has given foll output: Input image Output image(after histogram equalz.)

Upload: ubhaykar

Post on 12-Apr-2017

148 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Project 2-Image_Processng by Anish Hemmady

Name-Anish Hemmady

Project 2

Low level Image Processing

I have applied following low level processing in python programming :

1) Histogram equalization

2) Log Transformation

3) Median Filter

4) Gaussian filter-1D and 2D both have been implemented

5) Image rotation

6) Noise experiments have been carried out using Gaussian and median filters

1) Histogram equalization:

In histogram equalization we have to distribute the intensity values of given image since some

intensity values are clustered as a group together which can contribute to more intensity in

certain regions and less in others. We want to distribute these intensities equally that’s why we

use histogram equalization method. We want to get more accurate information of certain regions

which is made possible through histogram equalization. We make use of cumulative density

function of histogram.

Following are images output which have been generated without any external library usage for

histogram equalization.

Mine program has given foll output:

Input image Output image(after histogram equalz.)

Page 2: Project 2-Image_Processng by Anish Hemmady

Input Image Output Image

(ct_scan.pnm)

(tire.pnm)

(Auto.pnm)

Page 3: Project 2-Image_Processng by Anish Hemmady

(building.pnm)

Building.pnm histogram

After Histogram equalization:

Page 4: Project 2-Image_Processng by Anish Hemmady

Ct_scan initial image histogram

After histogram equalization:

These histograms you can generate easily from my code.Similarly you can get other images

histogram and compare your results. See how the intensity has spreaded evenly.

Now let us look at output images generated by using inbuilt library function:

Using Library function outputs:

Left handside images are input images and right handside are output images

Page 5: Project 2-Image_Processng by Anish Hemmady
Page 6: Project 2-Image_Processng by Anish Hemmady

These output images generated by inbuilt library functions are exactly similar to what I have

generated using my coding for histogram equalization.

2) Median filter-Median filter uses neighbouring pixel information to fix middle pixel values of

the sliding window or mask moving on it.It makes use of sorting technique to get the neighbours

sorted and then picks up the median value and places it as middle pixel value.

Median filter removes completely salt and pepper noise.its really good against it.

Below I have shown output on Noise experiments carried out on images using median

filtering to clear out the noise.

Amount of noise added is 0.09 for all images shown below (in program its 1-0.01)

These outputs are results without using any inbuilt library of medianfilter:

Lefthandside consists of noisy image and righthandside consists of output after median

filter

(child.pnm)

Page 7: Project 2-Image_Processng by Anish Hemmady

(tire.pnm)

(ct_scan.pnm)

(auto.pnm)

Page 8: Project 2-Image_Processng by Anish Hemmady

(building.pnm)

Below are the outputs generated using Library inbuilt function for medianfilter of matlab

Page 9: Project 2-Image_Processng by Anish Hemmady

3) Log Transformation-Log Transformation is done to increase brightness in darker

regions, its like contrast stretching . It lights up the darker parts of images. It makes use

of formula c*(1+log(r)) where r is the intensity value.

Below are the outputs generated using log transformation without using library function:

Using library function it gives us same output it’s the same syntax for library.

Page 10: Project 2-Image_Processng by Anish Hemmady
Page 11: Project 2-Image_Processng by Anish Hemmady

4) Gaussian Filter-Gaussian filter is used to smoothen image but it tough to remove salt and

pepper noise.It depends upon sigma value which is applied to the Gaussian filter. If sigma value

is large it removes most of salt and pepper noise but in this process it tried to blur image.This is

the problem og Gaussian filter. It can be done in 2d and 1d,it can be done in 1d since Gaussian

filter is separable.I have implemented in both ways. Also Gaussian filter in 1-D is faster than 2-D

filter. I have some good results noted down.If sigma increases noise is reduced by blurring

occurs more.

Below is the output of Gaussian 2-D kernel without inbuilt library:(Input images contain

noise and output images are after applying Gaussian filtering-see noise on rhs.lhs is input

image)

Sigma value used is 1.5 Noise type-salt and pepper, amount-0.09 for all images

Input Image Output Image

Page 12: Project 2-Image_Processng by Anish Hemmady

Below is the output generated using inbuilt library of Gaussian filter in matlab

Input Image Output Image

Page 13: Project 2-Image_Processng by Anish Hemmady

Now using 1-D Gaussian kernel I get similar results:

Page 14: Project 2-Image_Processng by Anish Hemmady
Page 15: Project 2-Image_Processng by Anish Hemmady

From the above results we can see that Gaussian filter cannot completely eliminate salt

and pepper noise,it blurs it out

Noteable Facts of Gaussian filter

Time taken by Gaussian kernel in 1-D is less as compared to 2-D kernel to filter out the

image.

Gaussian Kernel type Time taken(milliseconds) Input image

size(width*height) pixels

1-D 7.0542585998 (341, 374)

2-D 11.3605490906 (341, 374)

1-D 0.819472711185 (128, 128)

2-D 1.90503216172 (128, 128)

5) Image Rotation: Image Rotation is performed by going backwards method,in which one

has to first loop through new image where new pixel values will be placed and find out the point

in input image where this current pixel of output will be replaced. This is done by multiplying

inverse of rotation matrix with output image x,y coordiantes and translating back to origin.First

translate back to origin then rotate it with inverse matrix, you will get x,y coordinates.Using

these x,y coordinates first draw out the pixel intensity value in the input image and then place

this intensity value in output image.This method avoids aliasing effect in output image.Dont

forget to translate back after rotation by translating back by same amount from origin to rotate

image about its center.The translating factor is width/2 and height/2 of input image.

Page 16: Project 2-Image_Processng by Anish Hemmady

Images shown below is rotated at angle 45 degrees therefore its anticlockwise direction. If -45

then clockwise.

Following are output images without using inbuilt library of imroatate in python

Input Image OutputImage

Page 17: Project 2-Image_Processng by Anish Hemmady

Now Rotation using inbuilt library of cv2.getRotationMatrix2D in Python

Page 18: Project 2-Image_Processng by Anish Hemmady
Page 19: Project 2-Image_Processng by Anish Hemmady

Conclusion:

Low level processing Technique Its use

Histogram equalization Spread the intensity evenly

Log Transformation See darker regions clearly

Median filter Eliminate the salt and pepper noise

completely

Gaussian Filter (1-D and 2-D) Doesnt eliminate salt and pepper noise

completely but blurs it out

Image Rotation Rotate an image by specific angle clockwise

if negative angle and counter clockwise if

positive angle