CS2984: Introduction to Media Computation Drawing directly on images.

Slides:



Advertisements
Similar presentations
Creative Computing. \\ aims By the end of the session you will be able to: 1.Explain the difference between various image file formats 2.Load in and display.
Advertisements

2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
A Media Computation Cookbook Manipulating Images and Sounds for Use in Alice Part 1: Image Manipulations Part 2: Advanced Image Manipulations, e.g., changing.
PHY-102 SAPIntroductory GraphicsSlide 1 Introductory Graphics In this section we will learn how about how to draw graphics on the screen in Java:  Drawing.
Speed CS A109. Big speed differences Many of the techniques we’ve learned take no time at all in other applications Select a figure in Word. –It’s automatically.
L.Ghadah R. Hadba CT1514-L1.  Computer Graphics :refers to processing of creating a new image from Geometry, Lighting parameters, Materials and Textures.Using.
Python: Modifying Pictures Using Loops. Review JES command area – program area Defining/using functions specifying a sequence of steps for what the function.
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.
1 CS 177 Week 6 Recitation Slides Scaling Drawing on images Vector-based Vs. Bitmap graphical representation.
ISYS 3074 Graphics File Formats File formats have developed with applications. At least 50 currently in use. Examples include: GIF, JPEG, TIFF, BMP, DIB,
Eleven colors and rasters. Color objects Meta represents colors with color objects You can create a color by saying: [color r g b] r: amount of red (0-255)
James Tam Programming: Part II In this section of notes you will learn about more advanced programming concepts such as looping, functions.
CS 102 Computers In Context (Multimedia)‏ 02 / 25 / 2009 Instructor: Michael Eckmann.
Eleven colors and rasters. Color objects Meta represents colors with color objects You can create a color by saying: [color r g b] r: amount of red (0-255)
Introduction to Computer Graphics
Graphics and Images September 28, Unit 3.
How Images are Represented Bitmap images (Dots used to draw the image) Monochrome images 8 bit grey scale images 24 bit colour Colour lookup tables Vector.
Introduction to Graphic Arts Technology PRINT Versus WEB.
Graphical images Bit-mapped (or raster-based) image: Matrix describing the individual dots that are the smallest elements (pixels) of resolution on a computer.
Dedicated Vector and Bitmap editing software.
COMP Bitmapped and Vector Graphics Pages Using Qwizdom.
Computer Graphics Using “ Adobe Photoshop ” Introduction to E-Learning Center, DAD presents Workshop on Instructor: Mazhar.
CS 101: Introduction to Computing Programming picture manipulations Developed by Mark Guzdial, Georgia Institute of Technology, 2003–2004; modified by.
CS1315: Introduction to Media Computation Picture encoding and manipulation.
CS1315: Introduction to Media Computation Picture encoding and manipulation.
Images Data Representation. Objectives  Understand the terms bitmap & pixel  Understand how bitmap images are stored using binary in a computer system.
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
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.
7/11/20081 Today’s Agenda Friday 6 th Nov Revision of certain topics Floating point notation Excess Notation Exam format Interim Report.
Digital Media Dr. Jim Rowan ITEC 2110 Color. Question! Inside Photoshop and Gimp there are image filters that, among other things, allow you to blur the.
Image Representation. Objectives  Bitmaps: resolution, colour depth and simple bitmap file calculations.  Vector graphics: drawing list – objects and.
ManipulatingPictures-part11 Manipulating Pictures, Arrays, and Loops part 1 Barb Ericson Georgia Institute of Technology Nov 2009.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Graphics. Graphic is the important media used to show the appearance of integrative media applications. According to DBP dictionary, graphics mean drawing.
CS- 375 Graphics and Human Computer Interaction Lecture 1: 12/4/1435 Fundamental Techniques in Graphics Lecturer: Kawther Abas.
Image Representation. Digital Cameras Scanned Film & Photographs Digitized TV Signals Computer Graphics Radar & Sonar Medical Imaging Devices (X-Ray,
CS1315: Introduction to Media Computation Picture encoding and manipulation.
ADOBE PHOTOSHOP VECTOR VS RASTER. Pixel A pixel is the fundamental unit of an image in Photoshop. It is a small square block of color. An image often.
Copying: How it works Here's the initial setup:. Copying: How it works 2 After incrementing the sourceY and targetY once (whether in the for or via expression):
Chapter 2 File Format Objectives (1 of 2) Identify the difference between vector based graphics and bitmap-based graphics Clarify bitmap and vector graphic.
Graphics An image is made up of tiny dots called pixels (“picture elements”) The resolution determines the.
Digital Media Dr. Jim Rowan ITEC So far… We have compared bitmapped graphics and vector graphics We have discussed bitmapped images, some file formats.
Color and Images. Color The natural colors we see and the colors we see on computer monitors are different. CMYK -natural RGB -monitor.
Digital Images are represented by manipulating this…
 By Bob “The Bird” Fiske & Anita “The Snail” Cost.
Image File Formats. What is an Image File Format? Image file formats are standard way of organizing and storing of image files. Image files are composed.
A Media Computation Cookbook Manipulating Images and Sounds for Use in Alice Part 1: Image Manipulations Part 2: Advanced Image Manipulations, e.g., changing.
1 Introduction to Graphics b The last one or two sections of each chapter of the textbook focus on graphical issues b Most computer programs have graphical.
Image File Formats By Dr. Rajeev Srivastava 1. Image File Formats Header and Image data. A typical image file format contains two fields namely Dr. Rajeev.
CS1315: Introduction to Media Computation Transforming pictures by index number.
CS 112 Introduction to Programming Java Graphics Yang (Richard) Yang Computer Science Department Yale University 208A Watson, Phone:
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Computer Graphics Lesson 2 July 12, 2005 Image Formats What are some formats you are familiar with? There are 4 basic image format types: Uncompressed.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
ITEC2110, Digital Media Chapter 2 Fundamentals of Digital Imaging 1 GGC -- ITEC Digital Media.
Data Representation Images.
Binary Representation in Audio and Images
Bitmap vs. Vector.
Learning Intention I will learn how a computer stores graphics.
Basic Graphics Drawing Shapes 1.
Data Representation.
Computer Graphics Using “Adobe Photoshop”
SSEA Computer Science: Track A
CSE 8A Lecture 6 Reading for next class:
Gray Scale picture def pixBW(pixel): # given a pixel, change to BW
COMS 161 Introduction to Computing
Color and Images.
CS 177 Week 3 Recitation Slides
"Digital Media Primer" Yue-Ling Wong, Copyright (c)2013 by Pearson Education, Inc. All rights reserved.
Year 8 Unit 2 Bitmap Graphics
Presentation transcript:

CS2984: Introduction to Media Computation Drawing directly on images

Today’s Class: Drawing Graphics Referring to individual pixels by x,y location Drawing graphics by changing lots of pixels Graphics functions that are built in to JES Programmed graphics

We can make whatever we want on pictures already All drawing on pictures comes down to changing pixel values. By directly changing values to black (or whatever else we want), we can draw whatever we want.

Drawing lines on Santa def lineExample(): img = makePicture(pickAFile()) new = verticalLines(img) new2 = horizontalLines(img) show(new2) return new2 def horizontalLines(src): for x in range(1,getHeight(src),5): for y in range(1,getWidth(src)): setColor(getPixel(src,y,x),black) return src def verticalLines(src): for x in range(1,getWidth(src),5): for y in range(1,getHeight(src)): setColor(getPixel(src,x,y),black) return src Colors defined for you already: black, white, blue, red, green, gray, lightGray, darkGray, yellow, orange, pink, magenta & cyan Nested loops (one loop inside another loop): More on this next class

But that’s tedious It’s slow and tedious to set every pixel you want. What you really want to do is to think in terms of your desired effect (think about “requirements” and “design”)  E.g. Instead of “change the color of all the pixels that happen to be in a line to black”, say “draw a black line”

Today’s Class: Drawing Graphics Referring to individual pixels by x,y location Drawing graphics by changing lots of pixels Graphics functions that are built in to JES Programmed graphics

New functions addText(pict,x,y,string) puts the string starting at position (x,y) in the picture addLine(picture,x1,y1,x2,y2) draws a line from position (x1,y1) to (x2,y2) addRect(pict,x1,y1,w,h) draws a black rectangle (unfilled) with the upper left hand corner of (x1,y1) and a width of w and height of h addRectFilled(pict,x1,y1,w,h,color) draws a rectangle filled with the color of your choice with the upper left hand corner of (x1,y1) and a width of w and height of h

Example picture def littlepicture(): canvas=makePicture(getMediaPath("640x480.jpg")) addText(canvas,10,50,"This is not a picture") addLine(canvas,10,20,300,50) addRectFilled(canvas,0,200,300,500,yellow) addRect(canvas,10,210,290,490) return canvas

A thought experiment Look at that previous page: Which is a fewer number of bytes?  The program that drew the picture  The pixels in the picture itself. It’s a no-brainer  The program is less than 100 characters (100 bytes)  The picture is stored on disk at about 15,000 bytes

Today’s Class: Drawing Graphics Referring to individual pixels by x,y location Drawing graphics by changing lots of pixels Graphics functions that are built in to JES Programmed graphics

Vector-based vs. Bitmap Graphical representations Vector-based graphical representations are basically executable programs that generate the picture on demand.  Postscript, Flash, and AutoCAD use vector-based representations Bitmap graphical representations (like JPEG, BMP, GIF) store individual pixels or representations of those pixels.  JPEG and GIF are actually compressed representations

Vector-based representations can be smaller Vector-based representations can be much smaller than bit-mapped representations  Smaller means faster transmission (Flash and Postscript)  If you want all the detail of a complex picture, no, it’s not.

But vector-based has more value than that Imagine that you’re editing a picture with lines on it.  If you edit a bitmap image and extend a line, it’s just more bits. There’s no way to really realize that you’ve extended or shrunk the line.  If you edit a vector-based image, it’s possible to just change the specification Change the numbers saying where the line is Then it really is the same line That’s important when the picture drives the creation of the product, like in automatic cutting machines

But how could we change the program? How could we reach in and change the actual program? That’s called string manipulation  The program is just a string of characters  We want to manipulate those characters, in order to manipulate the program Coming up soon…

Example programmed graphic If I did this right, we perceive the left half as lighter than the right half In reality, the end quarters are actually the same colors.

Building a programmed graphic def greyEffect(): file = getMediaPath("640x480.jpg") pic = makePicture(file) # First, 100 columns of 100-grey grey = makeColor(100,100,100) for x in range(1,100): for y in range(1,100): setColor(getPixel(pic,x,y),grey) # Second, 100 columns of increasing greyness greyLevel = 100 for x in range(100,200): grey = makeColor(greyLevel, greyLevel, greyLevel) for y in range(1,100): setColor(getPixel(pic,x,y),grey) greyLevel = greyLevel + 1 # Third, 100 colums of increasing greyness, from 0 greyLevel = 0 for x in range(200,300): grey = makeColor(greyLevel, greyLevel, greyLevel) for y in range(1,100): setColor(getPixel(pic,x,y),grey) greyLevel = greyLevel + 1 # Finally, 100 columns of 100-grey grey = makeColor(100,100,100) for x in range(300,400): for y in range(1,100): setColor(getPixel(pic,x,y),grey) return pic

Another Programmed Graphic def coolpic(): canvas=makePicture(getMediaPath("640x480.jpg")) for index in range(25,1,-1): color = makeColor(index*10,index*5,index) addRectFilled(canvas,0,0,index*10,index*10,color) show(canvas) return canvas

And another def coolpic2(): canvas=makePicture(getMediaPath("640x480.jpg")) for index in range(25,1,-1): addRect(canvas,index,index,index*3,index*4) addRect(canvas,100+index*4,100+index*3,index*8,index*10) show(canvas) return canvas

Why do we write programs? Could we do this in Photoshop? Maybe  I’m sure that you can, but you need to know how. Could I teach you to do this in Photoshop? Maybe  Might take a lot of demonstration But this program is an exact definition of the process of generating this picture  It works for anyone who can run the program, without knowing Photoshop

We write programs to encapsulate and communicate process If you can do it by hand, do it. If you need to teach someone else to do it, consider a program. If you need to explain to lots of people how to do it, definitely use a program. If you want lots of people to do it without having to teach them something first, definitely use a program.

Today’s Class: Drawing Graphics Referring to individual pixels by x,y location Drawing graphics by changing lots of pixels Graphics functions that are built in to JES Programmed graphics - Each pixel knows its x,y position - range() returns a list of numbers (not pixels) - we can use range() to define which x,y pixels are interesting - Works, but tedious & slow - addText(), addRect(), etc. -Vector graphics take less space - & can be changed easily -Really, small special graphics recipes -Created by modifying canvas