Download presentation
Presentation is loading. Please wait.
Published byWarren Goodwin Modified over 6 years ago
1
Gray Scale picture def pixBW(pixel): # given a pixel, change to BW
get R,G,B values of the pixel compute the average set R,G,B values of the pixel to the average return def picBW(pic): get the width of pic, and name it get the height of pic, and name it for every y coordinate: for every pixel in the row at the given row y: call pixBW(pixxx)
2
What is wrong with this picture ?
3
Doing something useful with mirroring
4
Vertical Mirroring Imagine a mirror horizontally across the picture, or vertically What would we see? How do generate that digitally? We simply copy the colors of pixels from one place to another
5
Vertical Mirroring 1 2 3 4 Think of a number at each x and y location instead of a color Note that the distances from the middle column are identical in both directions 1 2 3 4 5 1 2 1 2 3 5 4
6
How do we design Algorithm for this ?
Slicing a picture down the middle and sticking a mirror on the slice Do it by using a loop to measure a difference x mirrorpoint y x x
7
Algorithm (recipe) Use a distance from the mirror point
Then reference to either side of the mirrorpoint using the difference
8
1 2 3 4 5 Loop through all the rows (y starts at 1, increments by 1, and is less than the picture height) For each row, Loop with x starting at 1 and x less than the midpoint (mirror point) value Get the left pixel at (mirrorpoint-x, y) Get the right pixel at (mirrorpoint+x, y) Set the color for the right pixel to be the color of the left pixel 1 2 3 5 4
9
How does it work? Compute the half-way horizontal index
The y value travels the height of the picture The x value is an offset It’s not actually an index It’s the amount to add or subtract We copy the color at mirrorpoint-offset to mirrorpoint+offset
10
Can we make a horizontal mirror?
11
Messing with Santa some more
Copy bottom to top
12
Lab_1102 Complete the Python program for one of image processings (gray scale, sunset, posterizing) Write a Python program for a vertical mirroring the Python program file to
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.