Images Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See

Slides:



Advertisements
Similar presentations
Def f(n): if (n == 0): return else: print(“*”) return f(n-1) f(3)
Advertisements

TOPIC 5 INTRODUCTION TO PICTURES 1 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B.
Computer Science 111 Fundamentals of Programming I More Digital Image Processing.
Tuples Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
My Penguin Math Book By:. I see How many penguins do you see? Count them & type the number in the box penguins.
CGA 115 Professor Mary A. Malinconico. Questions from Last Week ????????
Fundamentals of Digital Imaging
© red ©
Exercise 1 - Poisson Image completion using Discrete Poisson Linear Systems.
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-
First Bytes - LabVIEW. Today’s Session Introduction to LabVIEW Colors and computers Lab to create a color picker Lab to manipulate an image Visual ProgrammingImage.
Computer Science 111 Fundamentals of Programming I Introduction to Digital Image Processing.
CSc 461/561 CSc 461/561 Multimedia Systems Part A: 2. Image.
Color Model AbdelRahman Abu_absah Teacher: Dr. Sana'a Alsayegh.
1 Additive Colour Mixing using a Computer Monitor You will use: a Liquid Crystal Display (LCD) or Cathode Ray Tube (CRT) Computer Monitor, this PowerPoint.
1 Internet Graphics. 2 Representing Images  Raster Image: Images consist of “dots” of color, not lines  Pixel: Picture element-tiny rectangle  Resolution:
CMYK vs. RGB Design. Primary colors The colors that make up the base for every other color created. Depending on whether you are looking at it from science,
Digital Images Chapter 8, Exploring the Digital Domain.
Color Image Processing A spectrum of possibilities…
Image Processing & Perception Sec 9-11 Web Design.
Steganography Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Digital Terminology. Bitmap A representation consisting of rows and columns of dots of a graphic image stored in computer memory. To display a bitmap.
I-1 Steps of Image Generation –Create a model of the objects –Create a model for the illumination of the objects –Create an image (render) the result I.
COSC 1P02 Intro. to Computer Science 6.1 Cosc 1P02 Week 6 Lecture slides "To succeed, jump as quickly at opportunities as you do at conclusions." --Benjamin.
1 Computer Graphics Part 2: Images. 2 What is an image?  An image is the graphical and visual representation of some information that can be displayed.
Computer Screen Colors1 Colors Colors can be made of mixtures of 3 primary colors. If the medium is illumination (like on the face of a CRT) the colors.
Computer Science 112 Fundamentals of Programming II Graphics Programming.
Color and Resolution Introduction to Digital Imaging.
CS- 375 Graphics and Human Computer Interaction Lecture 1: 12/4/1435 Fundamental Techniques in Graphics Lecturer: Kawther Abas.
Do Now: Do Not Log In. Take out your notebook and a pen. Good morning! Do Now: Do Not Log In. Take out your notebook and a pen. Good morning! Aim: Review.
Color Web Design Professor Frank. Color Displays Based on cathode ray tubes (CRTs) or back- lighted flat-screen Monitors transmit light - displays use.
ITEC 109 Multimedia Lecture Lecture 23. Photo manipulation Review Lists / Arrays.
FRACTIONS & SHAPES BY:. How many of these are colored red? * out of *.
Image Operations Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
HSB to RGB to HEX.
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,
Counting Stars Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Information in Computers. Remember Computers Execute algorithms Need to be told what to do And to whom to do it.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Lesson 13 – Color and Typography. 2 Objectives Understand basic color theory. Understand the color wheel. Understand how color is presented on a computer.
Computer Graphic. Raster graphics In computer graphics, a raster graphics image, digital image, or bitmap, is a data structure representing a generally.
Hank Childs, University of Oregon April “29 th”, 2015 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / /
UNITS OF MEASUREMENT 2.01 Understand Digital Raster Graphics.
Representation of image data
Pixels, Colors and Shapes
The Colour of Light: Additive colour theory.
Image Processing & Perception
Fundamentals of Programming I Introduction to Digital Image Processing
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
CSc 110, Spring 2018 Lecture 9: Parameters, Graphics and Random
Colour Theories.
Programming Graphic LCD
Programming Graphic LCD
Two ways to discuss color 1) Addition 2) Subtraction
Fundamentals of Programming I Introduction to Digital Image Processing
Programming Graphic LCD
Advanced AV Production
Nuts and Bolts of Digital Imaging
Python Practice !!!.
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Colors Computers build colors from Red, Green, and Blue; not Red, Blue, and Yellow. RGB = Red Green Blue Creating Colors Red + Blue = Purple No Red, No.
What Color is it?.
Programming Graphic LCD
Programming Graphic LCD
Hank Childs, University of Oregon
Basic Concepts of Digital Imaging
Created By Dick Heckathorn 25 June 2K+3
Lecture 23 – Practice Exercises 5
CMPT 120 Lecture 22 – Unit 4 – Computer Vision
Lecture 23 – Practice Exercises 5
Presentation transcript:

Images Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See for more information. Multimedia Programming

Images Pictures are much older than text Just as easy to work with… …given the right libraries Explore the Python Imaging Library (PIL) Other languages have similar tools

Multimedia ProgrammingImages Start by loading the image into memory >>> from PIL import Image >>> pic = Image.open('ngc1333-noao.jpg')

Multimedia ProgrammingImages Examine image properties >>> pic.format 'JPEG' >>> pic.size (640, 480)

Multimedia ProgrammingImages Colors represented by red-green-blue (RGB) triples Black is (0, 0, 0) White is (255, 255, 255) or (0xFF, 0xFF, 0xFF) A color cube red green blue black white cyan magenta yellow

Multimedia ProgrammingImages Pixel coordinates are (x, y) tuples (0, 0) is the upper left corner of the image –Because that's how old CRT monitors drew things >>> pic.getpixel((0, 0)) # upper left corner (17, 12, 18)

Multimedia ProgrammingImages Find the brightest pixel

Multimedia ProgrammingImages Find the brightest pixelWhat does "brightest" actually mean?

Multimedia ProgrammingImages Find the brightest pixel >>> xsize, ysize = pic.size >>> bx, by, max_val = 0, 0, 0 >>> for x in range(xsize):... for y in range(ysize):... r, g, b = pic.getpixel((x, y))... if r + g + b > max_val:... bx, by, total = x, y, r + g + b... print (bx, by), total...

Multimedia ProgrammingImages Find the brightest pixel >>> xsize, ysize = pic.size >>> bx, by, max_val = 0, 0, 0 >>> for x in range(xsize):... for y in range(ysize):... r, g, b = pic.getpixel((x, y))... if r + g + b > max_val:... bx, by, total = x, y, r + g + b... print (bx, by), total... (59, 345) 758

Multimedia ProgrammingImages How fast is that?

Multimedia ProgrammingImages How fast is that? def brightest(picture):...as above... return (bx, by), total

Multimedia ProgrammingImages How fast is that? def brightest(picture):...as above... return (bx, by), total from time import time def elapsed(func, picture): start = time() result = func(picture) return time() - start, result

Multimedia ProgrammingImages How fast is that? 0.63 seconds def brightest(picture):...as above... return (bx, by), total from time import time def elapsed(func, picture): start = time() result = func(picture) return time() - start, result

Multimedia ProgrammingImages Ignore coordinates

Multimedia ProgrammingImages Ignore coordinates def faster(picture): max_val = 0 for (r, g, b) in picture.getdata(): if r + g + b > max_val: max_val = r + g + b return max_val

Multimedia ProgrammingImages Ignore coordinates def faster(picture): max_val = 0 for (r, g, b) in picture.getdata(): if r + g + b > max_val: max_val = r + g + b return max_val Pixels ordered row by row

Multimedia ProgrammingImages Ignore coordinates def faster(picture): max_val = 0 for (r, g, b) in picture.getdata(): if r + g + b > max_val: max_val = r + g + b return max_val Pixels ordered row by row 0.07 seconds

Multimedia ProgrammingImages Ignore coordinates def faster(picture): max_val = 0 for (r, g, b) in picture.getdata(): if r + g + b > max_val: max_val = r + g + b return max_val Pixels ordered row by row Exercise: return (x, y) coordinate of brightest pixel 0.07 seconds

Multimedia ProgrammingImages A useful compromise

Multimedia ProgrammingImages A useful compromise def inbetween(picture): xsize, ysize = picture.size temp = picture.load() bx, by, max_val = 0, 0, 0 for x in range(xsize): for y in range(ysize): r, g, b = temp[x, y] if r + g + b > max_val: bx, by, total = x, y, r + g + b return (bx, by), total

Multimedia ProgrammingImages A useful compromise def inbetween(picture): xsize, ysize = picture.size temp = picture.load() bx, by, max_val = 0, 0, 0 for x in range(xsize): for y in range(ysize): r, g, b = temp[x, y] if r + g + b > max_val: bx, by, total = x, y, r + g + b return (bx, by), total 0.13 seconds

Multimedia ProgrammingImages Find stars

Multimedia ProgrammingImages Find stars Convert to black and white

Multimedia ProgrammingImages Find stars Convert to black and white Easier to see black on white than vice versa

Multimedia ProgrammingImages Find stars Convert to black and white def monochrome(picture, threshold): black = ( 0, 0, 0) white = (255, 255, 255) xsize, ysize = picture.size temp = picture.load() for x in range(xsize): for y in range(ysize): r, g, b = temp[x, y] if r + g + b >= threshold: temp[x, y] = black else: temp[x, y] = white

Multimedia ProgrammingImages if __name__ == '__main__': pic = Image.open(sys.argv[1]) monochrome(pic, ) pic.save(sys.argv[2])

Multimedia ProgrammingImages if __name__ == '__main__': pic = Image.open(sys.argv[1]) monochrome(pic, ) pic.save(sys.argv[2]) Not the same as (200, 200, 200)

Multimedia ProgrammingImages if __name__ == '__main__': pic = Image.open(sys.argv[1]) monochrome(pic, ) pic.save(sys.argv[2])

Multimedia ProgrammingImages if __name__ == '__main__': pic = Image.open(sys.argv[1]) monochrome(pic, ) pic.save(sys.argv[2]) Now we can start counting

November 2010 created by Greg Wilson Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See for more information.