Compsci 101.2, Fall 2015 15.1 Plan for October 19-23 l Review Catchup and Midterm and Future  Make sure everyone understand options l Review Assignment.

Slides:



Advertisements
Similar presentations
Digital Images in Java Java’s imaging classes. Java imaging library  Java has good support for image processing  Must master a handful of classes and.
Advertisements

Container Types in Python
Sections of Ch. 12, 13, 14 Prof. V. Norman PhD, MS, BS, DDS, Esq.
Digital Color 24-bit Color Indexed Color Image file compression
Photoshop Lab colorspace A quick and easy 26 step process for enhancing your photos.
Python: Modifying Pictures Using Loops. Review JES command area – program area Defining/using functions specifying a sequence of steps for what the function.
Computer Science 111 Fundamentals of Programming I More Digital Image Processing.
I210 review Fall 2011, IUB. Python is High-level programming –High-level versus machine language Interpreted Language –Interpreted versus compiled 2.
GIMP Tutorial v2.0 Boo Virk
Bit Depth and Spatial Resolution SIMG-201 Survey of Imaging Science © 2002 CIS/RIT.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae & david streader, VUW Images and 2D Graphics COMP.
CSC 160 Computer Programming for Non-Majors Section 1.2: Drawing a UFO Prof. Adam M. Wittenstein
Computer Science 111 Fundamentals of Programming I Introduction to Digital Image Processing.
IMAGE PROCESSING LIBRARY (PIL) This is a package that you can import into python and it has quite a few methods that you can process image files with.
Digital Images The digital representation of visual information.
CS 102 Computers In Context (Multimedia)‏ 01 / 28 / 2009 Instructor: Michael Eckmann.
Objective Understand concepts used to create digital graphics. Course Weight : 15% Part Three : Concepts of Digital Graphics.
Color. There are established models of color, each discipline uses it own method for describing and discussing color intelligently.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
Python Image Library PIL 10/13/05. PIL – What is it? Pythonic library for Loading and Saving images (diverse formats) Scaling, cropping, compositing,
Computer Science 111 Fundamentals of Programming I Introduction to Graphics.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
Computer Science 112 Fundamentals of Programming II Graphics Programming.
Collecting Things Together - Lists 1. We’ve seen that Python can store things in memory and retrieve, using names. Sometime we want to store a bunch of.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Agenda Last class: Memory, Digitizing Numbers Today: Digitizing: Text
Make a blank window This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.In script mode create a file.
Built-in Data Structures in Python An Introduction.
CSC1401. Learning Goals Understand at a conceptual level What is media computation? How does color vision work? How can you make colors with red, green,
Computer Science 111 Fundamentals of Programming I Introduction to Digital Image Processing.
Compsci 6/101, Spring More on Python, Tools, Compsci 101 l APTs, Assignments, Tools  APT: Algorithmic Problem-solving and Testing  How to get.
Compsci 101.2, Fall #TBT l Finish some Python concepts and questions from earlier  Review for midterm exam l Strategies for success in 101 assignments.
Ch 6 Color Image processing CS446 Instructor: Nada ALZaben.
Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website.
ITEC 109 Multimedia Lecture Lecture 23. Photo manipulation Review Lists / Arrays.
Compsci 101.2, Fall Plan for TDAFB (after fall break) l Hear via about plans to catch-up and stay-ahead  Profs. Rodger and Astrachan to.
Simulation and Modeling: Predator-Prey Processing Lab IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 23, 2014 Carolyn Seaman Susan.
Python Let’s get started!.
Compsci 101.2, Fall Plan for FWON l Review current assignments and APTs  Review Dictionaries and how to use them  Code and APT walk-through.
Compsci 101.2, Fall Plan for 11/9 and 11/11 l Reviewing Concepts for test  Loops: index and by element  Strings, Lists, Sets, Dictionaries.
Midterm Review Important control structures Functions Loops Conditionals Important things to review Binary Boolean operators (and, or, not) Libraries (import.
Compsci 101.2, Fall Plan for October 22 l Images, tuples, RGB color model  Image processing by understanding API  Image processing with tuples.
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,
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
CompSci 101 Introduction to Computer Science November 11, 2014 Prof. Rodger CompSci 101 Fall Review for exam.
More Digital Representation Discrete information is represented in binary (PandA), and “continuous” information is made discrete.
Today… The for loop. Introducing the Turtle! Loops and Drawing. Winter 2016CISC101 - Prof. McLeod1.
See Winter 2016CISC101 - Prof. McLeod1.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
CompSci 101 Introduction to Computer Science March 8, 2016 Prof. Rodger.
Chapter 6 Functions The Tic-Tac-Toe Game. Chapter Content In this chapter you will learn to do the following: 0 Write your own functions 0 Accept values.
CompSci 101 Introduction to Computer Science
Images Data Representation.
Images and 2D Graphics COMP
David Meredith Aalborg University
Pixels, Colors and Shapes
CompSci 101 Introduction to Computer Science
Adjusting Image Colors Lasso & Marquee Tools
CompSci 101 Introduction to Computer Science
Reading Netpbm Images.
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CSC 108H: Introduction to Computer Programming
- orange white green - cyan - red - blue Example 1 24 bit RGB
Digital Image Processing
CS 177 Week 3 Recitation Slides
Binary pixel challenge 1
- orange white green - cyan - red - blue Example 1 24 bit RGB
Functions, Procedures, and Abstraction
Presentation transcript:

Compsci 101.2, Fall Plan for October l Review Catchup and Midterm and Future  Make sure everyone understand options l Review Assignment 5, Word Games  APIs, Global Variables, Interactive Games l Images, tuples, RGB color model  Ready for lab, next assignment, and next set of APTs

Compsci 101.2, Fall

Compsci 101.2, Fall Near-term Administrivia and Due Dates l Midterm regrade:  Review rubric, ask Prof in your section l Mastery APTs for mid-term catchup  October 23 and October 30 l Programming Assignments: Four left  10/29, 11/5, 11/19, 12/3 l APTs and APT Quizzes  Quizzes: 11/2, 11/16, 11/30 (moved by one week) l Midterm exam and final  November 12, December 9 and 13

Compsci 101.2, Fall Jumble Review from Last Week Use this problem to think about word games l Human approach  What do you do? l Computational method?  Cheating or insight?

Compsci 101.2, Fall Review Jumble Programming Concepts l When you run the program it starts in __main__, see Jumble.py for details  This is how Python works, boilerplate code  Global variables accessed in this section l What's the variable words at beginning?  Global variable. Accessible in every function in the module (global required for modifying)  Used sparingly often useful in a small module  Abused, can lead to hard to maintain code

Compsci 101.2, Fall Questions About Assignment 5 After this: image processing

Compsci 101.2, Fall Image Processing l What's real, what's Photoshopped  from  Learn more at we'll do very basic stuff in class and lab, next assignment too!

Compsci 101.2, Fall Example: convert color to gray scale Process each pixel Convert to gray

Compsci 101.2, Fall Example: convert blue to green Process each pixel Convert blue ones to green Is this like red-eye removal?

Compsci 101.2, Fall Need new concepts and Image library l Red, Green, Blue color model  Triples of (R,G,B) are processed as Python tuples.  Let's study tuples! l Images can be very big, what's 4K display?  4,096 x 2,160 = 8,847,360 pixels, 8Mb at least  Creating huge lists takes up memory  Sometimes only need one pixel at-a-time  Let's study generators!

Compsci 101.2, Fall Need new concepts and Image library l Red, Green, Blue color model  Additive model, each pixel specified by (r,g,b) triple, values of each between   White is (255,255,255) and Black is (0,0,0) l Images stored as sequence of (r,g,b) tuples, typically with more data/information too  256 values, represented as 8 bits, 2 8 = 256  32 bits per pixel (with alpha channel)  In Python we can largely ignore these details!

Compsci 101.2, Fall Image library: Two ways to get pixels l Each pixel is a tuple in both models  Like a list, indexable, but immutable  pix = (255,0,0) What is pix?, pix[0]? What is pix[5] ? l Invert a pixel: by subscript or named tuple  Access by assignment to variables! npx = (255-pix[0],255-pix[1],255-pix[2]) (r,g,b) = pix npx = (255-r,255-g,255-b)

Compsci 101.2, Fall Let's look at GrayScale.py l Key features we see  Import Image library, use API by example  Image.open creates an image object l Image functions for Image object im  im.show(), displays image on screen  im.save("xy"), saves with filename  im.copy(), returns image that's a copy  im.load(), [x,y] indexable pixel collection  im.getdata(), iterable pixel collection l Let's look at two ways to process pixels!

Compsci 101.2, Fall Image Library: open, modify, save Image.open can open most image files .png,.jpg,.gif, and more  Returns an image object, so store in variable of type Image instance  Get pixels with im.getdata() or im.load() Image.new can create a new image, specify color model "RGB" and size of image  Add pixels with im.putdata() l These belong to Image package

Compsci 101.2, Fall im.getdata(), accessing pixels l Returns something like a list  Use: for pix in im.getdata():  Generates pixels on-the-fly, can't slice or index unless you use list(im.getdata())  Structure is called a Python generator!  Saves on storing all pixels in memory if only accessed one-at-a-time l See usage in GrayScale.py, note how used in list comprehension, like a list!

Compsci 101.2, Fall Alternate : Still Tuples and Pixels The im.getdata() function returns list- like iterable  Can use in list comprehension, see code  Use.putdata() to store again in image pixels = [makeGray(pix) for pix in im.getdata()] def makeGray(pixel): r,g,b = pixel gray = (r+g+b)/3 return (gray,gray,gray)

Compsci 101.2, Fall Making Tuples and Generators l Overuse and abuse of parentheses  To create a tuple, use parentheses  To create a generator use parentheses as though creating a list comprehension! l See this in PyDev console for pix in im.getdata(): (r,g,b) = pix npx = (255-r,255-g,255-b) [2*n for n in range(10000)] (2*n for n in range(10000))

Compsci 101.2, Fall Questions about Image Code

Compsci 101.2, Fall im.load(), accessing pixels l Returns something that can be indexed [x,y]  Only useful for accessing pixels by x,y coords Object returned by im.load() is …  Use pix[x,y] to read and write pixel values l Note: this is NOT a generator pix = im.load() tup = pix[0,0] pix[1,1] = (255,255,0)