{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

rec5 - CS 177 Week 5 Recitation Slides Mirroring and...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS 177 Week 5 Recitation Slides Mirroring and copying images, Using for Loop, if statement, and range
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Announcements EXAM 1 Wednesday 09/29 6:30p - 7:30p EE 129
Background image of page 2
3 ANY QUESTIONS?
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Horizontal mirror recipe mirroring means intuitively "flipping around" an axis (when you mirror horizontally, you flip your picture around a vertical axis) STEP 1. Since the picture is represented by a matrix, you must determine the coordinates (x and y) of all the "points" of this axis in the matrix STEP 2. Then you have to determine the direction of the flipping (when you mirror horizontally, you may flip the left side to right side or vice versa) STEP3. Now, since pictures are encoded as a matrices, you must figure out where a pixel of the source picture should go in the target picture 4
Background image of page 4
Step 1- determine the mirror axis Step 2 - determine the flipping direction 5 1 2
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Work it out with matrices To find out the mirror axis you need just to determine its x coordinate (the mirrorPoint). It is is halfway across: getWidth(picture)/2 6
Background image of page 6
Work it out with matrices STEP 2. If the flipping direction is left to right, then the source and target matrices will look like this: 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Step 3 Figure out where a pixel of the source picture should go in the target picture 8 If source pixel is at (x,y), target pixel is at (width-x-1,y)
Background image of page 8
Recipe for vertical mirroring def mirrorVertical(source): mirrorPoint = getWidth(source) / 2
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}