Image Processing … computing with and about data, … where "data" includes the values and relative locations of the colors that make up an image.

Slides:



Advertisements
Similar presentations
Playing with pixels Programming For Artists Learning objectives:
Advertisements

aims By the end of the session you will be able to: Explain how images are represented in Processing Manipulate images using the pixels member Use for.
Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Programming Project 2 SORTING Lecture 05, file P2 Due January.
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.
IAT 334 Lab 2 Computer Graphics: Rocket, PImage. June 4, 2010IAT 3342 Outline  Programming concepts –Programming Computer Graphics –Transformations –Methods.
2D Arrays in Java. Interfaces  Separating What from How  Phones: Dial  Cars Gas, Break, Steer.
Raster Displays Images are composed of arrays of pixels displayed on a raster device. Two main ways to create images: –Scan and digitize an existing image.
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.
CS 4731: Computer Graphics Lecture 21: Raster Graphics Part 2 Emmanuel Agu.
Data starts with width and height of image Then an array of pixel values (colors) The number of elements in this array is width times height Colors can.
Tools for Raster Displays CVGLab Goals of the Chapter To describe pixmaps and useful operations on them. To develop tools for copying, scaling, and rotating.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004.
Computer Graphics Lecture 1 July 11, Computer Graphics What do you think of? The term “computer graphics” is a blanket term used to refer to the.
ITCS 3134 Final Project Ammar Ahmed and James Reetzke.
2002 by Jim X. Chen: 1 So far, we only concerned with the rendering of geometric data. Two other important classes of data:
Using the JImageViewer classes. JImageViewer classes JImageViewer class JImageViewer class ImagePanel class ImagePanel class Image class Image class.
Pictures Looping through pixels.. Lab Review (1) Objects  Instantiated from Class  Turtle myTut = new Turtle(myWorld);  new operator creates an instance.
Project ideas …. Basic Photoshop: – Take your green screen photo and select your head and place it over another student's head in their green screen photo.
Two –Dimensional Arrays Mrs. C. Furman Java Programming November 19, 2008.
Review Recursion Call Stack. Two-dimensional Arrays Visualized as a grid int[][] grays = {{0, 20, 40}, {60, 80, 100}, {120, 140, 160}, {180, 200, 220}};
INT 840E Computer graphics Introduction & Graphic’s Architecture.
Image Representation. Digital Cameras Scanned Film & Photographs Digitized TV Signals Computer Graphics Radar & Sonar Medical Imaging Devices (X-Ray,
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
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.
Graphic Format Factors
NestedLoops-Mody7-part51 Two-Dimensional Arrays and Nested Loops – part 5 Rotations Barb Ericson Georgia Institute of Technology May 2007.
Picture Lab. Manipulating Pictures Discussion and activities with java.awt.Color introduce students to megapixels, pixels, the RGB color model, binary.
Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic Light Source.
Arrays. An array is a collection “The Dinner offers an array of choices.” In computer programming, an array is a collection of variables of the same data.
Images. Digital Images Rectangular arrays of pixel data Pixel - picture element, smallest addressable part of the frame buffer. Color depth - the depth.
Computer Science I Classes and objects Classwork/Homework: Examine and modify my examples. Make your own.
Computer Science I Arrays. Parallel structures. Classwork/Homework: Build your own bouncing things.
Computer Science I Recap: variables & functions. Images. Pseudo-random processing.
Processing TYWu. Where can I download? 2.0b9 Windows 32-bit.
Chapter 4 -- Color1 Color Open GL Chapter 4. Chapter 4 -- Color2 n The goal of almost all OpenGL applications is to draw color pictures in a window on.
Sliding Doors Tutorial  doors/
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Programming for Art: Arrays – 2D ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 16 Fall 2010.
IAT 265 Images in Processing PImage. Jun 27, 2014IAT 2652 Outline  Programming concepts –Classes –PImage –PFont.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
IAT 800 Lecture 8 PImage and PFont. Oct 13, Fall 2009IAT 8002 Outline  Programming concepts –PImage –PFont.
Computer Science I More class examples. Paths. Jigsaw. Tolerance. Classwork/homework: Your class project. Post proposal for midterm project.
Tabs with Rounded Corners (Sliding Doors). Sliding Doors Tutorial  doors/
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
CSE 1301 Lecture 12 Arrays Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
數位影像處理 Digital Image Processing 吳育龍老師. Read image data Screen Resolution : 1024 X
Photoshop: Painting and Retouching Computer Information Technology Section 60.
Task 1 and Task 2. Variables in Java Programs Variables start with lower case letter Variables are descriptive of what they store Variables are one word.
Graphics and image data representation
Image Processing Objectives To understand pixel based image processing
David Meredith Aalborg University
IAT 265 PImage and PFont.
Kyoungju Park Computer Graphics Kyoungju Park
1.01 Investigate graphic types and file formats.
2D Drawing Basics 1.
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
CS320n –Visual Programming
Based on lecture notes from Dr. Deepak Kumar of Brynmawr
Based on lecture notes from Dr. Deepak Kumar of Brynmawr
Two-Dimensional Signal and Image Processing Chapter 8 - pictures
Gradient Type 1 Gradient stops: 5 Stop #: 1 Position: 0
Multidimensional Arrays
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Programming for Art: Images
Just a question for Mac users:
Chapter 15, Images …a few points
Can you calculate the actual file size of a computer image
The Image The pixels in the image The mask The resulting image 255 X
Presentation transcript:

Image Processing … computing with and about data, … where "data" includes the values and relative locations of the colors that make up an image.

An image is an array of colors mag.pde Pixel : Picture Element

Color A triple of bytes [0, 255] – RGB or HSB Transparency (alpha) – How to blend a new pixel color with an existing pixel color rgba.pde

Accessing the pixels of a sketch loadPixels() – Loads the color data out of the sketch window into a 1D array of colors named pixels[] – The pixels[] array can be modified updatePixels() – Copies the color data from the pixels[] array back to the sketch window

A 100-pixel wide image First pixel at index 0 Right-most pixel in first row at index 99 First pixel of second row at index 100 The pixels[] array is one-dimensional … … …

// whiteNoise void setup() { size(400, 300); } void draw() { float b; // Load colors into the pixels array loadPixels(); // Fill pixel array with a random // grayscale value for (int i=0; i<pixels.length; i++) { b = random(0, 255); pixels[i] = color(b); } // Update the sketch with pixel data updatePixels(); } See also colorNoise.pde

Accessing Pixels as a 2D Array Pixels can be accessed as a 2D array using the following formula: index = r * width + c index = y * width + x Using 0-based indices int idx = width*r + c; pixels[idx] = color(b);

// cone void setup() { size(400, 400); // Load colors into the pixels array loadPixels(); // Access pixels as a 2D array for (int y=0; y<height; y++) { for (int x=0; x<width; x++) { // Compute distance to center point float d = dist(x, y, width/2, height/2); // Set pixel as distance to center pixels[y*height+x] = color(d); } // Update the sketch with pixel data updatePixels(); }

Rendering Images in a Sketch Image data can be loaded from a file using loadImage() method, and drawn on a sketch with the image() command The PImage object also permits individual pixel color data to be modified. – like the sketch window PImage img = loadImage("myImage.jpg"); image(img, 0, 0);

PImage Fields width- the width of the image height- the height of the image pixels[]- the image pixel colors (after a call to loadPixels())

PImage Methods loadPixels() Loads the color data out of the PImage object into a 1D array of colors named pixels[]. updatePixels() Copies the color data from the pixels[] array back to the PImage object. Also red(color)extract the red component of from color blue(color)extract the green component from a color green(color)extract the blue component from a color

Basic Filters Color – Extracting Red/Green/Blue colors pixels[i] = color(red(c), 0, 0); pixels[i] = color(0, 0, blue(c)); – Grayscale pixels[i] = color(0.3*red(c)+ 0.59*green(c)+ 0.11*blue(c)); – Negative pixels[i] = color(255-red(c), 255-green(c), 255-blue(c));

Sepia Technique for archiving BW photos – float r = red(c)*0.393+green(c)*0.769+blue(c)*0.189; – float g = red(c)*0.349+green(c)*0.686+blue(c)*0.168; – float b = red(c)*0.272+green(c)*0.534+blue(c)*0.131; – pixels[i] = color(r, g, b);

PImage Methods (Cont'd) get(…) Reads the color of any pixel or grabs a rectangle of pixels set(…) Writes a color to any pixel or writes an image into another copy(…) Copies pixels from one part of an image to another mask(…) Masks part of the image from displaying save(…) Saves the image to a TIFF, TARGA, PNG, or JPEG file resize(…) Changes the size of an image to a new width and height blend(…) Copies a pixel or rectangle of pixels using different blending modes filter(…) Processes the image using one of several algorithms

get(…) Get a single pixel (very slow) Color c = img.get(x, y); Get a rectangular range of pixels PImage img2 = img.get(x, y, w, h);

tint(…) / noTint() tint() modifies the fill value for images tint( gray ); tint( gray, alpha ); tint( red, green, blue ); tint( red, green, blue, alpha ); Turn off applied tint() values with noTint()

// warhol2 void setup() { // Load the image three times PImage warhol = loadImage("andy-warhol2.jpg"); size(warhol.width*3, warhol.height); // Draw modified images tint(255, 0, 0); image(warhol, 0, 0); tint(0, 255, 0); image(warhol, 250, 0); tint(0, 0, 255); image(warhol, 500, 0); }

// fade PImage[] img = new PImage[5]; int alpha = 255; int i1 = 0, i2 = 1; void setup() { size(600,400); imageMode(CENTER); for (int i=0; i<img.length; i++) // Load images img[i] = loadImage("bmc"+i+".jpg"); } void draw() { background(255); // Fade out current image tint(255, alpha); image(img[i1], 300, 200); // Fade in next image tint(255, 255-alpha); image(img[i2], 300, 200); // Swap images when fade complete alpha--; if (alpha < 0) { i1 = (i1 + 1) % img.length; i2 = (i2 + 1) % img.length; alpha = 255; }

// pointillism PImage img; void setup() { img = loadImage("bmc3.jpg"); image(img.width, img.height); imageMode(CENTER); image(img, width/2, height/2); noStroke(); ellipseMode(CENTER); loadPixels(); // Cover with random circles for (int i=0; i<20000; i++) addPoint(); } void addPoint() { // Add a random filled circle to image int x = (int)random(width); int y = (int)random(height); int i = x + width*y; color c = pixels[i]; fill(c); ellipse(x, y, 7, 7); } void draw() { //addPoint(); }

Simple Image Visualization Sample pixel colors every n pixels Draw a grid of basic shapes (ellipse, rect, line, triangle, etc) using the sampled color as fill color or stroke color