{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

1 CS 177 Week 5 Recitation Slides Mirroring and copying images, Using for Loop, if statement, and range

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

View Full Document
2 Announcements EXAM 1 Wednesday 09/29 6:30p - 7:30p EE 129
3 ANY QUESTIONS?

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

View Full Document
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
Step 1- determine the mirror axis Step 2 - determine the flipping direction 5 1 2

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

View Full Document
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
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

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

View Full Document
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)
Recipe for vertical mirroring def mirrorVertical(source): mirrorPoint = getWidth(source) / 2

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}