+ All Categories
Home > Documents > Image Processing

Image Processing

Date post: 21-Jan-2016
Category:
Upload: britain
View: 53 times
Download: 0 times
Share this document with a friend
Description:
Image Processing. Image processing. Once we have an image in a digital form we can process it in the computer . We apply a “filter” and recalculate the pixel values of the processed image. We will look at the application of filters to sharpen and soften (make less sharp) the image. - PowerPoint PPT Presentation
Popular Tags:
23
Image Processing
Transcript
Page 1: Image Processing

Image Processing

Page 2: Image Processing

Image processing

• Once we have an image in a digital form we can process it in the computer.

• We apply a “filter” and recalculate the pixel values of the processed image.

• We will look at the application of filters to sharpen and soften (make less sharp) the image.

Page 3: Image Processing

Filters or Kernals

• Our filters take the form of a small matrix or vector which we place (in turn ) over the image at each pixel position.

• Typically our filters are symmetrical 3 x 3 matrices.

• We use a process called convolution to apply the filter to the image.

Page 4: Image Processing

Convolution

• Convolution is the process of multiplying each element of our filter by the pixel values of the image that the filter covers and adding the products.

• We can describe the result as “the original image convolved with the filter”.

• conv2 is a Matlab function which can do this.

Strictly what is described above is not a convolution but a correlation, however if our filters are symmetric the result is the same.

Strictly what is described above is not a convolution but a correlation, however if our filters are symmetric the result is the same.

Page 5: Image Processing

Convolution and filters

Filter

Image sample set

56

56

5656

565659 89 15

1 4 52 3 79 4 5

04

0

0 0-1-1

-1-1

04

0

0 0-1-1

-1-1

Page 6: Image Processing

Convolution and filters

Image sample set

56

56

5656

565659 89 15

1 4 52 3 79 4 5

04

0

0 0-1-1

-1-1

Page 7: Image Processing

Convolution and filters

1 4 52 3 79 4 5

04

0

0 0-1-1

-1-1

34 5

59 47

5

904)1(90

7)1(342)1(

504)1(10

newvalue

So the value of 3 in the centre of the original image is replaced with –5 on the convolved image.

Page 8: Image Processing

Image softening

• If we make all the elements of the filter equal to one ninth, then the convolution value will be the average of all the elements “covered” by the filter.

• It is the same as adding all the 9 values together and dividing by nine.

Page 9: Image Processing

Image softening

• The following block of image samples represents a sharp vertical edge as pixel values suddenly change from 0 (black) to 255 (white).

• We will attempt to smooth it (make it less sharp).

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

Sample Block

Page 10: Image Processing

Image softening

• Consider the operation of the averaging filter on the block of image samples.

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

1/9 1/9 1/9

1/9 1/9 1/9

1/9 1/9 1/9

Filter

Sample Block

Page 11: Image Processing

Image softening

• As we “run” the filter over the centre of the sample block. The following changes will take place. See next slide.

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

0 0 0 0 255 255 255 255

Sample BlockFilter

Page 12: Image Processing

Image softening

• The zeros in the 4th column are replaced with 85, since:

0 0 0 0 255 255 255 255

0 0 0 85 255 255 255 255

0 0 0 85 255 255 255 255

0 0 0 85 255 255 255 255

0 0 0 0 255 255 255 255

859

1255

9

10

9

10

9

1255

9

10

9

10

9

1255

9

10

9

10

Page 13: Image Processing

Image softening

• Similarly as we perform the convolution of the filter with the rest of the centre of the sample block we get:

0 0 0 0 255 255 255 255

0 0 0 85 170 255 255 255

0 0 0 85 170 255 255 255

0 0 0 85 170 255 255 255

0 0 0 0 255 255 255 255

Page 14: Image Processing

Image softening

• The resultant convolution (image) no longer has a sharp edge, but a more gradual one.

0 0 0 0 255 255 255 255

0 0 0 85 170 255 255 255

0 0 0 85 170 255 255 255

0 0 0 85 170 255 255 255

0 0 0 0 255 255 255 255

Page 15: Image Processing

Image softening

• That’s the theory; lets try it.

for i=1:256grey(i, 1:3)=(i-1)/255endcolormap(grey)myedge=zeros(5, 8)myedge(:, 5:8)=255filt=ones(3,3)/9image(myedge)myconv=conv2(myedge,filt, 'valid')image(myconv)

Page 16: Image Processing

Softening an image

im=imread(‘urban.bmp');smooth=[ 1 1 1; 1 1 1; 1 1 1]/9% convolve all colourssmoothim(:,:,1)=conv2(im(:,:,1),smooth

);smoothim(:,:,2)=conv2(im(:,:,2),smooth

);smoothim(:,:,3)=conv2(im(:,:,3),smooth

);image(im)figureimage(uint8(smoothim))

Page 17: Image Processing

Image sharpening

• It is easier to see this in one dimension initially.

• Consider some neighbouring pixels that are not sharp.

• If they are not sharp there will be no abrupt change in value between them.

• If we can cause an a more abrupt change in value between neighbouring pixels, we will sharpen the image.

Page 18: Image Processing

Image sharpening

• It is easier to see this in one dimension initially.

• Consider some neighbouring pixels that are not sharp.

• If they are not sharp there will be no abrupt change in value between them.

• If we can cause an a more abrupt change in value between neighbouring pixels, we will sharpen the image.

Page 19: Image Processing

Image sharpening

• The idea is to generate artificial sharp edges at the points of differing neighbouring pixels and then add these edges to the original image.

• The following diagram shows the variation in brightness values for:– (a) A perfect (sharp) edge.– (b) A blurred edge.– (c) The artificial correction to be

added.– (d) The corrected (enhaced) edge.

Page 20: Image Processing

Image sharpening

100

200

100

200

150

50

-50250

50100

150

200

(a)

(b)

(c)

(d)

Page 21: Image Processing

Image sharpening

• What kernal (filter) will (when convolved with the image) generate the correction waveform (c) ?

• In one dimension • Check it.

– It produces zero for flat fields, but a negative and positive edge at edges

• In two dimensions

04

0

0 0-1-1

-1-1

2-1 -12

Page 22: Image Processing

Image sharpening

• We need to produce a kernal which will add the artificial edges and the original together.

• The original will be produced if we only have a one (1) in the centre of the a convolution kernal. Check it.

• Add this to the edge generator + =

01

0

0 000

00

04

0

0 0-1-1

-1-1

01

0

0 000

00

05

0

0 0-1-1

-1-1

Page 23: Image Processing

Sharpening an Image

im=imread(‘urban.bmp');

sharp=[ 0 –1 0; -1 5 –1; 0 –1 0]

% convolve all colours

sharpim(:,:,1)=conv2(im(:,:,1),sharp);

sharpim(:,:,2)=conv2(im(:,:,2),sharp);

sharpim(:,:,3)=conv2(im(:,:,3),sharp);

image(im)

figure

image(uint8(sharpim))


Recommended