Presentation is loading. Please wait.

Presentation is loading. Please wait.

COSC 1P02 Intro. to Computer Science 6.1 Cosc 1P02 Week 6 Lecture slides "To succeed, jump as quickly at opportunities as you do at conclusions." --Benjamin.

Similar presentations


Presentation on theme: "COSC 1P02 Intro. to Computer Science 6.1 Cosc 1P02 Week 6 Lecture slides "To succeed, jump as quickly at opportunities as you do at conclusions." --Benjamin."— Presentation transcript:

1 COSC 1P02 Intro. to Computer Science 6.1 Cosc 1P02 Week 6 Lecture slides "To succeed, jump as quickly at opportunities as you do at conclusions." --Benjamin Franklin

2 COSC 1P02 Intro. to Computer Science 6.2 Light  Light is electromagnetic radiation and has properties of both waves and particles  Human perception of light  the visible light spectrum has wavelength of 370-730 nanommeters (nm, 10 -9, 0.00000037-0.00000073 meters)  low acuity  cannot distinguish fine detail  TV screen, monitor, photographs actually contain many dots but we see a clear picture

3 COSC 1P02 Intro. to Computer Science 6.3 Color  Different wavelengths of visible spectrum are sensed as different colors  ROYGBIV  Eyes have 3 sensors that trigger at different wavelengths  425 nm (blue)  550 nm (green)  560 nm (red)  Brain interprets the values registered by the three censors as colour.  each sensor registers something at all wavelengths  highest value for wavelength closest to trigger wavelength  brightness (luminance) handled separately from colour

4 COSC 1P02 Intro. to Computer Science 6.4 Electro Magnetic Spectrum

5 COSC 1P02 Intro. to Computer Science 6.5 Picture Representation  Picture represented by a series of dots (pixels – pi cture el ements)  if small enough eye won’t detect  pictures are two-dimensional  pixels arranged in rows and columns  e.g. monitor resolution (1024x768)  Can trick brain into seeing colour by providing 3 sources of light  e.g. orange light  actual wavelength will cause the brain to get a value for blue, green and red from the sensors  if transmit 3 colours (blue, green, red) in close proximity that trigger the 3 sensors at orange level, will “see” orange  Each pixel is really 3 dots: red, green and blue (RGB)  the amount (intensity) of each colour dot varied to produce the colours  e.g. blue at high intensity and others at low intensity will be seen as blue

6 COSC 1P02 Intro. to Computer Science 6.6 Encoding (Digitizing) Pictures  Picture is a collection of pixels  width & height  Each pixel has three Color values  red (R), green (G) and blue (B)  represent the intensity of the light of that color  1 byte gives 256 different intensities for each color  3 bytes or 2 24 = 16,777,216 different colors  Digital camera  array of sensors (3 per pixel) pick up R, G and B (like eye)  3 values (bytes) recorded per pixel  e.g. 10 megapixel camera  3648 x 2726 = 9,980,928 pixels  at 3 bytes per pixel = 29,942,784 bytes or approximately 28Mb per picture

7 COSC 1P02 Intro. to Computer Science 6.7 Simplest Representation

8 COSC 1P02 Intro. to Computer Science 6.8 Colour Representation

9 COSC 1P02 Intro. to Computer Science 6.9 Exploring Pictures  PictureInspector tool  Java program built using BasicIO & Media libraries  displays picture and allows zooming on a portion  E.g.  beach.jpg  Coordinate system  picture has width & height (in pixels)  top left corner is (0,0)  x-coordinate is column  y-coordinate is row  RGB values

10 COSC 1P02 Intro. to Computer Science 6.10 Picture and PictureDisplayer  Picture  class in Media library  access to attributes and pixels of picture  pictures can be loaded from a file (.jpg )  PictureDisplayer  class in BasicIO library  provides a window on which a picture can be displayed  picture objects placed on PictureDisplayer  E.g. load and display a picture

11 COSC 1P02 Intro. to Computer Science 6.11 Picture Methods

12 COSC 1P02 Intro. to Computer Science 6.12 PictureDisplayer Methods

13 COSC 1P02 Intro. to Computer Science 6.13 Choosing a Color  Set color of each pixel  Sequence through all pixels  Picture is a collection  for-each  ASCIIPrompter to get RGB values  Pixel class  methods to get & set color of pixels  Example  Color constructor allows setting RGB  Black & white  Gray  if R=G=B we get gray  different shades with different intensities

14 COSC 1P02 Intro. to Computer Science 6.14 Pixel Methods

15 COSC 1P02 Intro. to Computer Science 6.15 Grayscale  Convert a picture into grayscale  essentially what we call a black and white picture  shades of gray indicating the luminance of the picture  Gray if R=G=B  set RGB to same value  average of RGB values  Color methods  Example  Note method may change the pixels of the color parameter  they stay changed  just like a method moving a turtle changes its position

16 COSC 1P02 Intro. to Computer Science 6.16 Color Methods

17 COSC 1P02 Intro. to Computer Science 6.17 The end


Download ppt "COSC 1P02 Intro. to Computer Science 6.1 Cosc 1P02 Week 6 Lecture slides "To succeed, jump as quickly at opportunities as you do at conclusions." --Benjamin."

Similar presentations


Ads by Google