CSE1710. Big Picture. Reminder

Similar documents
CSE1710. Big Picture. Reminder

Brief Introduction to Vision and Images

Digital Image Processing. Lecture # 8 Color Processing

Color & Graphics. Color & Vision. The complete display system is: We'll talk about: Model Frame Buffer Screen Eye Brain

Digital Image Processing. Lecture # 6 Corner Detection & Color Processing

Multimedia Systems Color Space Mahdi Amiri March 2012 Sharif University of Technology

Images and Colour COSC342. Lecture 2 2 March 2015

Mahdi Amiri. March Sharif University of Technology

Interactive Computer Graphics

INSTITUTIONEN FÖR SYSTEMTEKNIK LULEÅ TEKNISKA UNIVERSITET

Image and video processing (EBU723U) Colour Images. Dr. Yi-Zhe Song

Visual Perception. human perception display devices. CS Visual Perception

Visual Perception. Jeff Avery

Color Image Processing

Image Perception & 2D Images

Bettina Selig. Centre for Image Analysis. Swedish University of Agricultural Sciences Uppsala University

Capturing Light in man and machine

Figure 1: Energy Distributions for light

Introduction & Colour

Human Vision, Color and Basic Image Processing

Capturing Light in man and machine

Capturing Light in man and machine

Computer Graphics: Graphics Output Primitives Primitives Attributes

Colors in Images & Video

IMAGE PROCESSING >COLOR SPACES UTRECHT UNIVERSITY RONALD POPPE

LECTURE 07 COLORS IN IMAGES & VIDEO

Prof. Feng Liu. Winter /09/2017

Image Processing for Mechatronics Engineering For senior undergraduate students Academic Year 2017/2018, Winter Semester

Sampling and Reconstruction. Today: Color Theory. Color Theory COMP575

4/9/2015. Simple Graphics and Image Processing. Simple Graphics. Overview of Turtle Graphics (continued) Overview of Turtle Graphics

Oversubscription. Sorry, not fixed yet. We ll let you know as soon as we can.

Colour. Cunliffe & Elliott, Chapter 8 Chapman & Chapman, Digital Multimedia, Chapter 5. Autumn 2016 University of Stirling

Graphics and Image Processing Basics

Colour. Why/How do we perceive colours? Electromagnetic Spectrum (1: visible is very small part 2: not all colours are present in the rainbow!

The human visual system

Colour. Electromagnetic Spectrum (1: visible is very small part 2: not all colours are present in the rainbow!) Colour Lecture!

DESIGN & DEVELOPMENT OF COLOR MATCHING ALGORITHM FOR IMAGE RETRIEVAL USING HISTOGRAM AND SEGMENTATION TECHNIQUES

IMAGES AND COLOR. N. C. State University. CSC557 Multimedia Computing and Networking. Fall Lecture # 10

CS 565 Computer Vision. Nazar Khan PUCIT Lecture 4: Colour

Colors in images. Color spaces, perception, mixing, printing, manipulating...

Review of concepts. What is a variable? Storage space to keep data used in our programs Variables have a name And also a type Example:

Color Image Processing

Exercise NMCGJ: Image Processing

Unit 8: Color Image Processing

Waitlist. We ll let you know as soon as we can. Biggest issue is TAs

Image Processing. Michael Kazhdan ( /657) HB Ch FvDFH Ch. 13.1

Chapter 3 Part 2 Color image processing

For a long time I limited myself to one color as a form of discipline. Pablo Picasso. Color Image Processing

Digital Image Processing Color Models &Processing

2. Color spaces Introduction The RGB color space

Lecture 8. Color Image Processing

COLOR and the human response to light

DIGITAL IMAGE PROCESSING (COM-3371) Week 2 - January 14, 2002

III: Vision. Objectives:

Digital Image Processing (DIP)

Additive Color Synthesis

Computer Graphics. Si Lu. Fall er_graphics.htm 10/02/2015

Achim J. Lilienthal Mobile Robotics and Olfaction Lab, AASS, Örebro University

Computers and Imaging

Color images C1 C2 C3

CS 544 Human Abilities

Digital Image Processing

USE OF COLOR IN REMOTE SENSING

Image Representation using RGB Color Space

Color Perception and Applications. Penny Rheingans University of Maryland Baltimore County. Overview

Technology and digital images

TOPIC 4 INTRODUCTION TO MEDIA COMPUTATION: DIGITAL PICTURES

Astronomy and Image Processing. Many thanks to Professor Kate Whitaker in the physics department for her help

Lecture 3: Grey and Color Image Processing

Segmentation using Saturation Thresholding and its Application in Content-Based Retrieval of Images

Human Visual System. Digital Image Processing. Digital Image Fundamentals. Structure Of The Human Eye. Blind-Spot Experiment.

Digital Image Processing

Color and perception Christian Miller CS Fall 2011

Wireless Communication

Colour (1) Graphics 2

Visual Perception. Overview. The Eye. Information Processing by Human Observer

Today. Color. Color and light. Color and light. Electromagnetic spectrum 2/7/2011. CS376 Lecture 6: Color 1. What is color?

Retina. last updated: 23 rd Jan, c Michael Langer

Introduction. The Spectral Basis for Color

University of British Columbia CPSC 414 Computer Graphics

COLOR. and the human response to light

Announcements. Color. Last time. Today: Color. Color and light. Review questions

Color Image Processing. Gonzales & Woods: Chapter 6

Images. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 38

Capturing Light in man and machine

Introduction to computer vision. Image Color Conversion. CIE Chromaticity Diagram and Color Gamut. Color Models

Vision. The eye. Image formation. Eye defects & corrective lenses. Visual acuity. Colour vision. Lecture 3.5

Retina. Convergence. Early visual processing: retina & LGN. Visual Photoreptors: rods and cones. Visual Photoreptors: rods and cones.

SCD-0017 Firegrab Documentation

Capturing Light in man and machine

Prof. Feng Liu. Fall /02/2018

Digital Image Processing

In order to manage and correct color photos, you need to understand a few

CSCE 763: Digital Image Processing

Digital Image Fundamentals. Digital Image Processing. Human Visual System. Contents. Structure Of The Human Eye (cont.) Structure Of The Human Eye

Digital Image Fundamentals. Digital Image Processing. Human Visual System. Contents. Structure Of The Human Eye (cont.) Structure Of The Human Eye

Introduction to Multimedia Computing

VC 16/17 TP4 Colour and Noise

Digital Image Processing

Overview of Human Cognition and its Impact on User Interface Design (Part 2)

Transcription:

CSE1710 Click to edit Master Week text 09, styles Lecture 17 Second level Third level Fourth level Fifth level Fall 2013! Thursday, Nov 6, 2014 1 Big Picture For the next three class meetings, we will be covering Chapter 5 of the textbook. We will be using images to demonstrate the concepts of iterative and selection. Reminder On Thurs Nov 20/Fri Nov 21, we will have out final labtest. 2 1

Images Take good notes there is relatively little material in the textbook; most of the material will be provided in lecture 3 To work with images, we need to: 1. work with the file system 2. work with the operating system s window manager and the platform s graphics hardware 3. understand colour models and image representation formats 4. understand the services of the RasterImage and the Pixel classes 5. iterate and construct conditions 4 4 2

A Code Segment, deconstructed VS 5 File pathnames are system dependent The file separator can be abstracted away as File.separator! Windows Local File System (LFS):! C:\USER\DOCS\LETTER.TXT!! Windows Uniform Naming Convention (UNC)! \\Server\Volume\File!! Unix-like OS! /home/user/docs/letter.txt! 6 6 3

The RasterImage class! provides services to create and to manipulate raster images 7 7 The RasterImage class a little more info! attributes are:! filename : String (might be null)! filenameextension : String (might be null)! title : String! width : int! height : int! a collection of pixels which are arranged in a rectangular grid! 8 8 4

A rectangular grid of pixels pixel a single point at a given coordinate that has specific colour attributes 9 9 A rectangular grid of pixels 10 10 5

A rectangular grid of pixels 11 11 A rectangular grid of pixels 12 12 6

A rectangular grid of pixels when the grid becomes large enough and the pixels become small enough, the human eye ceases to see the individual pixels the exact threshold for this is complicated and depends on angular displacement of the eye within the visual field 13 13 A rectangular grid of pixels pixel 14 14 7

The Rectangular Grid of Pixels! each element has a (x,y) coordinate! the convention is that (0,0) is in the upper left hand corner! the x part of coordinate indicates the column! the y part of the coordinate indicates the row! in the door and down the stairs 15 15 The Rectangular Grid of Pixels! the RasterImage class provides services to! get all of the pixels from an instance of a RasterImage! get a specific pixel from an instance of a RasterImage 16 16 8

What is a Pixel? A Pixel object encapsulates several attributes: the raster image to which it belongs its x and y location within its parent picture its colour Of these three attributes only one attribute is mutable*: the pixel s colour. the pixel s (x,y) coordinate within its parent image cannot be changed; they are immutable! 17 *mutable means able to be changed! Services for a Pixel! once we have a pixel, what can we do with it?! we can query its state! we can modify its state! both of these things concern the representation of colour 18 18 9

Pixels: How to mutate Suppose the variable p is an object reference, and refers to a Pixel object. So the only attribute I can change in a Pixel object is its colour. here are some examples: p.setcolor( ); this must be a reference to a Color object! 1. use a predefined color! 2. construct one from scratch! 3. use a reference from somewhere else (e.g., another pixel)! 19 Pixels: How to mutate p.setcolor( ); this must be a reference to a Color object! look at the API for the Color class! 1. use a predefined color! 2. construct one from scratch! 3. use a reference from somewhere else (e.g., another pixel)! There are many pre-defined colors: Color.RED Color.MAGENTA Color.BLACK Color.black 20 10

Pixels: How to mutate p.setcolor( ); this must be a reference to a Color object! 1. use a predefined color! Here is a constructor: new Color(255, 0, 0) 2. construct one from scratch! 3. use a reference from somewhere else (e.g., another pixel)! 21 Pixels: How to mutate p.setcolor( ); this must be a reference to a Color object! 1. use a predefined color! 2. construct one from scratch! 3. use a reference from somewhere else (e.g., another pixel)! look at the API for the Pixel class to see the accessor method for an object s color attribute! r.getcolor() 22 11

A Crash Course in Colour Perception and Colour Models! Two Color Models: RGB and HSV! The RGB model is much more intuitive than HSV! We ll first explain RGB, then show the mapping into HSV space! First, we will discuss the basics of colour perception 23 23 The Retina! the retina of the human eye is packed with photoreceptors! the photoreceptors receive light stimulus via the lens of the eye 24 24 12

The Retina! there are two types of photoreceptors in the retina!! rods : specialized for sensitivity! lower threshold, more sensitive than cones! provide sensing that something happened, but not specialized to colour! cones : specialized for colour and acuity! come in three types! short-wavelength! medium-wavelength! long-wavelength 25 25 The Retina! the fovea is a specialty region of the retina, more or less in the centre of the retina! rods: none! cones: completely and tightly packed! specialized for acute detailed vision! towards the periphery of retina! rods: more! cones: fewer! the proportion of rods to cones increase toward edge of retina! 26 26 13

Hue Hue corresponds to what we typically refer to as colour. It is determined by the light s wavelength Blue perceived by short-wavelength cones Green perceived by medium-wavelength cones Red perceived by long-wavelength cones 27 27 Colour is complicated! perception based on 2 types of receptors (hue and intensity)! our brain does more seeing than our eyes! what we call colour is more accurately described as hue and brightness 28 28 14

A Key Fact! the combination of red, blue and green together is indistinguishable from white to the human eye! this is exploited by computer displays 29 29 Pixels and Subpixels! Many displays have a cluster of R, G, B sub-pixels for each pixel! max intensity for R, G, B = seen as white! min intensity for R, G, B = seen as black! and other saturated colours 30 30 15

RGB Colour Space white cyan green yellow magenta blue red black 31 31 Color Red Green Blue Red 255 0 0 Green 0 255 0 Blue 0 0 255 Yellow 255 255 0 Cyan 0 255 255 Magenta 255 0 255 White 255 255 255 Black 0 0 0 32 32 16

Other cases! if the RGB intensities are all the same! this gets perceived as shade of grey! if the RGB intensities are different! then perception depends on relative difference between strongest and weakest intensities! Bottom line: Given a colour out in the world, it can be very difficult to determine its corresponding RGB values 33 33 Hue-Saturation-Value (HSV) Model! Each of hue, saturation, and brightness individually specified! similarities to the way humans perceive and describe colour! Given a colour out in the world, it is often easier to determine its corresponding HSV values than its RGB values 34 34 17

Small digression:! End of digression. back to regular programming 35 35 Let s talk about two forms of iteration!! one form: built upon a boolean condition! another form: built around a collection! 36 36 18

The Collection Form of Iteration!! a collection is simply a bunch of elements, possibly in a particular order, but not necessarily! the elements must have a type (e.g., Pixel)! there are certain sub categories for collections! a set is a collection in which duplicates are not permitted! a list is a collection in which the elements are ordered! an array is a specific kind of list collection, set, list : abstractions, not specific to Java array : a Java programming element 37 37 The Collection Form of Iteration!! for ( Type-of-Element e : Identifier-of-Collection ) { // here is the body of the loop } } This is called an enhanced for loop 38 38 19

The Collection Form of Iteration! It just so happens that a RasterImage object can function as a collection of Pixel elements for (Pixel p : myimage) { } // here is the body of the loop 39 39 The Condition Form of Iteration! for (; boolean expression ;) { } // here is the body of the loop 40 40 20

The Condition Form of Iteration! for ( initial ; boolean expression ; bottom ) { } // here is the body of the loop 41 41 Iterating over all of the pixels (v.2) The second version of this involves iterating over a set of indices and using an index-based accessor method to obtain a reference to each and every pixel! There are two ways to do this: by index in the array of pixels and by row and column index. First by index in the array of pixels 42 21

A Crash Course in Arrays Pixel[] thepixels = mypict.getpixelarray(); int firstpixelindex = 0; int lastpixelindex = thepixels.length-1; thepixels[60].getcolor(); this retrieves the 61 tst element in the array! thepixels[lastpixelindex].getcolor(); // the final //element thepixels[0].getcolor(); // the first element length is a special final attribute of arrays in Java! WHY minus 1?! 43 A Crash Course in Arrays Pixel[] thepixels = mypict.getpixelarray(); int firstpixelindex = 0; int lastpixelindex = thepixels.length-1; thepixels[lastpixelindex+1].getcolor(); // runtime error thepixels[-1].getcolor(); // runtime error 44 22

Iterating over all of the pixels (v.2) the array of pixels Pixel[] thepixels = mypict.getpixels(); // this sets the color of the first pixel thepixels[firstpixelindex].setcolor(color.red); // this sets the color of the second pixel thepixels[firstpixelindex+1].setcolor(color.red); // // this sets the color of the second-last pixel thepixels[lastpixelindex-1].setcolor(color.red); // this sets the color of the last pixel thepixels[lastpixelindex].setcolor(color.red); so how could we automate this? 45 Iterating over all of the pixels (v.2) Pixel[] thepixels = mypict.getpixels(); int firstpixelindex = 0; int lastpixelindex = thepixels.length-1; int currentindex = firstpixelindex; boolean iswithinbounds = currentindex <= lastpixelindex; for( ; iswithinbounds ; ) { Pixel currentpixel = thepixels[currentindex]; currentpixel.setcolor(color.red); mypict.repaint(); currentindex++ iswithinbounds = currentindex <= lastpixelindex; } 46 23

Iterating over all of the pixels (v.2) Pixel[] thepixels = mypict.getpixels(); int firstpixelindex = 0; int lastpixelindex = thepixels.length-1; int currentindex = firstpixelindex; for( ; currentindex <= lastpixelindex; ) { Pixel currentpixel = thepixels[currentindex]; currentpixel.setcolor(color.red); mypict.repaint(); currentindex++ } 47 Iterating over all of the pixels (v.2) Pixel[] thepixels = mypict.getpixels(); int firstpixelindex = 0; int lastpixelindex = thepixels.length-1; for(int currentindex = firstpixelindex; currentindex <= lastpixelindex; ) { Pixel currentpixel = thepixels[currentindex]; currentpixel.setcolor(color.red); mypict.repaint(); currentindex++ } 48 24

Iterating over all of the pixels (v.2) Pixel[] thepixels = mypict.getpixels(); int firstpixelindex = 0; int lastpixelindex = thepixels.length-1; for(int currentindex = firstpixelindex; currentindex <= lastpixelindex;currentindex++) { Pixel currentpixel = thepixels[currentindex]; currentpixel.setcolor(color.red); mypict.repaint(); } 49 5.2.1 Flow of Control! I t e r a t i o n loop body S B 1 B 2 X 50 Copyright 25

5.2.2 The for statement! Flow: Syntax : false { } 51 Copyright S for X initial condition { body } bottom condition true Statement -S for (initial; condition; b ottom) { body; } Statement -X Algorithm: 1. Start the for scope 2. Execute initial 3. If condition is false go to 9 4. Start the body scope { 5. Execute the body 6. End the body scope } 7. Execute bottom 8. If condition is true go to 4 9. End the for scope Example! final int MAX = 10; final double SQUARE_ROOT = 0.5; for (int i = 0; i < MAX; i = i + 1) { double sqrt = Math.pow(i, SQUARE_ROOT); output.print(i); output.print(\t); // tab output.println(sqrt); } 52 Copyright 26

for (initial; condition; bottom)! for (int i = 0; i < MAX; i = i + 1) {... } int i; for (; i < MAX; i = i + 1) {... } 53 Copyright for (initial; condition; bottom)! Can it be omitted?! Can it be set to the literal true?! What if it were false at the beginning?! Is it monitored throughout the body?! 54 Copyright 27

for (initial; condition; bottom)! Can it be any statement?! Will the loop be infinite if it is omitted?! 55 28