23 Pages

rec3

Course: CS 177, Fall 2010
School: Purdue
Rating:
 
 
 
 
 

Word Count: 753

Document Preview

177 CS Week 3 Recitation Slides Pictures, Pixels, Colors and for Loop 1 Announcements 2 ANY QUESTIONS? 3 Reminder: Why digitize media? Real media is analogue (continuous). To digitize it, we break it into parts and encode them into numbers. By encoding them, we can more easily manipulate them, store them, transmit them without error, etc. 4 Digitization of Pictures We digitize pictures into lots of...

Register Now

Unformatted Document Excerpt

Coursehero >> Indiana >> Purdue >> CS 177

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
177 CS Week 3 Recitation Slides Pictures, Pixels, Colors and for Loop 1 Announcements 2 ANY QUESTIONS? 3 Reminder: Why digitize media? Real media is analogue (continuous). To digitize it, we break it into parts and encode them into numbers. By encoding them, we can more easily manipulate them, store them, transmit them without error, etc. 4 Digitization of Pictures We digitize pictures into lots of little dots Enough dots and it looks like a continuous whole to our eye Our eye has limited resolution Each little dot (picture element) is referred to as a pixel 5 We already saw how to display a picture in JES myFile = pickAFile() myPicture = makePicture(myFile) show(myPicture) 6 Now, lets see how a picture is represented in JES A Picture is a matrix of pixels Row: width Column: height Pixels are picture elements Each pixel object knows its color It also knows where it is in its picture 7 Encoding Colors with RGB Model Each pixel encodes the color at that position in the picture How we represent a color? We use RGB model to encode colors in computers. RGB: Red, Green, Blue. 8 RGB Color Model Each component color (red, green, and blue) is encoded as a single byte Colors go from (0,0,0) black to (255,255,255) white 9 Encoding RGB: Bits and Patterns General rule: In n bits, we can have 2n patterns In 8 bits, we can have 28 patterns, or 256 If we make the first pattern 0, then the highest value we can represent is 28-1, or 255 Were representing color in 24 (3 * 8) bits. 10 Reminder: how to show pictures >>> file=pickAFile() >>> print file /Users/guzdial/mediasources/barbara.jpg >>> picture=makePicture(file) >>> show(picture) >>> print picture Picture, filename /Users/guzdial/mediasources/barbara.jpg height 294 width 222 11 Exploring the pixels of a picture.. You can use the picture tool of JES to see the color of a picture pixel. 12 Manipulating Pixels or you can use a Python command to: get a single pixel at given x,y position getPixel(picture,x,y) get all the pixels into an array getPixels(picture) 13 What can we do with a pixel? Once you got a pixel, you can get its color components: getRed, getGreen, and getBlue Input: a pixel Output: a value between 0 and 255 Or you can change one of its color components: setGreen, setRed, and setBlue Input: a pixel Output: a value between 0 and 255 14 What can we do with a color? getColor: Input: a pixel Output: a Color object with the color at that pixel setColor: Input: a pixel and a Color Output: a pixel with the color set makeColor: Input: red, green, and blue values (in that order) between 0 and 255 Output: a Color object pickAColor lets you use a color chooser and returns the chosen color We also have functions that can makeLighter and makeDarker an input color 15 Examples: Manipulating Colors Lets see some examples Demo 16 Change Pixels Directly >>> setColor(getPixel(pict,10,100),yellow) >>> setColor(getPixel(pict,11,100),yellow) >>> setColor(getPixel(pict,12,100),yellow) >>> setColor(getPixel(pict,13,100),yellow) >>> What if we want to change millions of pixels? Better way? Use a loop. 17 Example of a for Loop def decreaseRed(picture): for p in getPixels(picture): value=getRed(p) setRed(p,value*0.5) Lets see an example Demo 18 Rules of for Loops Command name: for An index variable p is used to hold each of the different values of a sequence The word in A Python function that generates a sequence The index variable will be the name for one value in the sequence, each time through the loop A colon (:) And a block (the indented lines of code) 19 How a for Loop Works The index variable is set to an item in the sequence The block is executed The variable is often used inside the block Then execution loops to the for statement, where the index variable gets set to the next item in the sequence Repeat until every value in the sequence was used. 20 Using the loop in our Egg Omelette recipe One Egg Omelette recipe: Put oil in pan Pre-heat pan Crack an egg into bowl Add Salt Wisk the contents of bowl Pour contents of bowl into pan Wait for 3 minutes 21 Using the loop in our Egg Omelette recipe Four Egg Omelettes recipe: Put oil in pan Pre-heat pan Crack an egg into bowl Add Salt Wisk the contents of bowl Pour contents of bowl into pan Wait for 3 minutes Repeat the above procedure again for the second egg omelette Repeat the above procedure again for the third egg omelette Repeat the above procedure again for the fourth egg omelette 22 Final QUESTIONS??? 23
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Purdue - CS - 177
CS 177 Week 4 Recitation Slidesfor Loopif statementandrange1AnnouncementsEXAM 1Wednesday 09/296:30p - 7:30pEE 1292ANY QUESTIONS?3Lets remember for Loopdef decreaseRed(picture):for p in getPixels(picture):value = getRed(p)setRed(p,value*0
Purdue - CS - 177
CS 177 Week 5 Recitation SlidesMirroring and copying images,Using for Loop, if statement, and range1AnnouncementsEXAM 1Wednesday 09/296:30p - 7:30pEE 1292ANY QUESTIONS?3Horizontal mirror recipe4mirroring means intuitively "flipping around" a
Purdue - CS - 177
CS 177 Week 6 Recitation SlidesScalingDrawing on imagesVector-based Vs. Bitmap graphical representation1AnnouncementsnEXAM 1Wednesday 09/296:30p - 7:30pEE 1292ScalingnScaling a picture (smaller or larger) has to do withsampling the source p
Purdue - CS - 177
CS 177 Week 7 Recitation SlidesModifying Sounds using Loops+Discussion of some Exam Questions1ANY QUESTIONS?2Q3. Consider the following function definition:def sum(a, b):c=a+breturn cprint Hello WorldWhat is the output when you execute sum(4,5
Purdue - CS - 177
CS 177 Week 8 Recitation SlidesJES Sound functionsandModifying SoundsIncreasing/Decreasing VolumeMaximizing (Normalizing)SplicingReversingMirroring1ANY QUESTIONS?2Lets remember SoundWe store sounds as array of integer values Each value is st
Purdue - CS - 177
CS 177 Week 9 Recitation SlidesSound Combination, SamplingandBuilding Bigger Programs1ANY QUESTIONS?2Media File Path is Important> setMediaPath() #must be called before getMediaPath> c4=makeSound(getMediaPath("bassoon-c4.wav")> e4=makeSound(getM
Purdue - CS - 177
CS 177 Week 9 Recitation SlidesCreating and Modifying Text1ANY QUESTIONS?2Text and StringLike sound, text is usually processed in an arraya longline of charactersStrings are defined with quote marks:Single quotes my string Double quotes my strin
Purdue - CS - 177
CS 177 Week 11 Recitation SlidesWriting out programs, Reading from the Internetand Using Modules1ANY QUESTIONS?2Writing a program to writeprogramsFirst, a function that will automatically change the textstring that the program littlepicture draws
Purdue - CS - 177
CS 177 Week 12 Recitation SlidesAdvanced Text Techniques and Making Text for theWeb + (some examII questions)1Q21. Suppose you have the following string:str = "Purdue University"Which of the following statements will produce the same result ofstr.f
Purdue - CS - 177
CS 177 Week 13 Recitation SlidesHTML and Relational Database1ANY QUESTIONS?2What is HTML?Language which specifies the format of the text on theworld wide web.a.k.a. Hyper Text Markup Language.Was originally created with the intent of identifying
Purdue - CS - 177
CS 177 Week 15 Recitation SlidesSpeedBig-O notationSorting and SearchingandFunctions with Recursion1ANY QUESTIONS?2More than one way to solve aproblemTheres always more than one way to solve a problem.3You can walk to one place around the blo
Purdue - CS - 177
CS 177 Week 16 Recitation SlidesObject Oriented Programming1ANY QUESTIONS?2Procedural Abstractions3Define tasks to be performedBreak tasks into smaller and smaller pieces Until you reach an implementable sizeDefine the data to be manipulatedDes
Purdue - CS - 177
Q1. What is the name of the function that will display the names of variables in yourprogram?A)showVars()B)showNames()C)showFiles()D)showObjects()Key: AQ2. The following function will result in a JES error. Why?A)B)C)D)In line 1 the : is m
Purdue - CS - 177
The Concept of Team WorkStarting with Lab 9 you will be doing lab exercises in groups of two or three students. You willalso do projects in groups. The content of this document applies to labs and to projects. Youshould elect one student as the group l
Purdue - CS - 177
Teaming: Reflection Paper GuidelinesPart of a successful teaming experience is the ability to critically reflect on that experience andarticulate it well to others. College-level writing that has been spell-checked and proof read isexpected. This paper
Purdue - CS - 177
If you want to turnin your project from your home you can follow the followingsteps:1. Download the SSH Secure Shell Client 3.2.9. You can google it or find atftp:/ftp.tm.informatik.uni-frankfurt.de/pub/prog/SSHSecureShellClient3.2.9.exeThis program i
University of Sydney - MATH - 1011
Periodic Functions[1.2 of the Notes, Chapter 1 ofStewart is also useful]There are many examples in natureof events repeating themselves overand over again. Nature is periodic!Example 1If you plot the length of day againsttime the graph repeats its
Purdue - HIS - 306
NewFinalExam1.ComparethedifferencesbetweentheEastandWestintermsofinfluencandlandscapearchitecture.StudentResponse:EgyptianlandscapeswemadefertilebytheoverfgardenswereformalandmadelandscapebecausnonaturallandscapestoirrigationsystemswereinEgypti
Purdue - HIS - 306
History of Horticulture: Lecture 1Lecture 1Dating the Past: Geologic,Archeologic, Biologic, and HumanArcheologic,CultureDating the Past (years ago)Dating the Past (years ago)1History of Horticulture: Lecture 1Dating the Past (years ago)The Emer
Purdue - HIS - 306
History of Horticulture: Lecture 2Lecture 2Early Humans and the Prehistoric Record:HumanPlant InteractionDating the PastHuman Fossils & ToolsHominid fossils and tools date to 1.8 million yearsago.There is some evidence of tools in Europe as early
Purdue - HIS - 306
History of Horticulture: Lecture 3Lecture 3Neolithic Revolution and theDiscovery of AgricultureDating the PastThe Great Technological Discoveriesof Pre-historyThe discovery of toolsThe discovery and control of fireThe invention of agricultureThe
Purdue - HIS - 306
History of Horticulture: Lecture 4Lecture 4Geography of Plant DomesticationAlphonse de Candolle (18061893)Charles Darwin (18091882)1858 Origin of SpeciesNicholas Ivanovitch Vavilov (18871943)Alphonse de Candolle (18061893)Alphonse De Candolle as a
Purdue - HIS - 306
History of Horticulture: Lecture 5Lecture 5Centers of Origin of Crop PlantsThe eight Vavilovian Centers of Origin for crop plantsOLD WORLDI. Chinese Center: The largest independent centerwhich includes the mountainous regions of centraland western
Purdue - HIS - 306
NewFinalExam1.ComparethedifferencesbetweentheEastandWestintermsofinfluencandlandscapearchitecture.StudentResponse:EgyptianlandscapeswemadefertilebytheoverfgardenswereformalandmadelandscapebecausnonaturallandscapestoirrigationsystemswereinEgypti
Purdue - HIS - 306
Title:exam1Started:Submitted:Timespent:Totalscore:February21,20088:26AMFebruary21,20088:58AM00:31:4799/100=99% Totalscoreadjustedby0.0Maximumpossiblescore:1001.ToxicsubstancestendtobeeliminatedinStudentResponseValueCorrectAnswer1 cultiva
Purdue - HIS - 306
JumptoNavigationFrameTitle:Started:Submitted:Timespent:Totalscore:exam2March5,200810:31AMMarch5,200811:08AM00:36:5298/100=98% Totalscoreadjustedby0.0Maximumpossiblescore:1001.ComparecontributionsofDioscoridesandTheophrastestohorticulturalkS
Purdue - HIS - 306
Title:Quiz1Started:January15,20088:29PMSubmitted:January15,20088:43PMTimespent:00:13:56Totalscore:10/10=100% Totalscoreadjustedby0.0 Maximumpossiblescore:101.GiveapproximatedatefortheBronzeAgeStudentResponse1. 4,000yearsagoValueCorrectAnswe
Purdue - HIS - 306
Extra Credit AssignmentTwo famous garden scenes of Shakespeare are found in Richard II and The Winter's Tale.Choose one and delineate and discuss the horticultural knowledge revealed in these excerpts.Your submission should be at least one page in leng
Purdue - HIS - 306
ARTGiuseppeArcimboldoMichelangeloCaravaggioGeorgDionysusEhretGeorgiaOKeefeVincentvanGoghLeonardodaVinciBartolomeoMayanYumKaax,Yucatan,Chultunes.AztecsTenochtitlan,Milpas,Chinampas,MexicoCity.IncasMacchuPichu,Potatoculture,.Cuzco.GreeceRhizotomoi,Hippoc
Purdue - HIS - 306
EXAM #1Question Type #1Cultivated Food Plants Toxic Substances tend to be eliminated in Seed dormancy is lost in Self pollination tends to increase in Fruit and organ size is greater in Life span for crops grown for vegetative organs is increased i
Purdue - HIS - 306
Yourlocation:AssessmentsViewAllSubmissionsViewAttemptViewAttempt1of1Title:exam1Started:Submitted:Timespent:Totalscore:January28,20098:28AMJanuary28,20098:47AM00:18:2190/100=90% Totalscoreadjustedby0.0 Maximumpossiblescore:1001.Toxicsubstance
Purdue - HIS - 306
Yourlocation:AssessmentsViewAllSubmissionsViewAttemptViewAttempt1of1Title:exam2Started: February2,20098:20AMSubmitted: February2,20098:53AMTime00:32:52spent:Total97/100=97% Totalscoreadjustedby0.0 Maximumpossiblescore:100score:1.Comparecontri
Purdue - HORT - 306
Old World Crops: Wheat, rice, Date. Apple, citrus/ New World Crops: Peanut, cacao, maize, squash, tomato Ikebana, Bonsai, and Sakai:ikebana is a Japanese flower arrangement that is based on the symbolic use of flowers. Bonsai is specimen grown on miniatu
Purdue - HORT - 306
View Attempt 1 of 1Title:Started:Submitted:Time spent:New Final ExamDecember 8, 2010 3:02 PMDecember 8, 2010 4:15 PM01:12:34Total score:170/200 = 85% Total score adjusted by 0.0Maximum possible score: 2001.Define the following design termsSy
Purdue - HORT - 306
Title:NewFinalExamStarted:Submitted:Timespent:Totalscore:February11,20098:29AMFebruary11,20099:52AM01:23:25154/200=77% Totalscoreadjustedby0.0 Maximumpossiblescore:2001.Defendthefollowingstatementandgiveexamples.<br>Thegreatestcontributiontoho
Purdue - HORT - 306
ViewAttempt1of1Title:Quiz3Started:Submitted:Timespent:Totalscore:January15,200911:31PMJanuary15,200911:40PM00:08:5310/10=100% Totalscoreadjustedby0.0 Maximumpossiblescore:101.WhatisevidenceforplantintroductionintoEgypt?(2points)StudentRespon
Purdue - HORT - 306
Yourlocation:AssessmentsViewAllSubmissionsViewAttemptViewAttempt1of1Title:exam1Started:Submitted:Timespent:Totalscore:January28,20098:28AMJanuary28,20098:47AM00:18:2190/100=90% Totalscoreadjustedby0.0 Maximumpossiblescore:1001.Toxicsubstance
Purdue - HORT - 306
Title:Quiz1Started:January15,20088:29PMSubmitted:January15,20088:43PMTimespent:00:13:56Totalscore:10/10=100% Totalscoreadjustedby0.0 Maximumpossiblescore:101.GiveapproximatedatefortheBronzeAgeStudentResponse1. 4,000yearsagoValueCorrectAnswe
Purdue - HORT - 306
Title:Quiz2Started:Submitted:Timespent:Totalscore:January15,20088:50PMJanuary15,20089:06PM00:16:1110/10=100% Totalscoreadjustedby0.0Maximumpossiblescore:101.WheatoriginatedinStudentResponse1. Americas2.Asia3. AfricaValueCorrectFeedbac
Purdue - HORT - 306
Title:Quiz3Started:Submitted:Timespent:Totalscore:January16,20087:06PMJanuary16,20087:15PM00:09:4310/10=100% Totalscoreadjustedby0.0Maximumpossiblescore:101.WhatisevidenceforplantintroductionintoEgypt?(2points)StudentResponse:SampleCorrectAn
Purdue - HORT - 306
Title:Quiz4Started:Submitted:Timespent:Totalscore:January16,20087:16PMJanuary16,20087:33PM00:16:4510/10=100% Totalscoreadjustedby0.0Maximumpossiblescore:101.Whatisthehorticulturalsignificanceof:HangingGardensofBabylon(2points)StudentResponse
Purdue - HORT - 306
Title:Quiz5Started:Submitted:Timespent:Totalscore:January16,20087:34PMJanuary16,20087:44PM00:09:248/10=80% Totalscoreadjustedby0.0Maximumpossiblescore:101.Definemilpa(1point)StudentResponse:SampleCorrectAnswerAztecmaizefield.Score:Aztecma
Purdue - HORT - 306
Title:Quiz6Started:Submitted:Timespent:Totalscore:January17,20083:30PMJanuary17,20083:54PM00:24:0510/10=100% Totalscoreadjustedby0.0Maximumpossiblescore:101.Identifyanddescribeinrelationtoagricultureorhorticulture.(1point)Aristotle:StudentRe
Purdue - HORT - 306
Title:Quiz7Started:Submitted:Timespent:Totalscore:January17,20083:54PMJanuary17,20084:06PM00:11:5010/10=100% Totalscoreadjustedby0.0Maximumpossiblescore:101.DefineorIdentify.(1point)RaisedBeds:StudentResponse:Bedsthatareraisedandfillewhich
Purdue - HORT - 306
Title:Quiz8Started:Submitted:Timespent:Totalscore:January17,20084:06PMJanuary17,20084:15PM00:09:0510/10=100% Totalscoreadjustedby0.0Maximumpossiblescore:101.Matchthecorrectanswer.(10points)StatementResponseConceptthatthemedicinalqualitiesof
Purdue - HORT - 306
Title:Quiz9Started:Submitted:Timespent:Totalscore:January17,20084:19PMJanuary17,20084:29PM00:10:0510/10=100% Totalscoreadjustedby0.0Maximumpossiblescore:101.MatcheachpersontohiscontributiontoBotanicalScienceorHorticulturStatementResponsePro
Purdue - HORT - 306
Title:Quiz10Started:Submitted:Timespent:Totalscore:January17,20084:30PMJanuary17,20084:45PM00:14:4210/10=100% Totalscoreadjustedby0.0Maximumpossiblescore:101.WhatwerethecontributionsofRachelCarsontohorticulture?StudentResponse:Amarinebiologi
Purdue - HORT - 306
OutlineIntroductionII. History/OriginIII. The Process of Raising MaizeIV. Development of the Maize PlantV. Uses of MaizeVI. Future of MaizeI.I. IntroductionMaize, also known as corn in Great Britain and the United States, is the most widespreadf
Purdue - HORT - 306
Term PaperA term paper (100 points) is due by 11:59 pm (midnight) on April 27th. The subject should be onan historical topic as suggested below. You are free to pick your own topic with Dr. Janicksapproval.You are not allowed recycle a term paper you
Purdue - HORT - 306
Horticulture 306Y/History 302YHistory of HorticultureSyllabusInstructorJules JanickOffice: 330, Horticulture BldgPhone: 494-1329Email: janick@purdue.eduCourse Administrator/GraderAnna WhipkeyOffice: 116A, Horticulture BldgPhone: 494-6968Email:
Purdue - HORT - 306
Title:Quiz12Started:Submitted:Timespent:Totalscore:February25,20087:15PMFebruary25,20087:30PM00:15:1110/10=100% Totalscoreadjustedby0.0Maximumpossiblescore:101.Whatisthedifferencebetweensymmetricalbalanceandasymmestricaldesign?(5points)Stude
Purdue - HORT - 306
Title:Quiz11Started:Submitted:Timespent:Totalscore:February25,20086:54PMFebruary25,20087:14PM00:19:4910/10=100% Totalscoreadjustedby0.0Maximumpossiblescore:101.Defineandrelatetoagriculturalcropsandhistory.OpiumWars:(2points)StudentResponse:
Rasmussen College - COST ACCOU - 101
Name:Section:Problem 7-21.Glide Tire CompanySales BudgetFor the Year Ended December 31, 2008Unit SalesVolumeProductPassenger car tiresTruck tiresTotalUnit SellingPriceTotal Sales-$-2.Glide Tire CompanyProduction BudgetFor the Year End
Jordan University of Science & Tech - TOURISM - 121
Reservation For Stanford Hotel Email: stanford@stanfordhotel.comTel: +852-2781-1881Website: http:/www.stanfordhongkong.com/en/Reservation For The Kimberley Hotel Email: hotel@kimberley.com.hkTel: +852-2723-3888Website: http:/www.kimberleyhotel.com.
Jordan University of Science & Tech - TOURISM - 121
Contents 2001 WorldatWork. The content islicensed for use by purchasers solely for their ownuse and not for resale or redistribution. No part ofthis article may be reproduced, excerpted orredistributed in any form without express writtenpermission of
Jordan University of Science & Tech - ECONS - 201
Political-Legal EnvironmentThe key feature for Subway is Franchise. In Singapore, franchising Subwayoffers a fast and easy approach to entrepreneurship. Firstly, there are nospecific laws governing franchising. Unlike some countries, there franchisors
Jordan University of Science & Tech - ECONS - 201
We observed that the mean hours spent on email per staff is 4.464. At least half of the staff will spent 4.4 hours on email while most of the staff will spent 4.7 hours or 5.3 hours. The median amount spent on email is higher for Executives.If we select
Jordan University of Science & Tech - ECONS - 301
Q4 (a)By ignoring the volatility, correlation and only focus on the achieving an expected re turns of 9% to 11%, we recommend Mr. David Tan to have a Balance portfolio. Theportfolio comprises of investing in different assets class with equal weighted al
Jordan University of Science & Tech - LAW - 343
Question 2:Background:1. Grace engaged Jane to teach her piano lessons for 10 lessons. Grace would payJane $500 per lesson. After 5 lessons, Grace could not continue with the lessons asshe needed to pay for her mothers medical bills. Jane offered to a
Jordan University of Science & Tech - LAW - 343
IntroductionRita (Principal) used materials to make art pieces to sale. Her neighbor, Barbie (agent)was aware of the kind of materials Rita used. Barbie saw some materials and wanted topurchase them for Rita, so she informed the seller (Third Party) th
Jordan University of Science & Tech - LAW - 343
Definition of ROTC?The Restraint of Trade Clause is applicable to the position of Design Engineer who has justbeen employed by CSM Pte Ltd to design a media player using voice-activated technology.This is a new entertainment device in the consumer mark