Computer Science 320 Parallel Image Generation. The Mandelbrot Set.

Slides:



Advertisements
Similar presentations
Computer Science 320 Clumping in Parallel Java. Sequential vs Parallel Program Initial setup Execute the computation Clean up Initial setup Create a parallel.
Advertisements

How SAS implements structured programming constructs
What is shape function ? shape function is a function that will give the displacements inside an element if its displacement at all the node locations.
COSC513 Operating System Research Paper Fundamental Properties of Programming for Parallelism Student: Feng Chen (134192)
Prepared 7/28/2011 by T. O’Neil for 3460:677, Fall 2011, The University of Akron.
Chapter 10 Introduction to Arrays
Computer Science 320 Reduction Variables and Operators.
Dale & Lewis Chapter 3 Data Representation. Representing color Similarly to how color is perceived in the human eye, color information is encoded in combinations.
Embarrassingly Parallel (or pleasantly parallel) Domain divisible into a large number of independent parts. Minimal or no communication Each processor.
CSE 113 Week 5 February , Announcements  Module 2 due 2/15  Exam 3 is on 2/15  Module 3 due 2/22  Exam 4 is on 2/25  Module 4 due 2/29.
C ENTER FOR I NTEGRATED R ESEARCH C OMPUTING MATLAB
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Examples of loops and nested loops.
CS559-Computer Graphics Copyright Stephen Chenney Image File Formats How big is the image? –All files in some way store width and height How is the image.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 l Array Basics l Arrays in Classes and Methods l Programming with Arrays.
1 CS4402 – Parallel Computing Lecture 7 Parallel Graphics – More Fractals Scheduling.
05/09/2015SJF L31 F21SF Software Engineering Foundations Formatting Converting numbers to Strings and vice versa Monica Farrow EM G30
Digital Image: Representation & Processing (2/2) Lecture-3
Video Mosaics AllisonW. Klein Tyler Grant Adam Finkelstein Michael F. Cohen.
Computer Science 320 Load Balancing for Hybrid SMP/Clusters.
Computer Science 320 Broadcasting. Floyd’s Algorithm on SMP for i = 0 to n – 1 parallel for r = 0 to n – 1 for c = 0 to n – 1 d rc = min(d rc, d ri +
CUDA Performance Considerations (1 of 2) Patrick Cozzi University of Pennsylvania CIS Spring 2012.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
Field Trip #33 Creating and Saving Fractals. Julia Set We consider a complex function, f(z) For each point on the complex plane (x,y), where z = x + iy,
Today’s lecture 2-Dimensional indexing Color Format Thread Synchronization within for- loops Shared Memory Tiling Review example programs Using Printf.
Parallel Algorithms Patrick Cozzi University of Pennsylvania CIS Spring 2012.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
COSC 1P02 Introduction to Computer Science 8.1 Cosc 1P02 “For myself, I am an optimist--it does not seem to be much use being anything else.” Winston Churchill.
Introduction to Image Processing. Image Processing is the steps of using image processing tools to covert different kinds of image sources into different.
GRAPHICS MODULE 14 STUDY BOOK. Graphic commands SCREEN - puts the screen into graphics mode WINDOW - allows scaling of the screen LINE - 3 formats –LINE.
A New Operating Tool for Coding in Lossless Image Compression Radu Rădescu University POLITEHNICA of Bucharest, Faculty of Electronics, Telecommunications.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Images and 2D Graphics COMP # 17.
Computer Science 320 Introduction to Hybrid SMP/Clusters.
Computer Science 320 Reduction. Estimating π Throw N darts, and let C be the number of darts that land within the circle quadrant of a unit circle Then,
Conditionals-part21 Conditionals – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
Computer Science 320 Load Balancing with Clusters.
Hosted by Mr. Bagunolo Function Area Formula Circle, Rectangle, Square What if?
1 ENGI 2420 Structured Programming (Lab Tutorial 8) Memorial University of Newfoundland.
11/10/2016CS150 Introduction to Computer Science 1 Last Time  We covered “for” loops.
Introduction to Images & Graphics JMA260. Objectives Images introduction Photoshop.
Comp 335 File Structures Data Compression. Why Study Data Compression? Conserves storage space Files can be transmitted faster because there are less.
Computer Science 320 Load Balancing. Behavior of Parallel Program Why do 3 threads take longer than two?
Digital Graphics for Computer Games Pixels Types of Digital Graphics (Raster and Vector) Compression.
Computer Science 320 Random Numbers for Parallel Programs.
Computer Science 320 A First Program in Parallel Java.
1 Preparation for site Create a folder in MyDocuments: beavercheese. Create a subfolder, images Classes, career, DW beginner Download.
Embarrassingly Parallel (or pleasantly parallel) Characteristics Domain divisible into a large number of independent parts. Little or no communication.
Computer Science 320 Barrier Actions. 1-D Continuous Cellular Automata 1-D array of cells, each having a value between 0.0 and 1.0 Each cell has a neighborhood.
Computer Science 320 Reduction. Estimating π Throw N darts, and let C be the number of darts that land within the circle quadrant of a unit circle Then,
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 3. Time Complexity Calculations.
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
Information Systems Design and Development Media Types Computing Science.
Computer Graphics Lesson 2 July 12, 2005 Image Formats What are some formats you are familiar with? There are 4 basic image format types: Uncompressed.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae & david streader, VUW Images and 2D Graphics COMP.
Data Storage So far variables have been able to store only one value at a time. What do you do if you have many similar values that all need to be stored?
Practical Session 9 Computer Architecture and Assembly Language.
Images and 2D Graphics COMP
Vocabulary byte - The technical term for 8 bits of data.
Computer Programming Methodology File Input
Chapter III, Desktop Imaging Systems and Issues: Lesson IV Working With Images
Counted Loops.
Representing Images 2.6 – Data Representation.
S.K.H. Bishop Mok Sau Tseng Secondary School
Drawing the Mandelbrot Set
COMS 161 Introduction to Computing
COMS 161 Introduction to Computing
Chapter 7 The Game Loop and Animation
Looping and Repetition
ECE 596 HW 2 Notes.
Presentation transcript:

Computer Science 320 Parallel Image Generation

The Mandelbrot Set

A set of points defined as follows: given a point (x, y), compute a sequence of other points (a i, b i ), i = 0, 1, 2, … a 0 = 0 b 0 = 0 a i+1 = a i 2 – b i 2 + x b i+1 = 2 * a i * b i + y If each point in (a i, b i ) stays finite, (x, y) is in; otherwise, not in

The Mandelbrot Set If each point in (a i, b i ) stays finite, (x, y) is in; otherwise, not in Can’t do an infinite # of points, so if (a i, b i ) ever exceeds a distance of 2 from the origin, it’s not in or: if (a i 2 + b i 2 ) 1/2 > 2 for some i

The Mandelbrot Set or: if (a i 2 + b i 2 ) 1/2 > 2 for some i If we do 1,000 points, if i reaches this limit before the distance exceeds 2, we’ll call the point in, even if further tests might show it to be out

Program Resources Will use the Parallel Java Graphics (PJG) format, which is lossless and larger, but uses faster compression, than PNG format Will generate color values for each point and save these in a PJG file

Program Inputs Image width and height Coordinates of the image center point Image resolution in pixels per unit Maximum number of iterations to test for membership Exponent in formula to calculate pixel hues Output file name

Pixel Matrix, Image File, Hue Table // Create image matrix to store results. matrix = new int [height] [width]; image = new PJGColorImage (height, width, matrix); // Create table of hues for different iteration counts. huetable = new int [maxiter+1]; for (int i = 0; i < maxiter; ++ i){ huetable[i] = HSB.pack(/*hue*/ (float) Math.pow(((double)i) / ((double)maxiter), gamma), /*sat*/ 1.0f, /*bri*/ 1.0f); } huetable[maxiter] = HSB.pack (1.0f, 1.0f, 0.0f);

Optimizing Matrix Access // Compute all rows and columns. for (int r = 0; r < height; ++ r){ int[] matrix_r = matrix[r]; double y = ycenter + (yoffset - r) / resolution; for (int c = 0; c < width; ++ c){ double x = xcenter + (xoffset + c) / resolution; Allows access to a cell with a single index operation

Iterate Until Convergence // Iterate until convergence. int i = 0; double aold = 0.0; double bold = 0.0; double a = 0.0; double b = 0.0; double zmagsqr = 0.0; while (i < maxiter && zmagsqr <= 4.0){ ++ i; a = aold * aold – bold * bold + x; b = 2.0 * aold * bold + y; zmagsqr = a * a + b*b; aold = a; bold = b; } // Record number of iterations for pixel. matrix_r[c] = huetable[i];

Parallelize the Program Each pixel value can be computed independently, so divide the matrix rows among the threads All inputs are shared No per-thread or local variables need synchronization No padding needed

The Parallel for Loop // Compute all rows and columns. new ParallelTeam().execute(new ParallelRegion(){ public void run() throws Exception{ execute (0, height-1, new IntegerForLoop(){ public void run (int first, int last){ for (int r = first; r <= last; ++ r){ int[] matrix_r = matrix[r]; double y = ycenter + (yoffset - r) / resolution;

Behavior of Parallel Program