2D Graphics: Advanced Topics Chapter 4. Bird’s Eye View  Overview of Computer Graphics  2D Graphics: Basics  2D Graphics: Rendering Details  2D Graphics:

Slides:



Advertisements
Similar presentations
Department of nskinfo i-education
Advertisements

Digital Images in Java Java’s imaging classes. Java imaging library  Java has good support for image processing  Must master a handful of classes and.
COMPUTER GRAPHICS SOFTWARE.
Advanced Manufacturing Laboratory Department of Industrial Engineering Sharif University of Technology Session # 7.
Computer Graphics (Spring 2008) COMS 4160, Lecture 6: Curves 1
Multithreading : animation. slide 5.2 Animation Animation shows different objects moving or changing as time progresses. Thread programming is useful.
Chapter 5 Programming Graphics. Chapter Goals To be able to write applications with simple graphical user interfaces To display graphical shapes such.
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 13: NURBs, Spline Surfaces Ravi Ramamoorthi Some material.
Advanced Computer Graphics (Fall 2010) CS 283, Lecture 7: Quadric Error Metrics Ravi Ramamoorthi
© University of Wisconsin, CS559 Spring 2004
1 Curves and Surfaces. 2 Representation of Curves & Surfaces Polygon Meshes Parametric Cubic Curves Parametric Bi-Cubic Surfaces Quadric Surfaces Specialized.
Unit 141 Threads What is a Thread? Multithreading Creating Threads – Subclassing java.lang.Thread Example 1 Creating Threads – Implementing java.lang.Runnable.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 4 2D Graphics: Advanced Topics.
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
Modelling. Outline  Modelling methods  Editing models – adding detail  Polygonal models  Representing curves  Patched surfaces.
1 Lecture 13 Modeling Curved Lines and Surfaces. 2 Types of Surfaces Ruled Surfaces B-Splines and Bezier Curves Surfaces of Revolution.
1/12/09 1 Introduction Computer Graphics COMP 770 (236) Spring 2009 Instructor: Dinesh Manocha.
1 Chapter 4 2D Graphics: Advanced Topics  To construct custom shape primitives  To apply basic image processing techniques  To create fractal images.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 2 2D Graphics: Basics F The architecture.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Introduction to Modeling. What is CG Modeling? Combination of Sculpting, Architecture, Drafting, and Painting. The core component of computer animation.
Overview of Computer Graphics Chapter 1. Bird’s Eye View  Overview of Computer Graphics –Basic concept of computer graphics, system, programming platforms,
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
Graphics: Creating Images Chapter 8, Exploring the Digital Domain.
Java: Animation Chris North cs3724: HCI. Animation? Changing graphics over time Examples: cartoons Clippy, agents/assistants Hour glass Save dohicky Progress.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Chapter 12: Simulation and Modeling
1 Additional 3D Topics  Splitting polygons  Off screen rendering for capture of rendered images.  Sound in Java 3D scene graphs  Advanced textures.
Bresenham’s Algorithm. Line Drawing Reference: Edward Angel’s book: –6 th Ed. Sections 6.8 and 6.9 Assuming: –Clipped (to fall within the window) –2D.
A D V A N C E D C O M P U T E R G R A P H I C S CMSC 635 January 15, 2013 Spline curves 1/23 Curves and Surfaces.
DEVSView: A DEVS Visualization Tool Wilson Venhola.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Chapter 15 Multithreading F Threads Concept  Creating Threads by Extending the Thread class  Creating Threads by Implementing the Runnable Interface.
Java Programming: Advanced Topics
Multi-Threaded Application CSNB534 Asma Shakil. Overview Software applications employ a strategy called multi- threaded programming to split tasks into.
2D/3D Shape Manipulation, 3D Printing Shape Representations Slides from Olga Sorkine February 20, 2013 CS 6501.
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Advanced User Interfaces with Java SD’98 - Session 3206 Ted Faison Faison Computing Inc.
Computer Science Term 1, 2006 Tutorial 3 Assignment 4 – Special Effects.
Image processing with Java - 2D cont’d. Overview  An imaging model that supports the manipulation of fixed- resolution images stored in memory.  A new.
2D Graphics Basics Chapter 2. Bird’s Eye View  Overview of Computer Graphics  2D Graphics: Basics –Basic 2D graphics, rendering pipeline, geometry,
Chapter 2: Java Fundamentals
Field Trip #19 Animations with Java By Keith Lynn.
CSC 205 – Java Programming II Applet. Types of Java Programs Applets Applications Console applications Graphics applications Applications are stand-alone.
CSE 219 Computer Science III Image Manipulation. HW 1 Has been posted on Blackboard Making a Game of Life with limited.
CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5.
Multithreading in Java Sameer Singh Chauhan Lecturer, I. T. Dept., SVIT, Vasad.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
Geometric Modelling 2 INFO410 & INFO350 S Jack Pinches
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
Graphics and Java2D Chapter Java Coordinate System Origin is in _____________ corner –Behind title bar of window X values increase to the ________.
Representation of Curves & Surfaces Prof. Lizhuang Ma Shanghai Jiao Tong University.
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
Kansas State University Department of Computing and Information Sciences CIS 736: Computer Graphics Wednesday, February 9, 2000 William H. Hsu Department.
© Wang Bin 2004 Java Threads. © Wang Bin 2004 In this lesson, you will learn to: u Define the concepts of threads and multithreading  Identify the functions.
Parallel Processing (CS526) Spring 2012(Week 8).  Shared Memory Architecture  Shared Memory Programming & PLs  Java Threads  Preparing the Environment.
CISC 110 Day 3 Introduction to Computer Graphics.
Object-Oriented Software Engineering Using Threads and simple Animation.
Chapter 13: Multithreading The Thread class The Thread class The Runnable Interface The Runnable Interface Thread States Thread States Thread Priority.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Advanced Java Screen Update Techniques SD’98 - Session 4406 Ted Faison Faison Computing Inc.
Java Programming: From Problem Analysis to Program Design,
3D Object Representations
CSE 167 [Win 17], Lecture 9: Curves 1 Ravi Ramamoorthi
PPT6: Advanced Geometric Algorithms
Presentation transcript:

2D Graphics: Advanced Topics Chapter 4

Bird’s Eye View  Overview of Computer Graphics  2D Graphics: Basics  2D Graphics: Rendering Details  2D Graphics: Advanced topics –Advanced techniques in 2D graphics including B- spline curves, custom shape primitives, image processing, animation, fractal images, and printing 2

Objectives  To understand B-spline curves  To construct custom shape primitives  To apply basic image processing techniques  To create fractal images  To create 2D animation  To perform graphics printing 3

Key Classes and Methods  javax.awt.geom.GeneralPath.curveTo() –A method to construct a cubic curve segment  javax.awt.image.BufferedImage – A class encapsulating an image  javax.awt.image.BufferedImageOp –An interface for image-processing operators  java.swing.Timer – A class generating action events in a periodic fashion  java.lang.Runnable –An interface to define code executable as a separate thread  java.lang.Thread – A class encapsulating a thread of execution of a program  java.lang.Thread.sleep(long ms) –A method to place the thread to sleep for a specified time period  java.util.Calendar – A class encapsulating a calendar for date and time  java.awt.image.Raster – A class encapsulating image data  java.awt.image.WritableRaster –A class encapsulating writable image data  java.awt.print.PrinterJob – A class for printing management  java.awt.print.Printable – An interface to define print contents 4

Key Terms  B-spline curve –A curve defined as a parametric equation of piecewise polynomials blending with a sequence of control points.  Bezier curve –A curve defined as a parametric equation of polynomials blending with control points.  NURB – Non-uniform rational B-spline  Image processing –Computer manipulation of digital images to enhance or extract information.  Convolution – A type of linear operations often used in signal and image processing  Kernel – A function to define a convolution.  Complex numbers – An extension of real numbers  Complex plane – The set of complex numbers interpreted as points on a plane.  Frame rate – The speed of an animation measured in frames per second (fps)  THREAD –A LINE OF EXECUTION IN A RUNNING PROGRAM. In a multithreading environment a single program may have several threads running simultaneously.  Cellular automata –A dynamic system on a grid of cells, evolving based a simple set of rules that specify the next state of a cell using the previous states of itself and its neighbors. 5

General Bezier Curve 6 Bernstein basis

B-Spline Curve 7 Normalized B-spline blending functions

B-Spline to Bezier Conversion 8 Source

Shape Interface public boolean contains(Rectangle2D rect) public boolean contains(Point2D point) public boolean contains(double x, double y) public boolean contains(double x, double y, double w, double h) public Rectangle getBounds() public Rectangle2D getBounds2D() public PathIterator getPathIterator(AffineTransform at) public PathIterator getPathIterator(AffineTransform at, double flatness) public boolean intersects(Rectangle2D rect) public boolean intersects(double x, double y, double w, double h) 9

A Custom Primitive  Cannot extend the final class GeneralPath  Wrap a GeneralPath 10 Source public class Heart implements Shape { GeneralPath path; public Heart(float x,float y,float w,float h){ path = new GeneralPath(); …

Image Processing 11 F AWT – push model F Java 2D – immediate model F JAI – pull model

BufferedImage 12 BufferedImage bi = new BufferedImage(300, 400, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = (Graphics2D)(bi.createGraphics()); g2.drawImage(image, 0, 0, new Component() {}); BufferedImage bi = ImageIO.read(file); Create Read Display

Operators 13 Source

Raster and WritableRaster int[] getPixel(int x, int y, int[] data) float[] getPixel(int x, int y, float[] data) double[] getPixel(int x, int y, double[] data) int[] getPixels(int x, int y, int w, int h, int[] data) float[] getPixels(int x, int y, int w, int h, float[] data) double[] getPixels(int x, int y, int w, int h, double[] data) void setPixel(int x, int y, int[] data) void setPixel(int x, int y, float[] data) void setPixel(int x, int y, double[] data) void setPixels(int x, int y, int w, int h, int[] data) void setPixels(int x, int y, int w, int h, float[] data) void setPixels(int x, int y, int w, int h, double[] data) 14

Mandelbrot Set 15 Source Iterations on the complex plane

Animation: Multi-threading 16 Source Outline of a typical multi-threading animation public void paintComponent(Graphics g) { } public void run() { while(true) { repaint(); try { Thread.sleep(sleepTime); } catch (InterruptedException ex) {} }

Animation: Timer 17 Source Timer timer = new Timer(period, listener); timer.start(); public void actionPerformed(ActionEvent event) { } Outline of an animation with Timer

Cellular Automata 18 Source The iteration of the system proceeds by assigning the next state of each cell based on the previous configuration. Each cell follows the same set of rules and the new state depends only upon the current states of the same cell and its neighbors. Example: A cell is black if exactly one of its neighbors in the current configuration is black

Printing  PrintJob –getPrintJob –printDialog –setPrintable –print  Printable –Print  PageFormat –getOrientation –getWidth –getHeight –getImageableX –getImageableY –getImageableWidth –getImageableHeight 19 Source

Summary  A B-spline curves can be converted to a sequence of Bezier curves, which may then be rendered directly by the Graphics2D object. The control point of each Bezier curve are linear combinations of controls points of the B-spline curve.  Shape interface and GeneralPath class  BufferedImage class is the main representation for images in Java 2D. BufferedImageOp interface provides convenient ways to process BufferedImage objects.  Raster and WritableRaster classes offer access to the pixel data in a BufferedImage. Mandelbrot set is given.  The Thread class and the Runnable interface provide essential multithreading support. The Timer class of the Swing package provides a convenient utility to trigger the periodic frame rendering.  Graphics2D class provides the rendering engine. The Printable interface allows for the necessary callback structure for defining the graphics output. The PrinterJob class facilitates the special tasks in printing. 20