Digital Pictures Represented by pixels Stored in .jpg (JPEG) files

Slides:



Advertisements
Similar presentations
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.
Advertisements

ManipulatingPictures-Mod6-part21 Manipulating Pictures, Arrays, and Loops part 2 Barb Ericson Georgia Institute of Technology.
Georgia Institute of Technology Manipulating Pictures, Arrays, and Loops part 1.
© 2004 Pearson Addison-Wesley. All rights reserved2-1 Introduction to Graphics The last few sections of each chapter of the textbook focus on graphics.
1 A Simple Applet. 2 Applets and applications An application is an “ordinary” program Examples: Notepad, MS Word, Firefox, Halo, etc. An applet is a Java.
©2004 Brooks/Cole Applets Graphics & GUIs. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Graphical Programs Most applications these days are.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Java Applets What is an Applet? How do you create.
Georgia Institute of Technology Manipulating Pictures, Arrays, and Loops part 1 Barb Ericson Georgia Institute of Technology August 2005.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Applets and Graphics.
A Simple Applet. Applets and applications An applet is a Java program that runs on a web page –Applets can be run from: Internet Explorer Netscape Navigator.
A Simple Applet.
Color (1) Turtle class contains a method to change the pen color Note: before using Color class, you should add following line in the top of the source.
Chapter 5 Graphics. Topics Applets Classes used for graphics –Graphics –Point –Dimension –Color.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Java Programs u 1 project file –with an extension of.mcp –contains information that CodeWarrior needs to run the program u >= 1 source files –have an extension.
Digital Images The digital representation of visual information.
Color Names All standards-compliant browsers should handle these color names These color names can be used with the CSS properties of color and background-color.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Java Applets What is an Applet? How do you create.
TOPIC 4 INTRODUCTION TO MEDIA COMPUTATION: DIGITAL PICTURES Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
How to use the Java class libraries Brief documentation of how to do this all with Java.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 14 Introduction to Computer Graphics.
Copyright © 2009 Curt Hill The Picture Object Getting and displaying.
ManipulatingPictures-part11 Manipulating Pictures, Arrays, and Loops part 1 Barb Ericson Georgia Institute of Technology Nov 2009.
1 Ethics of Computing MONT 113G, Spring 2012 Session 10 HTML Tables Graphics on the Web.
Jeopardy Heading1Heading2Heading3Heading4 Heading5 Q $100 Q $200 Q $300 Q $400 Q $500 Q $100 Q $200 Q $300 Q $400 Q $500 Final Jeopardy.
Two –Dimensional Arrays Mrs. C. Furman Java Programming November 19, 2008.
Applets Applet is java program that can be embedded into HTML pages. Java applets runs on the java enabled web browsers such as mozilla and internet explorer.
1 A Simple Applet. 2 Applets and applications An application is an “ordinary” program Examples: Notepad, MS Word, Firefox, Halo, etc. An applet is a Java.
Chapter 2: Color and Applets Coming up: Introduction to Graphics.
Image Representation. Digital Cameras Scanned Film & Photographs Digitized TV Signals Computer Graphics Radar & Sonar Medical Imaging Devices (X-Ray,
Digital Pictures Represented by pixels –With a red, green, and blue value stored for each pixel (each has a range from 0 to 255) Stored in.jpg (JPEG) files.
ManipulatingPictures-Mod6-part11 Manipulating Pictures, Arrays, and Loops part 1 Barb Ericson Georgia Institute of Technology.
CSC1401 Manipulating Pictures. What we have done to date We have modified pictures by writing on top of them Using Turtles and using Graphics Drawing.
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.
Digital Images are represented by manipulating this…
Classes Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
 By Bob “The Bird” Fiske & Anita “The Snail” Cost.
1 A Simple Applet. 2 Applets and applications An applet is a Java program that runs on a web page Applets can be run within any modern browser To run.
GUI Components. The Swing package has numerous GUI components that can be added to a window. The Swing package has numerous GUI components that can be.
Georgia Institute of Technology Manipulating Pictures, Arrays, and Loops Barb Ericson Georgia Institute of Technology August 2005.
Digital Graphics for Computer Games Pixels Types of Digital Graphics (Raster and Vector) Compression.
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.
HTTP transaction with Graphics HTML file + two graphics files.
Lecture # 6 Graphical User Interface(GUI). Introduction A graphical user interface (GUI) presents a user- friendly mechanism for interacting with an application.
TOPIC 4 INTRODUCTION TO MEDIA COMPUTATION: DIGITAL PICTURES Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
Intro to Graphics from Chapter 2 of Java Software Solutions
Chapter 02 Data and Expressions.
Getting and displaying
Manipulating Pictures, Arrays, and Loops part 1
Sampling, Quantization, Color Models & Indexed Color
Image Processing CS177.
Review.
Object Oriented Programming
Digital Pictures Represented by pixels Stored in .jpg (JPEG) files
Week 13 - Monday CS 121.
CS320n –Visual Programming
Two-Dimensional Arrays and Nested Loops – part 1
Workshop for Programming And Systems Management Teachers
Representing Images 2.6 – Data Representation.
Two-Dimensional Arrays and Nested Loops – part 1
Manipulating Pictures, Arrays, and Loops
Manipulating Pictures, Arrays, and Loops part 1
Other displays Saving Arrays Using fors to process
COMS 161 Introduction to Computing
COMS 161 Introduction to Computing
Manipulating Pictures, Arrays, and Loops
CS 177 Week 3 Recitation Slides
Digital Pictures Represented by pixels Stored in .jpg (JPEG) files
CSC1401 Manipulating Pictures 2
Presentation transcript:

Digital Pictures Represented by pixels Stored in .jpg (JPEG) files With a red, green, and blue value stored for each pixel (each has a range from 0 to 255) Stored in .jpg (JPEG) files International standard With “lossy compression” Lossy means not all data is stored But what is lost isn’t that important Compression means made smaller What are some other formats for storing pictures? For more about JPEG see http://en.wikipedia.org/wiki/Jpeg. See http://en.wikipedia.org/wiki/GIF for more information about GIFF. See http://en.wikipedia.org/wiki/Windows_bitmap for more information about BMP. This windows format is not compressed.

Pictures have lots of Pixels How can we refer to each pixel? pixel1, pixel2, pixel3, pixel4, pixel5, … Do we really want to name each one? There are 640 x 480 = 307,200 pixels How could we deal with all of the pixels in a picture WITHOUT naming each one separately?

What is an Array? Storage for a sequence of items 1 2 3 4 5 Storage for a sequence of items Of the same type You can access items by using the index The index starts at 0 The first item is at index 0 The last item is at index (length – 1) Arrays know their length (have a public length field) arrayObj.length 3 7 9 2 1 5 1 2 3 8 3 2 6 Think of seats in a row of a movie theater. They have an index too. They often start at 1. Java uses a 0-based index. This is a holdover from C when the index was really the distance from the beginning of the array. The distance from the beginning of the array to the first element is 0.

Manipulating a Picture To manipulate a picture we need to manipulate the pixels that make up the picture Change the red, green, or blue values at the pixel The Pixel class is not in the Java API!!! Created by the same people who made the Turtle class (Barbara Ericson @ Ga. Tech) Each pixel object has a red, green, and blue value

What Information Can A Picture Object Give Us? Each picture object has an array of pixel objects Read from the JPEG file It knows the picture’s width & height Which methods of SimplePicture do this? How would we call them? It knows how to obtain an array of pixel objects What method of SimplePicture does this? How would we call it?

Pixel Objects Each pixel has a red, green, and blue value getRed(), getGreen(), getBlue() setRed(v), setGreen(v), setBlue(v) Each pixel knows the location it was in the picture object getX(), getY() You can also get and set the color at the pixel getColor(), setColor(color)

Color Objects There is a class defined in Java that represents color The Color class in the package java.awt To use the class you must either import java.awt.Color; Use the full name java.awt.Color You can create a color object by giving the red, green, and blue values for it Color colorObj = new Color(255,10,125);

Predefined Colors The Color class has defined class constants for many colors Color.red, Color.green, Color.blue, Color.black, Color.white, Color.yellow, Color.gray, Color.orange, Color.pink, Color.cyan, Color.magenta Or you can use all uppercase names Color.RED, Color.BLUE, Color.BLACK, … Originally the predefined colors where are lowercase names. However, the Java convention for constants is to use all uppercase letters. So the uppercase names for the predefined colors were added.

Getting and Setting Pixel Colors EXAMPLE: Get a pixel’s color as a color object Color color1 = pixelObj.getColor(); int red = color1.getRed(); int green = color1.getGreen(); int blue = color1.getBlue(); EXAMPLE: Set a pixel’s color using a new color object red = 20; green = 30; blue = 100; Color color2 = new Color(red,green,blue); pixelObj.setColor(color2); For pixelObj use whatever the name is of the current pixel object.