Lecture 23 – Practice Exercises 5

Slides:



Advertisements
Similar presentations
RAPTOR Syntax and Semantics By Lt Col Schorsch
Advertisements

© red ©
The eyes have three different kinds of color receptors; One kind is most sensitive to short wavelengths, one to middle wavelengths, and one to long wavelengths.
RGB color model Skills: none IT concepts: combining red, green and blue light to generate colors This work is licensed under a Creative Commons Attribution-Noncommercial-
1 Perception. 2 “The consciousness or awareness of objects or other data through the medium of the senses.”
Bitmapped Images 27 th November 2014 With Mrs
Mr. Chapman Science 8.  As we all know by now (I hope!) the visible spectrum of light is all the colours that you can see in the rainbow – ROY G. BIV.
Contains 16,777,216 Colors. My Car is red My Car is red How do I add colors to my web page? Notepad Browser Works with the “Standard” colors: Red, Green,
Two-digit Addition 2.NBT.6. Joseph likes collecting stamps. He has 24 stamps from different Asian countries, 32 stamps showing different parks in the.
SNC2D. Primary LIGHT colours are red, green, and blue SECONDARY light colours are created by combining only two of the three primary colours of light.
1 Internet Graphics. 2 Representing Images  Raster Image: Images consist of “dots” of color, not lines  Pixel: Picture element-tiny rectangle  Resolution:
Colour Theory.
COLOURS.
Objective Understand concepts used to create digital graphics. Course Weight : 15% Part Three : Concepts of Digital Graphics.
CS 101 – Sept. 16 Finish color representation –RGB √ –CMY –HSB –Indexed color Chapter 4 – how computers think –Begin with basic building blocks.
Digital Terminology. Bitmap A representation consisting of rows and columns of dots of a graphic image stored in computer memory. To display a bitmap.
Colours and Computer Jimmy Lam The Hong Kong Polytechnic University.
ECE291 Computer Engineering II Lecture 9 Josh Potts University of Illinois at Urbana- Champaign.
Images Data Representation. Objectives  Understand the terms bitmap & pixel  Understand how bitmap images are stored using binary in a computer system.
Colour Wheel How to mix the colours you want!. Additive color refers to the mixing of colors of light. This example shows how the light from red, green.
Using Artemis to generate the genome Map: Demo 1.
What are the five colors in the legend? Enter the information below (5 points) 0000FF = = FFFFFF = 00FF00 = FF0000 = Color Theory Legend: income.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
Color Web Design Professor Frank. Color Displays Based on cathode ray tubes (CRTs) or back- lighted flat-screen Monitors transmit light - displays use.
Colors of Pigment The primary colors of pigment are magenta, cyan, and yellow. [
Subtractive Colour Mixing. 1.Explain why a magenta sweater is magenta. When white light strikes the magenta sweater, the sweater absorbs the green and.
8. DECISION STRUCTURES Rocky K. C. Chang October 18, 2015 (Adapted from John Zelle’s slides)
PART TWO Electronic Color & RGB values 1. Electronic Color Computer Monitors: Use light in 3 colors to create images on the screen Monitors use RED, GREEN,
Colour D. Crowley, 2008.
Videos and resources Double Rainbow Guy: Phet color addition:
Coloured Light Dispersion Colours Filters Seeing colour.
What colour is it / are they?
Sampling, Quantization, Color Models & Indexed Color
The Colour of Light: Additive colour theory.
Colour theory.
South African Flag The South African flag contains the most colours of any national flag. Can you colour it in here? RED WHITE YELLOW WHITE BLACK GREEN.
Colour Theory of Light Grade 10 Optics
Topic: Functions – Part 2
Color.
Absorption and Colour Along with everything else in the world, plants are the colour they are because of the light that they reflect, and all other colours.
Representing Images 2.6 – Data Representation.
What do these words mean to you?
Mixing coloured lights
10.5b Why colours change An apple looks red in normal (white) light because it reflects red light and absorbs all the other light rays shining on it.
Colour The Elements of Design.
Name: _______________________________
Colour Theories.
Georgia Institute of Technology
Colour Phrase Random Slide Show Menu
Game Controller Introduction.
Colours.
Practice with loops! What is the output of each function below?
Two ways to discuss color 1) Addition 2) Subtraction
HTML Colour Codes (Hexadecimal)
What Color is it?.
Lecture 5 Binary Operation Boolean Logic. Binary Operations Addition Subtraction Multiplication Division.

COLOURS.
Lecture 5 – Unit 1 – Chatbots Python – More on Conditional statements
Lecture 17 – Practice Exercises 3
CMPT 120 Lecture 22 – Unit 4 – Computer Vision
Lecture 20 – Practice Exercises 4
CMPT 120 Machine that can see! Lecture 21 – Unit 4 – Computer Vision
CMPT 120 Lecture 24 – Unit 4 – Computer Vision
Lecture 20 – Practice Exercises 4
Lecture 23 – Practice Exercises 5
Java-Assignment #4 (Due, April. 9, 2004)
Lecture 17 – Practice Exercise 3 SOLUTIONS
Year 8 Unit 2 Bitmap Graphics
Presentation transcript:

Lecture 23 – Practice Exercises 5 CMPT 120 Lecture 23 – Practice Exercises 5

Goals for Today! Practise hand tracing and commenting a program Practise implementing an image processing program

Question 1 a) – Add comments: import random def random_pie(pies): pie1 = random.choice(pies) pie2 = random.choice(pies) if pie1 == pie2: return (True, pie1, pie2) return (False, pie1, pie2) # Main part of program pies = ("blueberry", "apple", "pecan") pie_answer = random_pie(pies) if pie_answer[0]: print("You win a free " + pie_answer[1] + " pie!") else: print("You get a 5% discount on either " + pie_answer[1] + " or " + pie_answer[2] + " pie!")

Question 1 b) Is pies A and pies B the same variable? If not, what is pies A? What is pies B? What is the scope of pies A? What is the scope of pies B? import random def random_pie(pies): pie1 = random.choice(pies) pie2 = random.choice(pies) if pie1 == pie2: return (True, pie1, pie2) return (False, pie1, pie2) # Main part of program pies = ("blueberry", "apple", "pecan") pie_answer = random_pie(pies) if pie_answer[0]: print("You win a free " + pie_answer[1] + " pie!") else: print("You get a 5% discount on either " + pie_answer[1] + " or " + pie_answer[2] + " pie!") A B

Question 1 c) Can you rewrite the function random_pie() such that it only has 1 return statement instead of 2? import random def random_pie(pies): pie1 = random.choice(pies) pie2 = random.choice(pies) if pie1 == pie2: return (True, pie1, pie2) return (False, pie1, pie2) # Main part of program pies = ("blueberry", "apple", "pecan") pie_answer = random_pie(pies) if pie_answer[0]: print("You win a free " + pie_answer[1] + " pie!") else: print("You get a 5% discount on either " + pie_answer[1] + " or " + pie_answer[2] + " pie!")

raspberries.jpg Attribution: "Fir0002/Flagstaffotos" Question 2 Given the image raspberries.jpg below, what does the code below output (approximately)? from PIL import Image rasp = Image.open("raspberries.jpg").load() # raspberries.jpg is 320 x 213 pixels print(rasp[160, 0][0]) print(rasp[0,212]) https://commons.wikimedia.org/wiki/File:Raspberries.jpg If you want to download this image, click on “Other resolutions: 320 × 213 pixels ” raspberries.jpg Attribution: "Fir0002/Flagstaffotos"

Question 3 What colour would a pixel with RGB value (0, 0, 50) appear to be? (A) Dark red (B) Light red (C) Dark green (D) Light green (E) Dark blue (F) Light blue

Question 4 Problem Statement: Write a function that returns the colour of a given pixel as a string (using the table below) Sample input: (0, 255, 0) Function returns: “green” Possible return values: “red”, “green”, “blue”, “white”, “black”, “yellow” or “magenta”