22
October 29, 2013 1

image processing - zooming and shrinking

Embed Size (px)

Citation preview

Page 1: image processing - zooming and shrinking

October 29, 2013 1

Page 2: image processing - zooming and shrinking

October 29, 2013 2

1. Introduction

2. Zooming

3. shrinking

Page 3: image processing - zooming and shrinking

October 29, 2013 3

Determine (f) with gray level resolution of 2k , when

1. K = 5

2. K = 3

The pixel values of the following 5x5 image are represented by 8-bit

integers:

Introduction

Page 4: image processing - zooming and shrinking

October 29, 2013 4

Dividing the image by 2 will reduce its gray level resolution by one bit.

Hence to reduce the gray level resolution from 8-bit to 5-bit, we have to reduce

3-bits.

8bits – 5bits = 3 bits will be reduced

Thus, we divide the 8-bit image by 8 ( 23 ) to get the following 5-bit image:

Page 5: image processing - zooming and shrinking

October 29, 2013 5

Similarly, to obtain 3-bit image, we divide the 8-bit image by (32) 25

Page 6: image processing - zooming and shrinking

October 29, 2013 6

Zooming

Zooming may be viewed as oversampling. It is the scaling of an image area A of

w×h pixels by a factor s while maintaining spatial resolution (i.e. output has

sw×sh pixels).

Zooming: increasing the number of pixels in an image so that the image appears

larger

Zooming requires two steps:

• creation of new pixel locations

• assignment of gray level to those new locations

Page 7: image processing - zooming and shrinking

October 29, 2013 7

The black pixels represent empty spaces where interpolation is needed, and the

complete picture is the result of nearest neighbor interpolation.

Scaling algorithm is to find appropriate spot to put the empty spaces inside the

original image, and to fill all those spaces with livelier colors.

Page 8: image processing - zooming and shrinking

October 29, 2013 8

Nearest neighbor interpolation

Bilinear interpolation

K-Times zooming

Image interpolation is used to change the X and Y dimensions of an image

There are many methods of gray level assignments, for examples:

Page 9: image processing - zooming and shrinking

October 29, 2013 9

Is performed by repeating pixel values, thus creating checkerboard effect. Pixel

replication (a special case of nearest neighbored interpolation) is used to

increase the size of an image an integer number of times. The example below

shows 8-bit image zooming by 2x (2 times) using nearest neighbor interpolation.

Nearest neighbor interpolation (zero order hold)

Page 10: image processing - zooming and shrinking

October 29, 2013 10

Page 11: image processing - zooming and shrinking

October 29, 2013 11

Bilinear interpolation (First order hold)

Page 12: image processing - zooming and shrinking

October 29, 2013 12

Page 13: image processing - zooming and shrinking

October 29, 2013 13

Page 14: image processing - zooming and shrinking

October 29, 2013 14

K-Times zooming

• you have to take two adjacent pixels as you did in the zooming twice. Then you

have to subtract the smaller from the greater one. We call this output (OP).

• Divide the output(OP) with the zooming factor(K). Now you have to add the

result to the smaller value and put the result in between those two values.

• Add the value OP again to the value you just put and place it again next to the

previous putted value. You have to do it till you place k-1 values in it.

• Repeat the same step for all the rows and the columns , and you get a zoomed

images.

Page 15: image processing - zooming and shrinking

October 29, 2013 15

Suppose you have an image of 2 rows and 3 columns , which is given below.

And you have to zoom it thrice or three times.

K in this case is 3. K = 3.

The number of values that should be inserted is k-1 = 3-1 = 2.

15 30 15

30 15 30

Example

Page 16: image processing - zooming and shrinking

October 29, 2013 16

Row wise zooming

Take the first two adjacent pixels. Which are 15 and 30.

Subtract 15 from 30. 30-15 = 15.

Divide 15 by k. 15/k = 15/3 = 5. We call it OP.(where op is just a name)

Add OP to lower number. 15 + OP = 15 + 5 = 20.

Add OP to 20 again. 20 + OP = 20 + 5 = 25.

We do that 2 times because we have to insert k-1 values.

Now repeat this step for the next two adjacent pixels. It is shown in the first

table.

After inserting the values , you have to sort the inserted values in ascending

order, so there remains a symmetry between them.

It is shown in the second table

Page 17: image processing - zooming and shrinking

October 29, 2013 17

Column wise zooming

The same procedure has to be performed column wise. The procedure include

taking the two adjacent pixel values, and then subtracting the smaller from the

bigger one. Then after that , you have to divide it by k. Store the result as OP.

Add OP to smaller one, and then again add OP to the value that comes in first

addition of OP. Insert the new values.

Here what you got after all that

15 20 25 30 25 20 15

20 21 21 25 21 21 20

25 22 22 20 22 22 25

30 25 20 15 20 25 30

Page 18: image processing - zooming and shrinking

October 29, 2013 18

New image size

The best way to calculate the formula for the dimensions of a new image is to

compare the dimensions of the original image and the final image. The

dimensions of the original image were 2 X 3. And the dimensions of the new

image are 4 x 7.

The formula thus is:

(K (number of rows minus 1) + 1) X (K (number of cols minus 1) + 1)

Advantages and disadvantages

The one of the clear advantage that k time zooming algorithm has that it is able

to compute zoom of any factor which was the power of pixel replication algorithm

, also it gives improved result (less blurry) which was the power of zero order

hold method. So hence It comprises the power of the two algorithms.

The only difficulty this algorithm has that it has to be sort in the end , which is an

additional step , and thus increases the cost of computation.

Page 19: image processing - zooming and shrinking

October 29, 2013 19

15 20 25 30 20 25 15

30 25 20 15 20 25 30

15 20 25 30 25 20 15

30 25 20 15 20 25 30

Page 20: image processing - zooming and shrinking

October 29, 2013 20

Shrinking

Page 21: image processing - zooming and shrinking

October 29, 2013 21

Shrinking, in the other hand involves reduction of pixels and it means lost of

irrecoverable information. In this case scaling algorithm is to find the right

pixels to throw away.

Page 22: image processing - zooming and shrinking

October 29, 2013 22