IAT 265 Images in Processing PImage. Jun 27, 2014IAT 2652 Outline  Programming concepts –Classes –PImage –PFont.

Slides:



Advertisements
Similar presentations
Image Navigator Help Session. Review Graphics2D class for drawing shapes in a component – paintComponent(Graphics g) – Graphics2D g2 = (Graphics2D)g;
Advertisements

Objects. 2 Object Oriented Programming (OOP) OOP is a different way to view programming Models the real world A different view than Structured programming.
Image Processing … computing with and about data, … where "data" includes the values and relative locations of the colors that make up an image.
Processing the Danger Shield Everything you wanted to know about Processing but were afraid to ask By Ben Leduc-Mills.
Cosc 5/4730 Blackberry Drawing. Screen size With Blackberry devices, they have a known screen size in pixels. If you are programming for specific device.
A Quick Introduction to Processing
Emerging Platform#5: Processing 2 B. Ramamurthy 6/13/2014B. Ramamurthy, CS6511.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Programming Project 2 SORTING Lecture 05, file P2 Due January.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Programming Project 1 Truth Table Lecture 03, file P1 Due January.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Graphics Programming. In this class we will cover: Drawing lines, rectangles, and ellipses Copying an area Drawing an image.
Text David Meredith Aalborg University.
Grundaufbau import processing.core.PApplet; public class Proc_Minimal extends PApplet { public void setup(){ size(1024, 768); frameRate(60.0f);
Images. PImage class PImage is a class for loading and displaying an image in Processing. Declare a PImage type: PImage img; Make a new instance by loading.
Data: Programming Design and Modularization IS 101Y/CMSC 101 Computational Thinking and Design Thursday, September 26, 2013 Marie desJardins University.
IAT 334 Lab 2 Computer Graphics: Rocket, PImage. June 4, 2010IAT 3342 Outline  Programming concepts –Programming Computer Graphics –Transformations –Methods.
Processing Processing is a simple programming environment that was created to make it easier to develop visually oriented applications with an emphasis.
IAT 334 Java using Processing ______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY.
DSA Processing. Links Processing.org My Processing page Ben Fry Ben Fry’s Thesis on Computational Information DesignThesis Casey Reas siteCasey Reas Casey.
, Fall 2006IAT 800 Lab 2: Polygons, Transformations, and Arrays.
IAT 800 Foundations of Computational Art and Design ______________________________________________________________________________________ SCHOOL OF INTERACTIVE.
IAT 800 Lecture 4. Sept 18, Fall 2006IAT 8002 Outline  Programming concepts –Methods –Classes  Talk about project 1  Reading: Read Chapters 1-4 of.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
Lecture 3 IAT 800. Sept 15, Fall 2006IAT 8002 Suggestions on learning to program  Spend a lot of time fiddling around with code –Programming is something.
IAT 800 Lecture 8. Oct 13, Fall 2006IAT 8002 Outline  Programming concepts –BImage BFont –Creating XImage –Typography.
IAT 355 Lecture 4 Computer Graphics: Rocket. May 9, 2014IAT 3552 Outline  Programming concepts –Programming Computer Graphics –Transformations –Methods.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Java Spring PImage Let’s look at the PImage class in ProcessingPImage –What are the fields (i.e., variables)? –What methods are available? –What.
Introduction to Processing CS 4390/5390 Fall 2014 Shirley Moore, Instructor September 3,
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
PImage. Let’s look at the PImage class in ProcessingPImage –What are the fields (i.e., variables)? –What methods are available? –What about the constructor---how.
Processing can load images, display them on the screen, and change their size, position, opacity, and tint. You can load gif, png and jpg images in processing.
Introduction to Image processing using processing.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02b: Tutorial for Programming in Processing Jarek Rossignac.
B. RAMAMURTHY Simulating Motion and Implementing Animation.
Review Inheritance Overloading and overriding. example1.pde.
CIS 3.5 Lecture 2.2 More programming with "Processing"
Variables Art &Technology, 3rd Semester Aalborg University Programming David Meredith
Test 2 Review. General Info. All tests are comprehensive. You are still responsible for the material covered prior to the first exam. You will be tested.
CS 325 Introduction to Computer Graphics 04 / 12 / 2010 Instructor: Michael Eckmann.
Words. Characters and Strings Character –A single character inside of single quotes char letter = 'A' ; char digit = '0' ; – Strings Zero or more character.
Processing TYWu. Where can I download? 2.0b9 Windows 32-bit.
B. RAMAMURTHY Processing and Programming cse
Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan.
Data: Programming Design and Modularization IS 101Y/CMSC 101 Computational Thinking and Design Thursday, September 25, 2014 Carolyn Seaman Susan Martin.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
Processing Variables. Variables Processing gives us several variables to play with These variables are always being updated and you can assume they have.
Review Random numbers mouseX, mouseY setup() & draw() frameRate(), loop(), noLoop() Mouse and Keyboard interaction Arcs, curves, bézier curves, custom.
Computer Science I Text input. Transformations. Yet another jigsaw. Classwork/Homework: Create new application making use of transformations.
Object Oriented Programming Lecture 3: Things OO.
IAT 800 Lecture 8 PImage and PFont. Oct 13, Fall 2009IAT 8002 Outline  Programming concepts –PImage –PFont.
Programming in Processing Taught by Ms. Madsen Assistants: Ms. Fischer and Ms. Yen Winsor School, 2/20/08.
Variables. Something to mention… void setup(){ size(200, 200); background(255); smooth(); } void draw() { stroke(0); strokeWeight(abs(mouseX-pmouseX));
數位影像處理 Digital Image Processing 吳育龍老師. Read image data Screen Resolution : 1024 X
David Meredith Aalborg University
Some of Chap 17.
Computer Graphics: Rocket, Java: Class
IAT 265 PImage and PFont.
Emerging Platform#1: Processing 3
Example: Card Game Create a class called “Card”
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
Chapter 15, Images …a few points
For Net Art Lecture 2 J Parker
Exam1 Review CSE113 B.Ramamurthy 11/29/2018 B.Ramamurthy.
Chapter 15, Images …a few points
Programming for Art: Images
Chap 17 Section 3.
Exam1 Review CSE113 B.Ramamurthy 4/17/2019 B.Ramamurthy.
LCC 6310 Computation as an Expressive Medium
Presentation transcript:

IAT 265 Images in Processing PImage

Jun 27, 2014IAT 2652 Outline  Programming concepts –Classes –PImage –PFont

Jun 27, 2014IAT 2653 Loading Images  Loading Images –Give your project a name and save. –Place the image file in: /sketchbook/ /data/ –Use this code: PImage img = loadImage(“ ”);

Jun 27, 2014IAT 2654 Displaying Images  image( PImage img, int x, int y); shows your image. image(img, 0, 0) will display your image from the last slide at the top left of the window.

Jun 27, 2014IAT 2655 Accessing Pixels  The PImage class allows you to access the RGB values of each individual pixel of the image, with the pixels[] array.  You can get the width and height of the image file using the width and height fields of PImage.

Jun 27, 2014IAT 2656 Accessing Pixels  How do we know which pixel to look for in the array?

Jun 27, 2014IAT 2657 Accessing Pixels  How do we know which pixel to look for in the array?

Jun 27, 2014IAT 2658 Accessing Pixels  How do we know which pixel to look for in the array?

Jun 27, 2014IAT 2659 Accessing Pixels  How do we know which pixel to look for in the array?

Jun 27, 2014IAT Accessing Pixels  Array Index –x + y*width (4, 0) = 4 + 0*5 = 4 (3, 2) = 3 + 2*5 = 13

Jun 27, 2014IAT Accessing Pixels  What would a piece of code look like that got a color from a pixel?  Let’s look at some applications of this. PImage im = loadImage(“test1.jpg”); color c1 = im.pixels[3 + 2*im.width];// get color at (3, 2) stroke(c1); // set our line color

Jun 27, 2014IAT Window vs. Image  The drawing window also has a pixels[] array. –You must call loadPixels(); to get the image from the screen –You don’t need a PImage object. loadPixels(); color c2 = pixels[3 + 2*width]; // gives us the color at (3, 2) in the window.

Jun 27, 2014IAT Window vs. Image  When would we want to use both of these? –Use the Window’s pixels if you want to draw more things based on the image that’s already on the screen. –Use the Image’s pixels if you want to manipulate the pixels of the image before you draw them.

Jun 27, 2014IAT D Arrays  Java lets us make Arrays of Arrays, otherwise called 2D Arrays. These are very useful for accessing arrays of pixels like the ones we’ve been working with. int[][] bob = new int[3][4]; color[][] pixels2d = new color[200][200];

Jun 27, 2014IAT D Arrays  Processing doesn’t provide us with a 2D array of pixels to use, so let’s develop a class that will make manipulating pixels easier.

Jun 27, 2014IAT D Arrays  Interestingly, 2D Arrays are just covering up a 1D array much like the pixels[] array. color[][] pixels2d = new color[20][20]; color c2 = pixels2d[3][2]; color[] pixels1d = new color[400]; color c1 = pixels1d[3 + 2*20]; Underneath, these two pieces of code do the same thing. The 2D array convention just makes it easier for us to access the array based on things like our x and y values.

Jun 27, 2014IAT PFont  PFont is the Processing class for manipulating fonts –Like PImage for images  Use PFont with –PFont loadFont() – loads a font –textFont(PFont font, int size) – sets the current font –text(String str, int x, int y) – draws a string in the current font at the current location

Jun 27, 2014IAT Simple example // the fonts must be located in the data directory PFont engravers = loadFont("EngraversMT-48.vlw"); PFont cour = loadFont("Courier-32.vlw"); textFont(engravers, 44); text("word", 10, 30); textFont(cour, 44); text("word", 10, 60);

Jun 27, 2014IAT Use fill() to change the color of text // the fonts must be located in the data directory PFont engravers = loadFont("EngraversMT-48.vlw"); PFont cour = loadFont("Courier-32.vlw"); fill( 0, 255, 0 ); textFont(engravers, 44); text("word", 10, 30); fill( 255, 0, 0 ); textFont(cour, 44); text("word", 10, 60);

Jun 27, 2014IAT textMode sets the alignment  textAlign( LEFT ); –x, y is the upper left hand corner of the text  textAlign( RIGHT ); –x, y is the upper right hand corner of the text  textAlign( CENTER ); –x, y is the upper center of the text

Jun 27, 2014IAT Producing text effects  All the transform methods apply to drawing text –That means you can translate, rotate, and scale text  Combined with draw(), this means you can move text around the screen in real time –Remember, the movement of the rocket and asteroids in our asteroids example was just translation and rotation  So you can make textual machines where text moves around the screen!

Jun 27, 2014IAT Processing example PImage im ; PFont engrvr ; PFont courier ; void setup() { size( 600, 600 ); im = loadImage( "cdshaw.96.jpg" ); for( int i = 600 ; i >= 0 ; i -= 50 ) image( im, i, i ); engrvr = loadFont( "EngraversMT-48.vlw" ); courier = loadFont( "Courier-32.vlw" ); textFont( engrvr ); } void draw( ) { image( im, mouseX-370, mouseY-210 ); color c1 = im.pixels[ * im.width ] ; loadPixels(); c1 = pixels[ * width ] ; stroke( c1 ); fill( c1 ); textAlign( LEFT ); ellipse( mouseX, mouseY, 20, 10 ); textFont( engrvr, 44 ); text( "Yo!", mouseX + 20, mouseY + 20 ); fill( 255, 0, 0); pushMatrix(); textAlign( RIGHT ); rotate( 0.2); textFont( courier, 44 ); text( "Yo?", mouseX, mouseY ); popMatrix(); }

Review  Graphics: image( img, x, y )  PImage is also a class. –Each actual image is an object Jun 27, 2014IAT 26523

Review  Object Oriented Programming –Class-- a type you define –Instance-- one variable of a class –Fields-- variables within a class –Methods-- functions that act within a class –Constructor-- create an instance of a class Jun 27, 2014IAT 26524