Presentation is loading. Please wait.

Presentation is loading. Please wait.

Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce.

Similar presentations


Presentation on theme: "Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce."— Presentation transcript:

1 Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce the DVE (digital video effect). We will consider scaling, translation and rotation.

2 Graphic Manipulation Manipulation achieved as a series of transformations. These transformation achieved by matrices. Called transformation matrices. Complex manipulation is achieved by combination (multiplication) of the basic transformation matrices. We will see that the order of multiplication is important.

3 Manipulating a picture In bitmaps we have to manipulate each pixel in the image. There are three basic operations: –Translation (moving left/right, up/down) –Scaling (making smaller/larger) –Rotation (turning through some angle) Others can be made from combinations of the above.

4 The equations of manipulation Translation Scaling. Rotation.

5 Matrix multiplication Multiply each element of a row of the first matrix by each element of the corresponding column of the second matrix. Add the products together. Put the result in position (row of first matrix, column of second matrix) of a new matrix. Repeat for all rows of the first matrix. Means that the number of rows of the first matrix must be the same as the number of columns of the second matrix. Easy for computers.

6 Matrix multiplication Example: Try it with Matlab. A=[5 8 ; 7 2] B=[6 1 ; 4 3] A*B Try B*A Not the same.

7 The equations in a matrix form. Scaling Rotation Translation –Could add a translation matrix of a similar form, but it would be simpler if all matrices could be just multiplied by the original co- ordinates.

8 The equations in a “homogeneous” matrix form. Translation –Special 3x3 form allows translation by multiplication. Scaling Rotation

9 The Matlab DVE dve.m Need to make transformation matrix first. Lets try scaling: –Tr=[0.5 0 0; 0 0.5 0; 0 0 1] Also find or make two.bmp files of the same size. Syntax –dve –You are prompted to enter the names of the foreground and background pictures, followed by the transformation matrix. Try it.

10 Exercises in translation, scaling and rotation Now create your own transformation matrices for the following: Translation –Move the foreground picture 200 pixels up and 50 pixels across Scaling –Scale the foreground picture to a tenth of its height and a third of its width. Rotation –Rotate the foreground picture by 45 o clockwise. (You need to call 45 o pi/4 radians for Matlab)

11 Compound Transformations By multiplying different types of transformation matrix, we can do two (or more) transformations at once. Effectively this transforms the already transformed image.

12 Compound Transformations For example: Scaling followed by rotation.

13 Compound Transformations For example: Scaling followed by translation.

14 Order of transformation matrices Note that Scaling followed by translation is not the same as translation followed by scaling, because we scale the translation in the second case. Rotation followed by scaling distorts the transformation matrix and results in “skew”.

15 Order of transformation matrices This is true of all compound transformations, so the order is important. Also, because the transformation matrix is multiplied by the object to be transformed, rather than the other way around, “later” operations are on the left of any expression. This may look like the wrong way round.

16 Exercises in compound transformations. Produce a matrix which produces a two times increase in height, halves the width, and rotates the original image. Repeat the above, but move the image 40 pixels down and 100 pixels across also. Now reverse the order of the transformations and observe the effect. Try your own.

17 Scaling in PDF In PDF we change the “current transformation matrix” of the “graphics state” using the cm operator. For scaling: – s x 0 0 s y 0 0 cm

18 Translation in PDF In PDF we change the “current transformation matrix” of the “graphics state” using the cm operator. For translation: – 1 0 0 1 t x t y cm

19 Rotation in PDF In PDF we change the “current transformation matrix” of the “graphics state” using the cm operator. For rotation: – cos  sin  -sin  cos  0 0 cm –Eg 0.707 0.707 –0.707 0.707 0 0 cm rotates the current co-ordinates by 45 o

20 Further information Hill, Computer Graphics. Prentice Hall. Adobe specifications available from www.adobe.com –Postscript –PDF


Download ppt "Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce."

Similar presentations


Ads by Google