Top Banner
NEHA RATHORE |ID- 5994499980 1 EE 569- Fall’08 Submitted by: NEHA RATHORE ID -5994499980 Project-1 Visible watermarking technologies; Image enhancement; Noise Removal 19th September ’2008
37

watermarking- image enhancement- noise removal

Mar 08, 2016

Download

Documents

Neha Rathore

19th September ’2008 NEHA RATHORE EE 569- Fall’08 ID -5994499980 Submitted by: NEHA RATHORE |ID- 5994499980 1
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: watermarking- image enhancement- noise removal

NEHA RATHORE |ID- 5994499980 1

EE 569- Fall’08

Submitted by:

NEHA RATHORE

ID -5994499980

Project-1 Visible watermarking technologies;

Image enhancement; Noise Removal

19th September ’2008

Page 2: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 2

Problem 1

Gray Scale Images and Visible Watermarking Technologies

Objective

We need to convert a RGB image to a grayscale image. Furthermore, we need to implement a visible

watermarking technique for Donheny.raw file. We have to watermark the color and grayscale images of

donehy.raw with color and gray scale USC logos, respectively.

Motivation

Color images are converted to grayscale images for several reasons. For example, in data compression

techniques a gray scale image is helpful as it provides the information in 1byte per pixel, as opposed to

the color image that carries 3 bytes per pixel. There are various techniques available to convert a color

image into a grayscale image. However, most of the techniques result in a fattened image that lacks the

digital vibrance of the original color image. As one is aware, a color image is comprised of three primary

colors namely; red, green and blue. Different combinations of these colors produce variable output

colors. On the otherhand, a grayscale image is comprised primarily of the luminance and chrominance.

To convert a color image into a grayscale image that presents same kind of image depth we need to

calculate the luminance of the image at each pixel.

As we were provide with an image in RAW format1 we were able to process data efficiently in a pixel by

pixel basis. The First step was to extract the RGB values from the image. Being able to see an image in

discreet domain in the form of numbers was very fascinating. To know how few numbers arranged in a

certain way can produce magic to the human eyes. In practical application, sometimes these RGB

channels are separately used for transmitting information. Devices like, R,G,B filters make it possible to

transmit data in a encoded manner.

Digital watermarking is a process of embedded a digital signature in an image. The signal may be audio,

pictures or video, for example. If the signal is copied, then the information is also carried in the copy.In

visible watermarking, the information is visible in the picture or video. Typically, the information is text

or a logo which identifies the owner of the media. When a television broadcaster adds its logo to the

corner of transmitted video, this is also a visible watermark.2

The other form of water marking is the invisible water marking. In this form, the logo is embedded in the

image in an invisible manner. This is an efficient way of preventing unauthorized use of digital media.

1 Raw Format: A raw image file contains minimally processed data from the image sensor of a digital camera or

image scanner. Image can processed for precise adjustments can be made before conversion to an RGB file format

such as TIFF or JPEG for storage, printing, or further manipulation.

2 Wikipedia: http://en.wikipedia.org/wiki/Digital_watermarking

Page 3: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 3

Procedure

Problem 1.1- Color to Gray-Scale conversion:

In gray-scale image , each pixel has the value of only one component to record its brightness. This

component is called the luminance of the pixel and is often denoted as “Y”. In a RGB color image, each

pixel has the value of three color components (red, green and blue) to record the combined color of the

pixel. The brightness of the pixel is calculated in the following way:

Y = 0.299xR + 0.587xG + 0.114xB

Where, R, G, B values are the corresponding red, green and blue value for the pixel.

INPUT IMAGE OUTPUT IMAGE

FIG: 1.1 FIG 1.2

Procedure and algorithm:

As I am implementing this technology in C++, I stored the Input image in a 3D array called imagedata

[256][256][3]. This Array stores the three bytes of RGB respectively in the three location of the array and

stores the location of the pixel in the first two bytes. This made the processing the image much easier as

the Red pixels were stored in the imagedata[x][y][0] location, Green pixels were stored in the

imagedata[x][y][0] location and blue pixels were stored in the imagedata[x][y][2] location.

Each pixel of R was multiplied by a factor of (0.299), each pixel of G was multiplied by a factor of (0.587)

and each pixel of B was multiplies by a factor of (0.114). Finally, these three scaled values were added

together to give the total brightness of the particular pixel.

Furthermore, I calculated the brightness of each pixel using the above formula for “Y” and stored this

value in a new 3-D array called Imagedata1[x][y][0] which is an array of size 256*256*1. Hence an

image of 3 bytes of RGB values is converted to an image of 1byte of grayscale. As we are calculating the

Page 4: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 4

brightness of each pixel, we preserve the digital vibrance of the image as we convert the image from

RGB to gray scale.

Hence, we were able to convert the desired image to the grayscale maintaining its digital vibrance at the

same time. The gray scale image seems to be good and sharp.

Problem 1.2- Embedding Watermarks into Original Image

Digital watermarking is the process of embedding information into a digital signal called the host. The

host signal can be audio, pictures or video. In visible watermarking, the information is visible in the

picture or video. Typically, this information is a logo that identifies the owner of the media. This

technology helps prevent the unauthorized use of a copyright material.

Objective:

We need to implement a program that embeds the color USC logo in the Center position of color image.

This image is given to us as Donehy.raw. We also need to implement a program to embed the gray scale

USC logo in the center position of the gray scale image obtained in part 1 of the problem.

Images to be embedded

USC Color Logo USC Gray Logo

Figures :1.3,1.4,1.5,1.6 (clockwise)

Procedure and analysis

Watermarking the USC logo in the Doheny image.

Page 5: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 5

As we were given the USC logo in a 128x128 size as opposed to the 256x256 size of the image it was

crucial to choose the parameters to overwrite the pixels of the original image. I divided the image in a x-

y coordinate system with values of x & y belonging to a range [0,255]. This makes the first pixel of the

image at (1,1) location and last pixel the location (255,255). I further tried matching the centers of the

images. This implies that the pixel at (63,63) in the logo image had to be matched with the pixel at

(128,128) in the Doheny image.

In my imagedata array I ranged the values of x and y from 63 to 191 to accommodate the 128x128 pixels

of the USC loge. As a subtraction of 191 and 63 gives 128, this implies we can fit the USC logo of size

128x128 in the center of the Doheny image if the values of x & Y for Doheny image are varied in this

range.

The second challenge was to remove the white background of the USC logo (as shown in fig 1.5 and 1.6).

This was done by comparing the value of pixels of the original image and USC logo pixel by pixel and

checking for the value of white. As white is represented by 255, I compared the original pixel by 255 to

remove the white background of the logo. Hence, all the white pixels of the logo were replaced by the

pixels of the original image while watermarking procedure.

Watermarking the logo in case of the color image was a little more complex as the overwriting

procedure had to be done for each RGB channel for the image corresponding to the RGB channel of the

USC logo. The white background of the USC logo was removed the same way for each channel.

Watermarked color image Watermarked gray-scale image

Fig:1.7 Fig:1.8

We were successfully able to watermark the two images. However, we were not able to clearly remove

all the white background of the USC logo. This can be noticed by a close look to the image.

Problem 2- IMAGE ENHANCEMENT

OBJECTIVE: we need to implement two contrast manipulation techniques called linear scaling and

Histogram equalization, to enhance the low contrast images namely; rose_dark.raw, rose_bright.raw

and rose_ mid.raw. We need to enhance the given low, high and medium contrast images and plot

Page 6: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 6

histograms and the transfer function of the input and output images and to analyze and discuss the logic

behind these techniques.

Motivation

An ideal image is said to have a histogram equally distributed in the whole gray scale range, i.e 0 to 255.

Each gray level contains fairly good amount of pixels in an ideal image. An image with poor contrast has

a range of gray level usually limited to a particular subset of the whole gray scale levels. For example,

You will see the rose_dark image has gray scale values limited to a set [0-31]. As “0” is represented as

Black in gray scale, the image has all the pixels with values close to black. This makes the overall image

very dark and often unrecognizable.

One of the most common defects of photographic or electronic images is poor contrast resulting from a

reduced, and perhaps nonlinear, image amplitude range. Image contrast can often be improved by

amplitude rescaling of each pixel. An image corrected for contrast is often more pleasant to human

eyes. As the human eyes is known to lack the ability to mark the distinction between pixels that are very

close in their intensity levels, an image with variable intensity levels makes an image appear clear and

sharp to the human eye.

The idea of stretching the histogram of an image and making an image with increased contrast is an

interesting thing to implement. Furthermore, the method of contrast correction is widely used in the

media industry to edit images affected by poor lighting conditions. As lighting conditions are vary from

time to time and place to place, it is possible that one can get different results for the same kind of set

up. Sometimes it is a useful thing, but often change in lighting conditions makes is impossible to take an

particular picture. Hence, Contrast correction is a useful technique to learn as a student of digital image

processing.

Histogram

A histogram is used to graphically summarize and display the distribution of a process data set. A histogram can be constructed by segmenting the range of the data into equal sized bins (also called segments, groups or classes).

3 In statistics, a histogram is a graphical display of tabulated frequencies,

shown as bars. It shows what proportion of cases fall into each of several categories. A histogram differs from a bar chart in that it is the area of the bar that denotes the value, not the height, a crucial distinction when the categories are not of uniform width (Lancaster, 1974). The categories are usually specified as non-overlapping intervals of some variable. The categories (bars) must be adjacent.

4

Cumulative distribution function (CDF) In probability theory and statistics, the cumulative distribution function (CDF), also probability distribution function or just distribution function, completely describes the probability distribution of a real-valued random variable X. For every real number x, the CDF of X is given by

where the right-hand side represents the probability that the random variable X takes on a value less than or equal to x. The probability that X lies in the interval (a, b] is therefore FX(b) − FX(a) if a < b.

3 http://www.isixsigma.com/library/content/c010527c.asp

4 http://en.wikipedia.org/wiki/Histogram

Page 7: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 7

If treating several random variables X, Y, ... etc. the corresponding letters are used as subscripts while, if treating only one, the subscript is omitted. It is conventional to use a capital F for a cumulative distribution function, in contrast to the lower-case f used for probability density functions and probability mass functions. This applies when discussing general distributions: some specific distributions have their own conventional notation, for example the normal distribution. The CDF of X can be defined in terms of the probability density function ƒ as follows:

Note that in the definition above, the "less or equal" sign, '≤' is a convention, but it is a universally used one, and is important for discrete distributions.

5

Probability Density of a Pixel (in our Case)

By the theory of relativity of occurrence, the probability of a particular even can be calculated by

dividing the total number of occurrences of this event by the total number of occurrences of all events

in a sample space.

Prob[x] = na/ n

We calculate the probability of each pixel by calculating its total number of occurrences and dividing it

by the total number of occurrences, i.e. 65536. Suppose a particular pixel is present 32768 times in the

image, then its probability is 32768/65536=0.5.

Procedure and Analysis

We first plot the Histogram for each image and notice the range of gray scale values occupied by each

image on the histogram of the image.

Our goal is to distribute the 255 gray levels evenly in the new image that forms a contrast enhanced final

image.

To plot the histogram

I read by imagedata array for value of each pixel. As a particular value is read we increment the number

of that pixel for that particular gray level in our histogram table. We download this data in the text

format in a txt file and plot the corresponding graph in Micrsoft excel6.

We plot these graphs for each given image.

Rose_dark.raw Rose_mid.raw Rose_bright.raw

5 Wikipedia: http://en.wikipedia.org/wiki/Cumulative_distribution_function

6 This was allowed by the TA in the discussion board.

Page 8: watermarking- image enhancement- noise removal

Fig: 2.1 Fig: 2.2

HISTOGRAMS of above images.

Fig: 2.1a Histogram of the Rose_dark.raw image. We can clearly see that all the pixels have a gray scale value range from

minimum of “0=black” to 31. This makes the image very dark. This image also make it difficult to recog

intelligibly.

Fig: 2.2a Histogram of the Rose_mid.raw image. We can clearly see that all the pixels have a gray sc

minimum of 64 to 128. This makes the image ve

lacks sharpness.

0

2000

4000

6000

8000

10000

12000

1

11

21

31

41

51

no. of pixels with same gray levels for rose_dark

0

1000

2000

3000

4000

5000

6000

1

11

21

31

41

51

61

no. of pixels with same gray levels for rose_mid

EE 569- Fall’08 | ID- 5994499980

Fig: 2.1 Fig: 2.2 Fig: 2.3

HISTOGRAMS of above images.

Histogram of the Rose_dark.raw image. We can clearly see that all the pixels have a gray scale value range from

minimum of “0=black” to 31. This makes the image very dark. This image also make it difficult to recognize the original image

.raw image. We can clearly see that all the pixels have a gray sc

. This makes the image very dull. This makes it difficult to recognize the original image intelligibly

51

61

71

81

91

10

1

11

1

12

1

13

1

14

1

15

1

16

1

17

1

18

1

19

1

20

1

21

1

22

1

23

1

no. of pixels with same gray levels for rose_dark

61

71

81

91

10

1

11

1

12

1

13

1

14

1

15

1

16

1

17

1

18

1

19

1

20

1

21

1

22

1

23

1

no. of pixels with same gray levels for rose_mid

5994499980 8

Histogram of the Rose_dark.raw image. We can clearly see that all the pixels have a gray scale value range from

nize the original image

.raw image. We can clearly see that all the pixels have a gray scale value range from

it difficult to recognize the original image intelligibly and

23

1

24

1

25

1

23

1

24

1

25

1

Page 9: watermarking- image enhancement- noise removal

Fig: 2.3a Histogram of the Rose_bright.raw image. We can clearly see that all the pixels have a gray sc

minimum of 128 to “255= white”. This makes t

image intelligibly and lacks sharpness and gradation

0

500

1000

1500

2000

2500

3000

35001

11

21

31

41

51

61

no. of pixels with same gray levels for rose_bright

EE 569- Fall’08 | ID- 5994499980

.raw image. We can clearly see that all the pixels have a gray sc

to “255= white”. This makes the image too bright. This image also make it difficult to recognize the original

and gradation.

61

71

81

91

10

1

11

1

12

1

13

1

14

1

15

1

16

1

17

1

18

1

19

1

20

1

21

1

22

1

23

1

no. of pixels with same gray levels for rose_bright

5994499980 9

.raw image. We can clearly see that all the pixels have a gray scale value range from

. This image also make it difficult to recognize the original

23

1

24

1

25

1

Page 10: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 10

Full Scale linear Scaling

There are three common linear scaling methods, the first one is called Linear Image Scaling, in which the

processed image is linearly mapped over its entire range; the second one is called Linear Image Scaling

with Clipping, where the extreme amplitude values of the processed image are clipped to maximum and

minimum limits. The last one is called Absolute Value Scaling, which utilizes an absolute value

transformation for visualizing an image with negatively valued pixels. The second technique is often

subjectively preferable, especially for images in which a relatively small number of pixels exceed the

limits.7

For our purpose, we are going to implement the second method, which is Linear Image Scaling. The idea

of linear scaling is illustrated below.

This process Involves mapping of histogram of the input image in such a way that the histogram of the

output image covers the entire range from [0-255] of gray scale levels. The main challenge faced here is

to realize the mapping range. Low contrast images can be result of poor illumination and lack of

dynamic range in the imaging sensor. These low contrast images have a very low dynamic range. Thus

the primary idea is to increase the dynamic range of these images , that is to stretch the range from low

to high linearly.We have an equation,

Where,

7 Digital Image Processing(fourth edition) by William K. Pratt

Page 11: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 11

(Fmin,Fmax)= minimum and maximum grey level of input image that is occupied

(Gmin,Gmax)= minimum and maximum grey level of output image that is desired.

In a way, this equation represents the line form y=mx+c, where m is the slope and c is the intersection

on y axis. In our case the slope is given by the quantity (Gmax-Gmin) / (Fmax - Fmin). When we make

Gmin=0 and Gmax=255, we cover the entire range for 8 bit images, hence the process is called full range

linear scaling.

Algorithm

We scan the whole image stored in imagedata array one by one starting with first row and first column.

As a particular gray level is encountered, we calculate the new gray level to be replaced by the above

formula. Thus we replace each pixel value by the new pixel value obtained from the equation and the

resulting image is contrast enhanced. We apply the same procedure in each of the given images with

desired dynamic range.

Results after Linear scaling

Rose_dark.raw

Rose_dark before linear Scaling Rose_dark after linear Scaling

Fig 2.1b: We see the Linear scaling technique converts a rather dark image in an image that is much brighter. The contents of

the image can be easily recognized and the image looks more pleasant to the eyes.

The above image was linearly scaled for the following values:

Fmin = 0

Fmax= 31

Gmin= 0

Gmax=255

Page 12: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 12

Slope= 8.22 or 88

Histogram of the final image change

Transfer Function

8 Nearest integer approximation

0

2000

4000

6000

8000

10000

12000

1

13

25

37

49

61

73

85

97

10

9

12

1

13

3

14

5

15

7

16

9

18

1

19

3

20

5

21

7

22

9

24

1

25

3

histogram dark after linear scaling

0

2000

4000

6000

8000

10000

12000

1

11

21

31

41

51

61

71

81

91

10

1

11

1

12

1

13

1

14

1

15

1

16

1

17

1

18

1

19

1

20

1

21

1

22

1

23

1

24

1

25

1

no.pixels for rose_dark histogram dark after linear scaling

0

0.2

0.4

0.6

0.8

1

1.2

1

14

27

40

53

66

79

92

10

5

11

8

13

1

14

4

15

7

17

0

18

3

19

6

20

9

22

2

23

5

24

8

Page 13: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 13

Analysis As we compare the two histograms, we see the dynamic range is clearly stretched. The output

image is also visually enhanced and the Cdf shows more level gradations then the original CDF.

Rose_mid.raw

Rose_mid before linear Scaling Rose_mid after linear Scaling

Fig 2.2b: We see the Linear scaling technique converts a rather flat image to an image that has much more variations and

gradations. The contents of the image can be easily recognized and the image looks more pleasant and vibrant to the eyes.

The above image was linearly scaled for the following values:

Fmin =64 ; Fmax= 128 ; Gmin= 0; Gmax=255;

Slope= 3.98 or 49

Histogram of the final image change

9 Nearest integer approximation

Page 14: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 14

Transfer Function

0

1000

2000

3000

4000

5000

6000

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

new histogram for rose_mid

0

1000

2000

3000

4000

5000

6000

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

new histogram old histogram

Page 15: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 15

Analysis

We see that the dynamic range of the image is increased and the Cdf is also changed. The image is much

better then the original image.

Rose_Bright.raw

Rose_bright before linear Scaling Rose_Bright after linear Scaling

Fig 2.1b: We see the Linear scaling technique converts a rather brightimage in an image that is much better. The contents of the

image can be easily recognized and the image looks more pleasant to the eyes.

0

0.2

0.4

0.6

0.8

1

1.2

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

New CDF for MID_rose

Page 16: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 16

The above image was linearly scaled for the following values:

Fmin = 128 Fmax= 255 Gmin= 0 Gmax=255

Slope= 2.007 or 210

Histogram of the final image change

Transfer Function

10

Nearest integer approximation

0

500

1000

1500

2000

2500

3000

3500

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

New histogram

0

500

1000

1500

2000

2500

3000

3500

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

no.pixels for rose_bright New histogram

Page 17: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 17

Analysis

Conclusion: We see that the linear scaling of the given images produces a better result as compared to

the original images. The gray scale range which was restricted to a particular subset of gray level was

distributed in a wider range from 0 to 255. Thus, creating much better images then the original image.

Histogram Equalization

Histogram equalization is the technique by which the dynamic range of the histogram of an image is

increased. Histogram equalization assigns the intensity values of pixels in the input image such that the

output image contains a uniform distribution of intensities. It improves contrast and the goal of

histogram equalization is to obtain a uniform histogram. This technique can be used on a whole image

or just on a part of an image.

Histogram equalization redistributes intensity distributions. If the histogram of any image has many

peaks and valleys, it will still have peaks and valley after equalization, but peaks and valley will be

shifted. Because of this, "spreading" is a better term than "flattening" to describe histogram

equalization. In histogram equalization, each pixel is assigned a new intensity value based on the its

previous intensity level.11

The luminance histogram (as explained before) of a typical image is usually skewed towards a particular

range. The histogram equalization Technique forces the histogram of an image to be uniform. We

11

www.CoderSource.net

0

0.2

0.4

0.6

0.8

1

1.2

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

New CDF for MID_rose

Page 18: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 18

approach this method useful information given by the normalized CDF. We calculate the CDF for each

original image and Process the resulting output image by the help of this information.

Procedure and Analysis:

Our goal here is to make the histogram as uniform as possible. Here, Uniformity can either mean that

each gray level has 256 pixels12

or by stretching the histogram in a way that instead of occupying a small

set of values it occupies the entire range of gray level values. We would try both techniques one-by-one.

Wide-Sense histogram equalization

In this method we stretch the original histogram to cover the whole 0-255 range of gray levels. This

technique does not guarantee equal number of pixels in each gray levels, but gives a contrast enhanced

version of input image. We use the following formula:

The meaning of Max. Intensity Levels maximum intensity level which a pixel can get. For example, if the

image is in the grayscale domain, then the count is 255. And if the image is of size 256x256 then, the No.

of pixels is 65536. And the expression is the bracket means the CDF value for the value of input gray

level.This is how we get new intensity levels calculated for the old intensity levels13

In my method I started by calculating the CDF for each image from the histogram data calculated in the

previous parts. I then have the CDF value for each gray level . I normalize it by dividing by (256*256) and

then multiply the whole term by the max. Intensity level i.e 255. The completion of this procedure gives

me a table of new intensity values. I then scan the image stored in imagedata array pixel-by-pixel and

then replace the old intensities by new intensities.

RESULTS FOR WISE-SENSE HISTOGRAM EQUALIZATION

Rose_dark.raw

Rose_dark before linear Scaling Rose_dark after linear Scaling

12

making the image closer to ideal image as per definition 13

www.CoderSource.net

Page 19: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 19

Fig 2.1b: We see the Linear scaling technique converts a rather dark image in an image that is much brighter. The contents of

the image can be easily recognized and the image looks more pleasant to the eyes. However, we see the contouring effects in

the image. The overall quality of the image is degraded while the contrast in increased

New HISTOGRAM

Rose_mid.raw

Rose_mid before histogram equalization Rose_mid after histogram equalization

Page 20: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 20

Fig 2.2b: We see the Linear scaling technique converts a rather flat image to an image that has much more variations and

gradations. The contents of the image can be easily recognized and the image looks more pleasant and vibrant to the eyes

Again we see lack of smoothness in some places This is the countouring effect as wee impose the new intensity on some pixels.

Histogram of the new image

Page 21: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 21

Rose_Bright.raw

Rose_bright before histogram equalization Rose_Bright after histogram equalization

Fig 2.1b: We see the Linear scaling technique converts a rather bright image in an image that has gradations in gray levels. The

contents of the image can be easily recognized and the image looks more pleasant to the eyes.

Histogram of the final image change

Analysis

Dynamic range is clearly increased drastically. The image looks much better then the original image.

Strict Sense Histogram Equalization

Page 22: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 22

As we known, the PDF of a uniform distribution X is equal to X. Therefore, in order to have uniform

distribution for the output image equal to 1, we need to evaluate the new intensities by the following

formula:

New PDF= OLD PDFx(1/OLD PDF)

This way the new Pdf is uniformly distributed at level 1. This implies that each gray level has equal

number of pixels there by abiding with the definition of ideal image.

To implement this in a program, we need the histogram of the original image as a reference. For the

images given for this assignment, there are 256*256=65536 pixels in an image, and the pixel value range

from 0 to 255, i.e. 256 values. Therefore, for each pixel value, there should be 256 pixels assigned to it.

The histogram hence formed will be uniform.

In my implementation, the Input image is recorded in the 3 –D array imagedata which hold the location ,

and value of a pixel. I scan the images one-by one for all values from 0 to 255. I start from zero, and

while scanning for a 0 gray level I count the number of times it occurs in the image. As soon as I

encounter the 256th

occurrence I start replacing the next 0 levels by intensity 1 and continue scanning

till the end of the array which is our last pixel. I continue this procedure for 255 times for each gray level

and slice the whoe image in buckets of 256 pixels with increasing order of gray level intensities.

By doing this, I can achieved a uniform histogram.

Results by Strict sense Histogram equalization

Rose_Bright.raw

Rose_bright before histogram equalization Rose_Bright after histogram equalization

Fig 2.1b: We see the Linear scaling technique converts a rather dark image in an image that is much brighter. The contents of

the image can be easily recognized and the image looks more pleasant to the eyes.

Histogram of the final image

Page 23: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 23

Transfer Function

Analysis

The transfer function that is the CDF is conerted to a srtraigh line. The image looks much better but has

contouring effects.

Rose_mid.raw

0

50

100

150

200

250

300

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

PDF of new image

PDF of new image

0

0.2

0.4

0.6

0.8

1

1.2

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

New CDF for strict sense histogram

equalization

Page 24: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 24

Rose_bright before histogram equalization Rose_Bright after histogram equalization

Fig 2.1b: We see the Linear scaling technique converts a rather dark image in an image that is much brighter. The contents of

the image can be easily recognized and the image looks more pleasant to the eyes.

Histogram of the final image change

Transfer Function

0

50

100

150

200

250

300

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

PDF of new image

PDF of new image

Page 25: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 25

Rose_dark.raw

Rose_bright before linear Scaling Rose_Bright after linear Scaling

Fig 2.1b: We see the Linear scaling technique converts a rather dark image in an image that is much brighter. The contents of

the image can be easily recognized and the image looks more pleasant to the eyes. We can see clear effects of countouring.

Histogram of the final image

0

0.2

0.4

0.6

0.8

1

1.21

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

New CDF for strict sense histogram

equalization

Page 26: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 26

Transfer Function

0

50

100

150

200

250

300

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

PDF of new image

PDF of new image

0

0.2

0.4

0.6

0.8

1

1.2

1

12

23

34

45

56

67

78

89

10

0

11

1

12

2

13

3

14

4

15

5

16

6

17

7

18

8

19

9

21

0

22

1

23

2

24

3

25

4

New CDF for strict sense histogram

equalization

Page 27: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 27

Problem 3

The objective of problem 3 is to study and anaylse different kinds of noises in gray-scale and color

images and learn techniques to remove two kinds of noises in particular.

We will focus on removal of

1. Impulse noise(Salt and pepper noise ) and Uniform Noise.

2. Mixed noise

We need to rectify images affected by these kind of noise and present a hypothesis for the choice of

filters and parameters in each case.

Motivation

Images are often corrupted by different kinds of noise. These noise can come from the recording media,

the channel of communication or some other source. In either case the quality of the image is

degraded and the image becomes unclear or unclean. Noise is a primary problem in processing of digital

images. The principal sources of noise in digital images arise during image acquisition or transmission.

The imaging sensors is affected by a variety of factors, such as environmental conditions during image

acquisition, and by the quality of the sensing elements themselves. For instances, in acquiring images

with CCD camera, light levels and sensor temperature are major factors affecting the amount of noise in

the resulting image. Images are corrupted during transmission principally due to interference in the

channel used for transmission. For eg , an image transmitted using a wireless network might be

corrupted as a result of lightening or any atmospheric disturbances.

Some types of noises are removable and some of them need extensive processing. Basically, we apply

different kinds of filters that can filter out the unwanted signals from the input signal. We will study a

few noise removal methods in detail.

Problem 3.1

In this part we work on images by applying masks or matrix operations. To implement this efficiently we

duplicate our image of size 256x256 into a new image or size 258x258. This is done by copying the

columns and rows at the boundary of original image to their adjacent empty new location on the mew

image.

This done to be able to apply the mask efficiently on the pixels at the boundary. If we Ignore the copying

of pixels in new rows and columns and let their value be zero, then this could affect the application of

mask as the gray level 0 denotes the color Black and hence can make the boundaries go relatively

darker because of this dark pixel. This is because most of the masks are averaging filters. We will analyze

these techniques in depth in the further discussions.

Objective: Gray-Level Image

Page 28: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 28

Problem 3.1.b- IMPULSE NOISE

Impulse noise is a category of noise which includes unwanted, almost instantaneous (thus impulse-like)

sharp peaks. Noises of the kind are usually caused by electromagnetic interference, scratches on the

recording media, and ill synchronization in digital recording and communication.14

Salt and pepper noise is a form of noise typically seen on images. It represents itself as randomly

occurring white and black pixels. Usual and effective noise reduction method for this type of noise

involves the usage of median filter.15

We try different approaches in treating our input image for impulse noise removal.

We use the concept of neighborhood processing in removing these kind of noises. The spatial

distribution of these images can show a distinct difference in values of pixels when a noise is present in a

particular section of the image. Pixels carrying noise are usually marked with a very high or very low

value than its neighboring pixels. The reason for this is the composition of the image. An image is

comprised of similar values of pixels to represent a surface and high frequency pixels to represent

edges. However, the noise forms a different distribution pattern. These noisy pixels are evident from

analyzing the spatial distribution of an image. Any value that is outrageously different from its

neighboring pixel values is often considered as noise.

We will start analyzing an Image for noise by picking up a set of pixels that are spatially connected and

analyze their values for any possible values of noise.

Median filter:

Procedure

Im my first approach I choose nine pixels that are spatially connected in form of a 3x3 matrix starting

from the first pixel of my new 258x258 image. Ifix the center pixel at origin and name the other pixels as

per their location in coordinates. For example, If the center pixel is (x,y), I name its adjacent pixel to the

left as (x-1,y) and the one to the right as (x+1,y). Similarly I name all the pixels. I then store these values

in an array and ascending order of values.

We then choose the median16

of the array and replace the center pixel with the median value. We

repeat the process for each matrix of pixel till the last pixel is analyzed.

Explanation

14

http://en.wikipedia.org/wiki/Impulse_noise_(audio) 15

http://en.wikipedia.org/wiki/Salt_and_pepper_noise 16

A median is the center value if the data is arranged in an ascending order.

Page 29: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 29

As we know, that the impulse nose is either represented as 0 or 255 in the case of salt and pepper noise,

sorting the data in a ascending order brings 0 to the 1st

entry and 255 to the last one. As we are choosing

the middle value, both 0 and 255 are excluded from the result and hence we are able to exclude the

noise.

Results

Pepper_imp( given imge) Pepper_imp after median filtering

Analysis

Pepper_original image Pepper_imp after median filtering

Page 30: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 30

We are able to primarily remove all noise. However, we see a very few noise pixels in the output image.

The reason for this could be that, the noise in these regions is so significant that the median turns out to

be the noise itself. It could also happen that the noise is not a 0 or 255 level. In which case it can lie

within a range that can be taken as no-noise by the filter.

Median filter can be cascaded or the sze of matrix can be increased or decreased depending on our

requirement. We can also consider a cross type combination of 9 pixels and analyze the image for noisy

pixels.

To keep a double check, I have taken care that if the median is a noisy pixel, then the original pixel will

not be replaced by the noisy pixel. The total result works very good.

In our case, 3x3 matrix median filter works very efficiently.

Pseudo Median Filtering:

It is believed that median filter is computationally intensive; the number of operations grows

exponentially with window size . for decreasing the complexity of the algorithm and making the method

more efficient we try the miniman-maximin approach named Pseudo median filter.

Elplanation:

Let SL denote the sequence of elements s1,s2,….SL. The pseudomedian of the sequence is

PMED{SL} = (1/2) (MAXMIN{SL}) + MINIMAX{SL} —1-D case

PMED{SE}= ½ MAX[MAXIMIN{XC},MAXIMIN{YR}] - 2D CASE

+ ½ MIN[MINIMAX{XC},MINIMAX{YR}

Where for M=(L+1)/2

MAXIMIN{SL} =MAX{[MIN(s1,,,,,,sM)],[MIN(s2,…sM+1)]…….,,,[MIN(sL-M+1,,,,,sL)]}

MANIMAX{SL} =MIN{[MAX(s1,,,,,,sM)],[MAX(s2,…sM+1)]…….,,,[MAX(sL-M+1,,,,,sL)]}

Operationally,the sequence of L elements is decomposed into Subsequences of M elements,each of

which is slid to the right by one element in relation to its predecessor and the appropriate MAX and MIN

operations are computed. It is also possible to recursively decompose the Max Min functions on long

sequences into sliding fucctions of length 2 and 3 for pipeline computation.We compute MAX,MIN

functions over rectangular windows and this filter tends to smoothen image.In my program,I am taking

min(1,2,..5)pixels,min(2,3…6),min(3,4,,…7) till min(5,6….9) pixel and max of all these values and I replace

the center pixel by that max value as mentioned in the book.17

The basic logic behind it is taking different sets of spatially related pixels and processing them. In

MINIMAX, we take minimum values of these sets and chose the maximum value out of those. We repeat

17

Digital image processing by pratt.

Page 31: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 31

the procedure for MAXIMIN. We do this for horizontal and vertical rows and compute the output of the

center pixel by the above formula. We do this assuming the neighborhood information of a spatially

distributed image is related to each other. Hence considering all the possible combinations can provide a

higher level of analysis of data.

Result:

Pepper_imp( given imge) Pepper_imp after pseudo median filtering

Pepper_imp after pseudo median filtering Pepper_imp after cascading pseudo median and

median filtering

Page 32: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 32

Pepper_original image Pepper_imp after median filtering

We see that by applying psudo-median filter to a 3x3 matrix of our image, we were not able to remove

the noise completely. This is because for our composition of image, Median filter work better and

pseudo filter takes some pixels that are noise as desired pixels.

Outlier Filter

Here we compare the center pixel with the average of the surrounding pixels. If the difference between

these pixels is is higher then a threshold value T, we consider this center pixel as noise. And replace this

with the average of the surrounding pixels. The formula below represents the outlier filter.

As T is chosen by the user here, we have to test image for various values of T that gives a better result.

Cascading different filters. Shown above

Page 33: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 33

Problem 3.1.b Uniform noise

The uniform noise being an additive noise, adds itself to each pixel in the image. Hence, the histogram

of the image with uniform noise is uniform in nature. This makes it difficult to apply filters like median

, pseudo median and outlier to remove the noise as all these filter are based on difference in values in

the neighboring pixels.

The approach we use here is to apply different masks that scale different pixels in such a way that the

center pixel is given a value different but related to its neighbors.

These masks act as low pass of high pass filters as per their construction. Most of them are averaging

filter but with different values scaled with different weights. Lets discuss a few of Masks for uniform

noise removal in detail.

Application of these masks: Application of these masks is analogous to the way we treat noise in

frequency domain. We convolute these masks with our chosen matrix and replace the center pixel with

the average of convolved values.

The most basic type of mask is the matrix represented as

MASK1 = 1/9*[(1, 1,1)t (1, 1,1)

t (1, 1,1)

t ]

This is nothing but a simple averaging filter as it is simply adding all the elements of chosen matrix and

dividing it by 9 which is the sum of pixels of our mask.

Mask2 = 1/10*[(1, 1,1)t (1, 2,1)

t (1, 1,1)

t]

This is a similar mask but here we are multiplying the center pixel with a value 2. This is done because

we wish to give higher importance to the center pixel as opposed to the pixels in the surroundings.

Mask2 = 1/16*[(1, 2,1)t (2, 4,2)

t (1, 2,1)

t]

Similar to the masks above, here we are adding weight to the center pixel and immediate neighbors of

the center pixels.

These masks are low pass masks with all positive elements. These arrays are called noise cleaning masks

and are normalized to unit weighting so that noise cleaning process doesn not introduce an amplitude

bias in the processed image.

Since all these are averaging filter, they reduce the sharpness of the image hence, making the image

blur. Adding weights to the center pixels helps in reducing the blur effect of the process and try to

remove the noise.

Other MASKs

Mask4=1/48*[(1 2 2 2 1)t (2 2 2 2 2)

t (2 2 4 2 2)

t (2 2 2 2 2)

t (1 2 2 2 1)

t];

Page 34: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 34

Results

Pepper_uni before filtering Pepper_uni after mask 1

Conclusion and reasons

Pepper_original image Pepper_uni after mask 1

Pepper_uni before filtering Pepper_uni after mask 2

Page 35: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 35

Pepper_uni before filtering Pepper_uni after mask 3

Problem 3.2 Color noise

Objective

We have been given a color image that has each channel embedded with mixed noise. We need to

process this image for noise removal and compare it with original image.

The noise in color image is similar to the noise in gray level. However, this noise in color image is

distributed in different channels. The resulting images had noises in all three channels. Hence, the noise

removal process for noisy color images is the same as above but we need to process each channel of the

image for the similar kind of noise.

Also, since this is a mixed noise, we process each channel of the image for different kind of noise like,

impulse noise and uniform noise. We try out different cascading of noise removal techniques to remove

the maximum noise form the image.

Page 36: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 36

Color_noise before filtering Color_noise after cascasing mask3 and median filter

Color_noise after cascasing mask2 only Color_noise after second cascade of median filter

Color_noise after cascasing mask3 only Color_noise after psuedo median filter

Page 37: watermarking- image enhancement- noise removal

EE 569- Fall’08 | ID- 5994499980 37

Results

Analysis

Original image Best result

The image shows lot of blurring effects as the filters are averaging filter. We were not able to remove

the noise completely in any of the above cases.