HW 3: Problems 2&3. HW 3 Prob 2:Encipher encipher( S, n ) takes as input a string S and a non-negative integer n between 0 and 25. This function returns.

Slides:



Advertisements
Similar presentations
Spreadsheet Vocabulary
Advertisements

Lesson 3 Working with Formulas.
Computer Science 111 Fundamentals of Programming I More Digital Image Processing.
Q UIZ Direction: Choose the correct answer from the given choices. Begin.
The Binary Numbering Systems
 Caesar used to encrypt his messages using a very simple algorithm, which could be easily decrypted if you know the key.  He would take each letter.
1 Normal Probability Distributions. 2 Review relative frequency histogram 1/10 2/10 4/10 2/10 1/10 Values of a variable, say test scores In.
Lecture 4 Linear Filters and Convolution
1 The Normal Probability Distribution. 2 Review relative frequency histogram 1/10 2/10 4/10 2/10 1/10 Values of a variable, say test scores
HW 1: Problems 3 & 4 EC 1 & 2.
The Normal Distribution
Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc. 8.1 Chapter 8 Continuous Probability Distributions.
A Novel 2D To 3D Image Technique Based On Object- Oriented Conversion.
Computer Science 111 Fundamentals of Programming I Introduction to Digital Image Processing.
5. 1 JPEG “ JPEG ” is Joint Photographic Experts Group. compresses pictures which don't have sharp changes e.g. landscape pictures. May lose some of the.
2.1: Frequency Distributions and Their Graphs. Is a table that shows classes or intervals of data entries with a count of the number of entries in each.
Tickertape def tickertape(directory,string): for each frame to generate create an new canvas write the string on canvas slightly left of the previous frame.
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
AGB 260: Agribusiness Information Technology Advanced Functions and Logic.
Spring  Evolving Lists & Lights On!  Caesar Cipher  Looks Good!
TOPIC 7 MODIFYING PIXELS IN A MATRIX NESTED FOR LOOPS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by.
Copyright © 2013, 2009, and 2007, Pearson Education, Inc. 1 PROBABILITIES FOR CONTINUOUS RANDOM VARIABLES THE NORMAL DISTRIBUTION CHAPTER 8_B.
Chapter 6: Modifying Pixels by Position. Chapter Learning Goals.
EECS 110: Lec 8: Lists of Lists Aleksandar Kuzmanovic Northwestern University
STRINGS CMSC 201 – Lab 3. Overview Objectives for today's lab:  Obtain experience using strings in Python, including looping over characters in strings.
 1. x = x = 11/15 3. x = x = x ≤ 7 6. x > x ≥ 3/2 8. x ≤ hours or more 10. x = x = 27/ x =
Computer Science 112 Fundamentals of Programming II Graphics Programming.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. M I C R O S O F T ® Refining Original Illustrations Lesson 9.
… Caesar Cipher: encipher encipher( 'gv vw dtwvg', 0 ) encipher( 'gv vw dtwvg', 1 ) encipher( 'gv vw dtwvg', 2 ) encipher( 'gv vw dtwvg', 3 ) encipher(
1 CSC 427: Data Structures and Algorithm Analysis Fall 2008 Algorithm analysis, searching and sorting  best vs. average vs. worst case analysis  big-Oh.
1 CS 177 Week 5 Recitation Slides Mirroring and copying images, Using for Loop, if statement, and range.
Comprehending List Comprehensions
CSC508 Convolution Operators. CSC508 Convolution Arguably the most fundamental operation of computer vision It’s a neighborhood operator –Similar to the.
Chapter 8 Continuous Probability Distributions Sir Naseer Shahzada.
EECS 110: Lec 8: Lists of Lists Aleksandar Kuzmanovic Northwestern University
Python Programming in Context Chapter 6. Objectives To understand pixel based image processing To use nested iteration To use and understand tuples To.
Data Representation. What is data? Data is information that has been translated into a form that is more convenient to process As information take different.
1 Arrays of Arrays An array can represent a collection of any type of object - including other arrays! The world is filled with examples Monthly magazine:
EECS 110: Lec 9: Review for the Midterm Exam Aleksandar Kuzmanovic Northwestern University
Copyright © Curt Hill Further Picture Manipulation Considering position.
EECS 110: Lec 8: Lists of Lists Aleksandar Kuzmanovic Northwestern University
More String Manipulation. Programming Challenge Define a function that accepts two arguments: a string literal and a single character. Have the function.
Click once to reveal the definition. Think of the answer. Then click to see if you were correct. Spreadsheet / Workbook A grid of rows and columns containing.
AGB 260: Agribusiness Information Technology Advanced Functions and Logic.
EECS 110: Lec 8: Lists of Lists
AP CSP: Pixelation – B&W/Color Images
Spring 2010 EECS 110: Homework III.
high-level operations on pictures
EECS 110: Lec 9: Review for the Midterm Exam
Caesar Cipher: encipher
Frequency Distributions and Their Graphs
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Each column represents another power of the base
Color Values All colors in computer images are a combination of red, green and blue Each component is encoded as a number means the color is.
Ch2: Data Representation
Chapter 10 Lists.
Gray Scale picture def pixBW(pixel): # given a pixel, change to BW
CSc4730/6730 Scientific Visualization
Numbers and their bases
Fundamentals of Programming I Introduction to Digital Image Processing
Spring 2015.
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Half Term 1 Please type your name here:.
Digital Image Processing
CSC 427: Data Structures and Algorithm Analysis
EECE.2160 ECE Application Programming
Hash Maps Implementation and Applications
EECE.2160 ECE Application Programming
CSC 221: Introduction to Programming Fall 2018
Lecture 23 – Practice Exercises 5
Presentation transcript:

HW 3: Problems 2&3

HW 3 Prob 2:Encipher encipher( S, n ) takes as input a string S and a non-negative integer n between 0 and 25. This function returns a new string in which the letters in S have been rotated by n characters. For this problem, you should assume that.... upper-case letters are "rotated" to upper-case letters lower-case letters are "rotated" to lower-case letters all non-alphabetic characters are left unchanged. Examples: Shift ‘y’ by 3  ‘b’ Shift ‘Y’ by 3  ‘B’

abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 90 ASCII VALUES HW 3 Prob 2:Encipher chr(66) is 'B' ord('a') is 97 What is chr( ord('i')+13 )'v' What is chr( ord('P')+13 ) ']'

HW 3 Prob 2:Encipher Wala! If c was ‘x’  def adv13( c ): """ rotates c by 13 chars, "wrapping" as needed NON-LETTERS DO NOT CHANGE! """ if 'a' <= c <= 'z': #neword = neword = ord(c) + 13 if neword <= ord('z'): return chr(neword) # no wrapping else: #chr( – )  chr(107)  ‘k’ return chr(ord('a')+neword-ord('z')-1) elif 'A' <= c <= 'Z': # same as above, only use 'A' and 'Z' else: return c

HW 3 Prob 2:Decipher decipher decipher should return the original English string from an encoding, to the best of its ability. Note: some strings have more than one English "deciphering." What's more, it is very difficult to handle short strings correctly. Thus, your decipher does not have to be perfect. However, you could use letter frequencies -- a function is provided online. - Scrabble scores have also been suggested!?! - You might want also to use some additional "heuristics" (rules of thumb) of your own design.

HW 3 Prob 2:Decipher def decipher(S): """ go through all rotations and see which makes most sense "" encoded word is ‘Nkuc’ #create all 26 possibilities [‘Olvd’,’Pmwe’,….] (Hint: use your encoding function!) …. #create list of lists of prob for each letter [[#,#,#,#],[#,#,#,#]….[…]] (could use scrabble score for this…) …. #sum the letter probabilities [ #, #, …., #] …. #find the maximum probability  MAX FROM PREVIOUS LIST ….. #search for index where there is the maximum  use a for loop? …. #return most likely decoding…. ….

HW 2 Prob 3: Looks Good! Click here to for set up instructions… s09/hw/hw3/hw3pr3.htm

HW 2 Prob 3: Looks Good! pixels: [ [(3, 10, 100), (3, 11, 110)], [(3, 10, 200), (10, 110, 290)] ] Width: len(pixels[0]) Height: len(pixels) 2x2 pixel image

[ L[j][0] for j in range(2) ] L [[42, 43], [44, 45]] [ [L[0][i]] for i in range(2) ] [ [ L[j][i]+1 for i in range(2) ] for j in range(2) ] HW 2 Prob 3: Looks Good! Comprehending List Comprehensions [42, 44] [42, 43] [[43,44][45,46]]

HW 2 Prob 3: Looks Good! [ [(3, 10, 100), (3, 11, 110)], [(3, 10, 200), (10, 110, 290)] ] Tuples use ( ); lists use [ ] But otherwise, they are the same… (for now, almost) >>> t = (1, 2, 3) >>> t[1] 2 >>> t[1:] (2, 3) >>> (x, y, z) = t >>> x 1 >>> y 2

HW 2 Prob 3: Looks Good! def modify(pic): """ modify modifies an image to make it brighter """ pixels = getPixels(pic) #returns a list of lists, example for 2x2… # [ [(3, 10, 100), (3, 11, 110)], [(3, 10, 200), (10, 110, 290)] ] if len(pixels) == 0: return newPixels = [ [setNewPixel( pixels, row, col ) for col in range(len(pixels[0]))] for row in range(len(pixels))] setPixels(pic, newPixels) def setNewPixel( pixels, row, col ): """ setNewPixel returns the NEW imanges (row, col) (r,g,b) value input pixels: a 2D list containing RGB information in the pixels in a picture input row: the row of the pixel in question input col: the column of the pixel in question """ rval= min(pixels[row][col][0]+30, 255) gval = min(pixels[row][col][1]+30, 255) bval = min(pixels[row][col][2]+30, 255) return (rval, gval, bval)

HW 2 Prob 3: Looks Good! Your task is to implement (at least) 3 functions, one from each group (groups will be reviewed shortly) For up to +15 points of extra credit (depending on the scope of your additions) you can implement more of them or make up your own creative image manipulation function.

Group 1: negative.py: Modifies an image to create its negative. That is, all color values should be 255 minus their original value grayscale.py: Modifies an image to make it grayscale (i.e. black and white). HW 2 Prob 3: Looks Good! There is no one "correct" conversion from RGB to grayscale, since it depends on the sensitivity response curve of your detector to light as a function of wavelength. A common one in use is: Y = 0.3*R *G *B

HW 2 Prob 3: Looks Good! Group 2: flipVert.py: Flip the image on its horizontal axis Hint: flip the rows around flipHoriz.py: Flip the image on its vertical axis Hint: flip the columns around mirrorVert.py: Mirror the photo across its horizontal axis (i.e., so that the top part is mirrored upside down on the bottom of the image Hint:first, must find the midpoint of the columns mirrorHoriz.py: Same as above, but across the vertical axis Hint:first, must find the midpoint of the rows

HW 2 Prob 3: Looks Good! Group3: scale.py: Scale the image to half its original size (either horizontally, vertically, or both) blur.py: Blur the image by combining neighboring pixels in some way (up to you) one method would be to take the average of the pixels surrounding the pixel you are looking at

HW 2 Prob 3: Looks Good! randomGrid.py: Divide the image into an NxN grid (where the N is up to you) and randomly sort the pieces of the grid across the image. Useful function: random.shuffle Ex. Shuffle [0,1,2]  [1,2,0] [[0,1,2],[3,4,5],[6,7,8]]  [[3,4,5],[0,1,2],[6,7,8]] Feel free to add any more functions you can think of. Be creative! The professor will show off the more interesting images in class.