Matlab Class 5 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS)

Slides:



Advertisements
Similar presentations
Science Olympiad Optics Color and Shadows.
Advertisements

Photoshop Lab colorspace A quick and easy 26 step process for enhancing your photos.
1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.
EIGHTH GRADE ROBOTICS KITTATINNY REGIONAL HIGH SCHOOL MR. SHEA Introduction to Programming
Civil 114 Civil Engineering Drawing AutoCAD
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphicsIntroduction Dr. Eng. Farag Elnagahy
Introduction to Visual Basic What it is, and a simple program Mike Thelwall University of Wolverhampton, UK.
By D. Fisher Geometric Transformations. Learning Targets I can draw transformations of reflections, rotations, translations and combinations of these.
DIGITAL GRAPHICS & ANIMATION
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® PowerPoint 2010 © 2011 The McGraw-Hill Companies,
Chapter 3 Working with Symbols and Interactivity.
Visual stimulus generation ICN, UCL Session 5, 18 Jan 2007 MATLAB for Cognitive Neuroscience.
Computer Graphics Prepared by Dragon Lee 1 January 2003.
COMP Bitmapped and Vector Graphics Pages Using Qwizdom.
Chapter 5. Loops are common in most programming languages Plus side: Are very fast (in other languages) & easy to understand Negative side: Require a.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Google Sketchup Lab Mr. Garner Tech Ed Lime Kiln MS.
I-1 Steps of Image Generation –Create a model of the objects –Create a model for the illumination of the objects –Create an image (render) the result I.
My First ACCESSIBLE Flash Movie. Course notes Detailed course notes, a printable copy of my slides, and all the samples shown today can be downloaded.
1 Working with Cascading Style Sheet (CSS) (contd.)  What we will cover… 1. Color (decimal and hexadecimal representation) 2. Floating elements 3. Styling.
Chapter 2 Getting Started: Drawing Figures. The Framebuffer Lecture 2 Fri, Aug 29, 2003.
Matlab Class 7 Hristiyan Kourtev & Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS)
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
Objectives Differentiate between raster scan display and random scan display.
Working with Symbols and Interactivity
Introducing Scratch the Cat
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
© 2010 Delmar, Cengage Learning Chapter 3: Working with Symbols and Interactivity.
MA/CS 3751 Fall 2002 Lecture 24. MA/CS 3752 ginput ginput is a Matlab function which takes one argument input: number of points to select in the image.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
© 2011 Delmar, Cengage Learning Chapter 1 Getting to Know Illustrator.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Working with Objects. Objectives Create an object Transform an object Arrange and lock an object Step and repeat an object Use Live Distribute Use the.
Chapter 2: Color and Applets Coming up: Introduction to Graphics.
Graphics. Graphic is the important media used to show the appearance of integrative media applications. According to DBP dictionary, graphics mean drawing.
User Interface Programming in C#: Direct Manipulation Chris North CS 3724: HCI.
Adobe Flash CS4 – Illustrated Unit D: Creating Animation.
Drawing Board. House Plan Electricity Installation.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Introduction to Processing. 2 What is processing? A simple programming environment that was created to make it easier to develop visually oriented applications.
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
Object Oriented Programming Dr. Ennis-Cole CECS 5100.
V part 3.  Different programs have different ways of displaying objects in real-time while the scenes are being created within the workspace. Some.
Data Representation The storage of Text Numbers Graphics.
Color and Blending 03/22/06. RGB  Why?  Monitor  Human vision system  Scale: 0-1, 0-n.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
Microsoft® Small Basic Exploring Shapes Estimated time to complete this lesson: 1 hour.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
Matlab Class 4 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS) and Chris Kourtev.
Introduction To Matlab Class 5 Instructors: Hristiyan (Chris) Kourtev and Xiaotao Su, PhD.
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
CS 104 – Fall 2011 Exploring Computer Science Build Your Own Blocks September 19, 2011.
Adobe Photoshop CS4 – Illustrated Unit A: Getting Started with Photoshop CS4.
CIS 205—Web Design & Development Flash Chapter 3 Working with Symbols and Interactivity.
PowerPoint Vocabulary Tabs 1. Backgrounds: Backgrounds are used in presentations to create a more interesting eye-pleasing look. Backgrounds may include.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Matlab Class 8 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS) and Chris Kourtev.
Chapter 7 Introduction to High-Level Language Programming.
Geometric Transformations
The Psychophysics Toolbox
Matlab Class 2 Xiaotao Su, Ph. D
Example: Card Game Create a class called “Card”
Learning to program with Logo
Basic Graphics Drawing Shapes 1.
Matlab Class 6 Xiaotao Su, Ph. D
CS297 Graphics with Java and OpenGL
Presentation transcript:

Matlab Class 5 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS)

RuCCS Psychtoolbox Basics Computers are perfect for creating and displaying visual psychophysics stimuli Programs usually written in a low-level language (e.g. C or Pascal) to achieve full control of the hardware for precise stimulus display but are difficult to program Interpreted languages like Matlab are abstracted from hardware details and provide friendlier development environments The Psychophysics Toolbox is a software package that allows Matlab to fully control the hardware for precise stimulus display while retaining the flexibility and ease of Matlab.

RuCCS Screen drawing and psychtoolbox Screen Geometry X Positive -> Y Positive Origin Max X and Y Coordinates are measured in pixels.

RuCCS How you typically work with the psychtoolbox Back Buffer (invisible) Front Buffer

RuCCS How you typically work with the psychtoolbox Front Buffer Step 1: Draw Shape to the back buffer

RuCCS How you typically work with the psychtoolbox Step 2: Flip the back buffer to the front buffer

RuCCS How you typically work with the psychtoolbox Back Buffer is automatically cleared

RuCCS How you typically work with the psychtoolbox Now you can continue with your next frame of animation

RuCCS How you typically work with the psychtoolbox Flip the back buffer to the front buffer

RuCCS How you typically work with the psychtoolbox Back Buffer is automatically cleared

RuCCS Basic Display Loop in PsychToolbox (PTB) % Open Window % while some condition is true do the following % draw something % make some changes % repeat % Close screen

RuCCS Set up program draw_stuff % draw_stuff.m % % Draws stuff on the screen

RuCCS Skip Sync Tests Add to your program before opening the new screen Screen('Preference','SkipSyncTests', 1);

RuCCS Initialize the main window % draw_stuff.m % % Draws stuff on the screen clear all; which_screen=0;

RuCCS Set up program draw_stuff % draw_stuff.m % % Draws stuff on the screen clear all; which_screen=0; [window_ptr, screen_dimensions] =Screen(0,'OpenWindow', [0, 0, 0]); 0 is main screen (allows for multiple monitors) Command issued to the psychtoolbox Screen function [red, green, blue] Vector specifying Screen color 0

RuCCS Set up program draw_stuff % draw_stuff.m % % Draws stuff on the screen clear all; which_screen=0; [window_ptr, screen_dimensions]=Screen(0,'OpenWindow', [0, 0, 0]); Vector [x1, y1, x2, y2] Which could be: [0, 0, 800, 600] For an 800 X 600 display x1= 0 y1 = 0 x2= 800 y2 = 600

RuCCS Draw shape in back buffer % draw_stuff.m % % Draws stuff on the screen clear all; which_screen=0; [window_ptr, screen_dimensions]=Screen(0,'OpenWindow', [0, 0, 0]); shape_dimensions = screen_dimensions/2; Screen(window_ptr, 'FillRect', [0,0,255], shape_dimensions); X1, Y1 X2, Y2 Front buffer Back buffer

RuCCS % draw_stuff.m % % Draws stuff on the screen clear all; which_screen=0; [window_ptr, screen_dimensions]=Screen(0,'OpenWindow', [0, 0, 0]); shape_dimensions = screen_dimensions/2; Screen(window_ptr, 'FillRect', [0,0,255], shape_dimensions); %Flip the buffers Screen(window_ptr,'Flip'); Back buffer Flip the back buffer to the front buffer Front buffer

RuCCS Clear screen >>> clear all; which_screen=0; [window_ptr, screen_dimensions]=Screen(0,'OpenWindow', [0, 0, 0]); shape_dimensions = screen_dimensions/2; Screen(window_pointer, 'FillRect', [0,0,255], shape_dimensions); %Copy to main window Screen(window,'Flip'); %leave the image up for 5 seconds WaitSecs(5); %Clear screen and return control to matlab clear screen;

RuCCS Task 1: Making a movie % draw_stuff.m % % Draws stuff on the screen clear all; which_screen=0; [window_ptr, screen_dimensions] …=Screen(0,'OpenWindow', [0, 0, 0]); shape_dimensions = screen_dimensions/2; Screen(window_pointer, 'FillRect', … [0,0,255], shape_dimensions); % then loop and increment screen_dimensions at each turn

RuCCS Task 1: Basic Display Loop in PTB (code) % draw_stuff.m % % Draws stuff on the screen clear all; try which_screen=0; bg_color = [0, 0, 0]; [window_ptr, screen_dimensions]= … Screen(which_screen, … 'OpenWindow',bg_color); shape_dimensions = … screen_dimensions/2; tic; while (toc < 5) % move shape shape_dimensions = … shape_dimensions + [0,5,0,5]; % draw shape Screen(window_ptr, 'FillRect', … [0,0,255], shape_dimensions); % flip buffer and repeat Screen(‘Flip’, window_ptr); end clear Screen; catch clear Screen; end

RuCCS Moving Shapes around the Screen Shapes are defined by an array of numbers e.g. sh1 = [10, 15, 40, 45] ; % [x1, y1, x2, y2] To move a shape in the x direction by 5 pixels we need to increment both x coordinates by 5 e.g. sh1(1) = sh1(1) +5; sh1(3) = sh1(3) +5 or use another array: sh1 = sh1 + [5, 0, 5, 0]; Same for moving in the y direction Increment both if you want to move diagonally

RuCCS Task 2 Make the rectangle move to the bottom of the screen at 5 pixels per frame, then move right when it hits the bottom. When it hits the right, the program ends Hint: shape_dimensions(1) is x1, (2) is y1, (3) is x2, 4 is y2

RuCCS Task 3 When the rectangle hits the bottom make it change colors to red Hint: color is a 3 number vector red is [255, 0, 0]