Pictures Looping through pixels.. Lab Review (1) Objects  Instantiated from Class  Turtle myTut = new Turtle(myWorld);  new operator creates an instance.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

RAPTOR Syntax and Semantics By Lt Col Schorsch
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.
Georgia Institute of Technology Manipulating Pictures, Arrays, and Loops part 1.
Computer Vision Chapter 6 Color.
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
Color.
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.
CSc 461/561 CSc 461/561 Multimedia Systems Part A: 2. Image.
Games and Simulations O-O Programming in Java The Walker School
Digital Images The digital representation of visual information.
CS 102 Computers In Context (Multimedia)‏ 01 / 28 / 2009 Instructor: Michael Eckmann.
Georgia Institute of Technology Introduction to Media Computation Barb Ericson Georgia Institute of Technology May 2006.
Image Processing & Perception Sec 9-11 Web Design.
Introduction to Programming Writing Java Beginning Java Programs.
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.
CS1315: Introduction to Media Computation Picture encoding and manipulation.
CS1315: Introduction to Media Computation Picture encoding and manipulation.
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.
Two –Dimensional Arrays Mrs. C. Furman Java Programming November 19, 2008.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Structured data types An elegant way to deal with the rgb image is to employ structured data types. A Java class is a generalization of a C struct. A structure.
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,
CS1315: Introduction to Media Computation Picture encoding and manipulation.
TOPIC 6 MODIFYING PICTURES USING LOOPS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and.
Introduction to Programming Writing Java Beginning Java Programs.
ManipulatingPictures-Mod6-part61 Manipulating Pictures, Arrays, and Loops: Eliminating color, Inversion, grey scale and adjusting for luminance Barb Ericson.
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.
Picture Lab. Manipulating Pictures Discussion and activities with java.awt.Color introduce students to megapixels, pixels, the RGB color model, binary.
February ,  2/16: Exam 1 Makeup Papers Available  2/20: Exam 2 Review Sheet Available in Lecture  2/27: Lab 2 due by 11:59:59pm  3/2:
CPSC1301 Computer Science 1 Chapter 4 Manipulating Pictures, Arrays, and Loops part 5.
Color Web Design Professor Frank. Color Displays Based on cathode ray tubes (CRTs) or back- lighted flat-screen Monitors transmit light - displays use.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
1 Arrays of Arrays An array can represent a collection of any type of object - including other arrays! The world is filled with examples Monthly magazine:
TOPIC 4 INTRODUCTION TO MEDIA COMPUTATION: DIGITAL PICTURES Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
Copyright © Curt Hill Further Picture Manipulation Considering position.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
ManipulatingPictures-part31 Manipulating Pictures, Arrays, and Loops part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
04-ManipulatingPictures-part21 Manipulating Pictures, Arrays, and Loops part 2 Barb Ericson Georgia Institute of Technology June 2008.
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.
1 of 32 Computer Graphics Color. 2 of 32 Basics Of Color elements of color:
Barbara Ericson Georgia Tech Sept 2005
Image Processing Objectives To understand pixel based image processing
Manipulating Pictures, Arrays, and Loops part 2
Manipulating Pictures, Arrays, and Loops part 2
Topic 6 Modifying Pictures Using Loops
Multimedia Summer Camp
Image Processing & Perception
Manipulating Pictures, Arrays, and Loops part 3
CS320n –Visual Programming
Manipulating Pictures, Arrays, and Loops part 2
Manipulating Pictures, Arrays, and Loops part 2
Looping through pixels.
CSE 113 A January 26 – 30, 2009.
Introduction to Media Computation
Other displays Saving Arrays Using fors to process
Manipulating Pictures, Arrays, and Loops
January 26 – 30, 2009 CSE 113 B.
Manipulating Pictures, Arrays, and Loops part 6
Digital Image Processing
CS 177 Week 3 Recitation Slides
Basic Concepts of Digital Imaging
Manipulating Pictures, Arrays, and Loops
Manipulating Pictures, Arrays, and Loops part 6
Corresponds with Chapter 5
Presentation transcript:

Pictures Looping through pixels.

Lab Review (1) Objects  Instantiated from Class  Turtle myTut = new Turtle(myWorld);  new operator creates an instance of the class  Constructor Constructs (initializes) object Has same name as class May need to supply arguments as parameters

Lab Review (2) Methods  Send message to object by calling method myTut.turnLeft();  Argument can be supplied as a parameter myTut.forward(45);

Lab Review (3) /** * Draws a square with side width pixels at the current position * in the world. * width length of the side */ public void drawSquare(int width) { //draw side one this.forward(width); // turn 90 deg counterclockwise this.turnLeft(); // draw side two … } For main program: /** This program draws uses the Turtle to draw nested S. 2/4/2007 */

Lab Review (4) Using the Java packages require that the class or classes be made available to the compiler. import statement used to do this  import java.awt.Color;  Put at top of the file  import java.awt.*; makes all classes in java.awt available.

Problem Manipulate a digital image  make a picture brighter/darker  alter the color in a picture In computer science we must often start by learning about the domain in which we are writing programs.  Often requires us to learn more about our language

Digital Images How are images encoded? Basic Idea: Represent image as a 2- dimensional matrix of colored dots. Human Visual Perception  Humans have low visual acuity  We see color and luminance (black and white) using different neural pathways in our brain  Luminance is perceived with our peripheral vision

Digital Images - Arrays Arrays are a contiguous collections of cells homogeneous data where each cell is identified by an index. int [] score = {23, 25, 22, 25}; score[0] is 23; score[1] is 25; score[3] is ? Arrays are objects. The assignment above is a shorthand that hides the new operator. int [] grades = new int [10]; // declares and // allocates grades[0] = 35;

Digital Images – Matrices Matrices are 2-dimensional arrays In Java a matrix is an array of arrays An image has type: Pixel [][] pictData; Row Major Order pictData [r] [c] Column Major Order pictData [c] [r]

Digital Images - Color Visible light is continuous  Wavelength: 370 nm – 730 nm We have red, green, blue receptors  red peak: 560 nm  green peak: 550 nm  blue peak: 425 nm Color we see is based upon signals from recptors

Digital Images – Color Models RGB – Red Green Blue HSV – Hue Saturation and Value CMYK – Cyan, Magenta, Yellow, Black  Used by printers

Digital Image - RGP Three Channels  Red, Green, Blue  Value Range: 0 – 255  24 bit color 16 million colors Does not cover range of colors we perceive  32 bit color 16 million colors alpha channel – transparency

Creating an Image String fileName = FileChooser.pickAFile(); Picture pict = new Picture(fileName); // show the image pict.show(); // explore the image pict.expore();

Looking at Pixels Pixel pix = pict.getPixel(0,0); int xCord = pix.getX(); int yCord = pix.getY(); int redVal = pix.getRed(); pix.setRed(255); pix.setGreen(0); pix.setBlue(0); pict.repaint(); // must repaint to show // change

Looking at Pixels (2) Pixel [] imgData = pict.getPixels(); pict.getPixel(10,100).setColor(Color.black); pict.getPixel(11,100).setColor(Color.black); pict.getPixel(12,100).setColor(Color.black); pict.getPixel(13,100).setColor(Color.black); pict.repaint(); This process is a little laborious!!

Changing The Green Component For All Pixels Push the green component to 255 for all pixels. Algorithm  Get an array of pixels in image  For each pixel in the image set the green component to 255 How do we do the for each?

The For Each Loop Allows us to repeat a set of Java commands for each element in an array. Syntax  for (type variableName: array) statement;  for multiple statements enclose in { }

Method to Maximize Green public void maxGreen() { // get the pixels Pixel [] pixels = this.getPixels(); // set the pixels to max green for(Pixel curPix : pixels) { curPix.setGreen(255); }

While Loops Java provides other ways to construct loops While loop  loop while some condition is true  syntax while (test) statement;  Advice: always use braces

Maximize Green With a While Loop public void maxGreen() { // get the pixels Pixel [] pixels = this.getPixels(); // set the pixels to max green int curPos = 0; while (curPos < pixels.length) { pixels[curPos].setGreen(255); curPos++; // same as curPos = curPos + 1; }

For Loop Loop with a built-in counter – also called a counting loop Syntax  for (init; limit test; change) statement;  Advice: always use braces

Maximize Green With a For Loop public void maxGreen() { // get the pixels Pixel [] pixels = this.getPixels(); // set the pixels to max green for (int i=0;i < pixels.length; i++) { pixels[i].setGreen(255); }

Scope For loop from previous slide for (int i=0;i < pixels.length; i++) { pixels[i].setGreen(255); } Where is i’s value know? Just inside the block the defines the body of the loop. This is i’s scope. Look at scope in Picture. Principle: Variables scope should be as small as possible. Called localization.