computer graphics in java cr325. what is computer graphics? a kind of data processing voice and...

37
Computer Graphics in Java CR325

Upload: violet-lamb

Post on 31-Dec-2015

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Computer Graphics in Java

CR325

Page 2: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

What is Computer Graphics?

• A kind of Data processing

• Voice and Signal Processing = 1D data processing

• Image Processing = 2D data processing

• Computer Graphics = 3D data in with 2D data out. Geometry is transformed into images.

Page 3: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

What is Computer Animation?

• Like Computer Graphics with a difference.

• Animation=movement. This is simulated with image sequences. Output is an image sequence. Input is 3D geometry.

Page 4: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Why study Computer Graphics?

• Entertainment

• Visualization of data (analysis)

• Simulation can be visualized with CG.

• CAD (Computer Aided Design)

Page 5: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

What do people study in CG?

• How to do 2D drawing– How to draw a line– How to draw a circle, etc.

• How to do 3D drawing– How to draw a 3D line– How to draw a sphere, etc.

Page 6: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Where do we get input?

• Pick device– Gives us a location– Mouse, light-pen, arrow-keys, keyboard,– Joystick, tablet, scanner, image– video camera with a cooperative target.– Geometries– Dynamics, kinematics (math).

Page 7: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Introduction to 2D Graphics

• Draw some 2D geometries.

• Input is 2D geometry

• Ouput is image.

Page 8: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

How do we represent an image?

• Image Processing answer: 2D array of pixels

• Computer Answer: BREP:vectors

• to the right is a bitmap• vector vs. bitmap

Page 9: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

What is an image?

• A 2D array of PIXELS.

Page 10: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

What is a PIXEL

• A picture element.

• Typically a pixel can be described as an intensity for light at a given location.– Location (200,20), I = 255; // gray scale– Location (34,50), R=255, G= 0, B =0; //red

pixel.

• Looks like a dot!

Page 11: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

What is an Image?

• a 2D array of pixels

• a pixel is a scalar quantity that represents the intensity of light. It smallest area within the given image.

Page 12: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

How do we represent a pixel?

• how do we represent light?

Page 13: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Trading an eye for an ear

optical axiscornea

lensoptic disk

optic nerve

retina

fovea centralis

iris

Page 14: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Spectra of the Human Visual System

• ranges from 400 nm wavelength to about 800 nm, 1 nm = 10 ** -9 meters

• d = rate * time

• rate = c = 3 * 10 ** 8 meters / second

• d = wavelength = 400 * 10 **-9 meters

• T = lambda/c, f = 1/T = c / lambda

• f = 3 * 10 ^ 8 / 4 * 10 ^ -7 =750.*10^12?

Page 15: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

An eye is a Multi-mega pixel camera

• It has a lens (adjustable zoom)

• It has an automatic f-stop (iris 2-8 mm)

• It has a sensor plane (100 million pixels)

• The sensor has a transfer function senstive to mesopic range; 380 to about 700 nm

Page 16: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

The eyes have a USB2 data rate!

• 250,000 neurons in the optic nerve

• variable voltage output on EACH nerve

• 17.5 million neural samples per second

• 12.8 bits per sample

• 224 Mbps, per eye (a 1/2 G bps system!).

• Compression using lateral inhibition between the retinal neurons

Page 17: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Response curves

• Eye has Gaussian response to light.

• Gives rise to biologically motivated image processing

Page 18: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Quantization of an Image

• Computers use digital cameras -> quantization

SNR6b 4.8

SNR 10 log 3 22 b 20b log2 10log 3

Page 19: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Quantization Error is visible

Page 20: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Displays

• Color Monitors are made for people

• physiological arguments are used for display design

Page 21: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

What is light?

• any electromagnetic energy

• visible light is typically visible to the human visual system (eye).

Page 22: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

How do we represent a pixel

• assume that the pixel is for humans.

• You need to know the dynamic range of the eye!

• 1 part in a million is needed for a pixel that displays on a monitor for people.

• Typically we use 24 bits per pixel, 8 bits per color.

Page 23: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

peter packed a pickled pixelits color was that of hash.

And every system that displayed it would crash!

Page 24: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Displays are designed for

• human visual system (eye)

• Painting with LIGHT (additive synthesis) display

• This is not painting with MUD! (subtractive synthesis) printer

Page 25: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Overview

public int filterRGB (int rgb) { int r = (rgb & 0xff0000) >>16; int g = (rgb & 0xff00) >> 8; int b = rgb & 0xff; int gr = (r + g + b) / 3;int p = 0xff000000 | (gr << 16) | (gr << 8) | gr; return p// p = 0xffgrgrgr;

Page 26: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

How would do you pack RGB?

• int pack(int r, int g, int b) {return 0xff000000 | (r << 16) | (g << 8) | b;• }

Page 27: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

How do I represent the following in decimal

• int I = 1;

• int k = ~I+1;

• how much is k? Ans: -1

Page 28: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Intro to bitwise ops

• and - & - bitwise (not && is logical)

• or - | - bitwise (not || is logical)

• not - ~ - bitwise (not !, is logical)

• xor - ^ - bitwise (has no logical correspondence)

Page 29: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Intro to ANDing

• int I = 0;

• int j = 1;

• I&I is 0

• I&J is 0

• J&I is 0

• J&J is 1

Page 30: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Intro to Oring

• int i=0xF0; S={0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f}• int j =0x0F;• i|I is 240 = 0xF0• i|j is 255 in decimal = 0xFF• 0xF0 = (in base 2) 11110000• 0x0F = (in base 2) 00001111• 0x0F | 0xF0 = 11111111

Page 31: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Using hex for ANDing

• int i=0x7a;

• int j =0x0F;

• how much is i&j ?

• 01111100 &

• 00001111 =

• 00001100 = 0x0c

Page 32: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

using hex for not

• int i=0x7a;

• int j =0x0F;

• how much is ~j?

0xfffffff0

nibble is 4 bits, byte is 8 bits

Page 33: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

using hex for xor

• int i=0x7a;

• int j =0x0F;

• how much is i^j?

• 01111100 = I^

• 00001111 = j

• 01110011 = i^j = 0x73

Page 34: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Common Radicies

• in java, you can use:

• binary (base 2) Radix 2

• octal (base 8) Radix 8

• decimal (base 10) Radix 10

• hexidecimal (base 16) Radix 16

Page 35: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

How come they call it base 2?

• You can only have 0 and 1, so why call it base 2?

• Why not call it base 1?

• Cardinality of the set of symbols is the radix S = {0, 1}, card(s)=2

Page 36: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Why call it a base?

• The base of the exponent!

• 1101, base 2 is, in decimal

• 1*2^3 + 1 * 2^2 + 0 * 2 ^ 1 + 1

• = 8 + 4 + 0 + 1 = 13 base 10.

• This is called positional notation.

Page 37: Computer Graphics in Java CR325. What is Computer Graphics? A kind of Data processing Voice and Signal Processing = 1D data processing Image Processing

Doing the positional notation in hex

• 0x28 = 2 * 16 ^ 1 + 8 * 16 ^ 0

• = 2 * 16 + 8

• = 32 + 8 = 40 base 10