Creative Commons Attribution Non-Commercial Share Alike License

Slides:



Advertisements
Similar presentations
Overloading Having more than one method with the same name is known as overloading. Overloading is legal in Java as long as each version takes different.
Advertisements

Selection Feature of C: Decision making statements: It allow us to take decisions as to which code is to be executed next. Since these statements control.
Control Structures.
FORTRAN PROGRAMMING BASICS (2) MET 50. Programming Basics A few extra things from last week… 1. For a program written in Fortran 90, use the extension.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Vladimir Misic: Scope and Lifetime1 Scope And Lifetime Material Borrowed from Nan Schaller.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Java: Chapter 1 Computer Systems Computer Programming II.
NestedLoops-part11 Nested Loops – part 1 Barb Ericson Georgia Institute of Technology Nov 2009.
Chapter 5 Creating an Image Map.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CSC1401 Viewing a picture as a 2D image - 1. Review from the last week We used a getPixels() to get all of the pixels of a picture But this has been somewhat.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
February ,  2/16: Exam 1 Makeup Papers Available  2/20: Exam 2 Review Sheet Available in Lecture  2/27: Lab 2 due by 11:59:59pm  3/2:
Lecture 71 CS110 Lecture 8 February 19, 2004 Announcements –hw3 due tonight –hw4 available, due Thursday February 26 –exam Tuesday March 2 Agenda –questions.
CSC1401 Using Decisions in Java - 1. Recall from Alice We only wanted to shoot a lightning bolt at a philosopher So, we used the If statement.
Conditionals-part21 Conditionals – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
TOPIC 10 THE IF STATEMENT 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Georgia Institute of Technology Conditionals – part 2 Barb Ericson Georgia Institute of Technology August 2005.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Continuous. Flow of Control Programs can broadly be classified as being –Procedural Programs are executed once in the order specified by the code varied.
Conditionals-Mod8-part21 Conditionals – part 2 Edge Detection Barb Ericson Georgia Institute of Technology May 2007.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Today in CS161 Lecture #7 Learn about… If and else statements Rewrite our First Program Using if and else statements Create new Graphics Demos Using if.
SCIENCE INTERACTIVE NOTEBOOK
SCIENCE INTERACTIVE NOTEBOOK
Recap: If, elif, else If <True condition>:
Creative Commons Attribution Non-Commercial Share Alike License
Selection (also known as Branching) Jumail Bin Taliba by
Georgia Institute of Technology
Topic 10 The if statement Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
Barb Ericson Georgia Institute of Technology August 2005
CS 106A, Lecture 6 Control Flow and Parameters
SCIENCE INTERACTIVE NOTEBOOK
Conditions and Ifs BIS1523 – Lecture 8.
How to Create an Interactive Science Notebook (ISN)
Georgia Institute of Technology
Workshop for Programming And Systems Management Teachers
CSE 8A Lecture 6 Reading for next class:
INTERACTIVE SCIENCE NOTEBOOK
Bell work – 5 minutes Read the entire bubble gum lab.
Defining methods and more arrays
INTERACTIVE SCIENCE NOTEBOOKS
Your key to success in 5th grade Science
CS139 October 11, 2004.
Selection Statements.
SCIENCE INTERACTIVE NOTEBOOK
INTERACTIVE SCIENCE NOTEBOOK
Building Java Programs
Week 4 Lecture-2 Chapter 6 (Methods).
Creative Commons Attribution Non-Commercial Share Alike License
IPC144 Introduction to Programming Using C Week 4 – Lesson 1
Creative Commons Attribution Non-Commercial Share Alike License
Program Flow.
INTERACTIVE SCIENCE NOTEBOOK
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
CSC1401 Manipulating Pictures 2
Agenda for Unit 5: Control Structures
Arrays Introduction to Arrays Reading for this Lecture:
Presentation transcript:

Creative Commons Attribution Non-Commercial Share Alike License Original Developer: Beth Simon, 2009 bsimon@cs.ucsd.edu

THIS LECTURE GOT WRITTEN OVER! Re develop from older ones – there were some new slides in Fa 2009, so get those from UP.

CSE8A Lecture 15 Read next class: read pg 197-202 Quizzes pick up

About group quizzes and learning Group quizzes are great, I really learn a lot Group quizzes are good, it helps me solidify my learning to discuss the questions with others Group quizzes are OK, I’m not sure how much I learn by doing them Group quizzes are not helpful to my learning at all.

By the end of today’s class you should be able to… LG30: Write and read code that either loops over a subset of pixels or loops over all pixels and controls changes to pixels with and if statement LG31: Use parameters to control looping in conditional setting of pixels LG32: Identify the flow of control in the three types of Java if statements: if, if-else, and if-else if-else LG34: Compare and contrast two solutions to a problem using for loops and if statements

Changing pixels all over, conditionally //Inside loop over all pixels topP = this.getPixel(x,y); botP = this.getPixel(x,y+1); topAvg = topP.getAverage(); botAvg = botP.getAverage(); if (Math.abs(topAv – botAv) < 10) topP.setColor(Color.WHITE); else topP.setColor(Color.BLACK); What is it doing? Comparing 2 pixels side by side and, if they are similar make the pixel white, otherwise black Comparing 2 pixels one on top of the other and, if they are similar make the pixel white, otherwise black Comparing 2 pixels side by side and, if they are different make the pixel white, otherwise black Comparing 2 pixels one on top of the other and, if they are different make the pixel white, otherwise black

What’s the result of running that code on this input?

A DIFFERENT edgeDetect //Inside loop over all pixels topP = this.getPixel(x,y); botP = this.getPixel(x+1,y); // was (x,y+1) topAvg = topP.getAverage(); botAvg = botP.getAverage(); if (Math.abs(topAv – botAv) < 10) topP.setColor(Color.WHITE); else topP.setColor(Color.BLACK);

A DIFFERENT edgeDetect //Inside loop over all pixels topP = this.getPixel(x,y); botP = this.getPixel(x+1,y); // was (x,y+1) topAvg = topP.getAverage(); botAvg = botP.getAverage(); if (Math.abs(topAv – botAv) < 10) topP.setColor(Color.WHITE); else topP.setColor(Color.BLACK);

Which is most true about ONE execution of this code (for a specific diffValue) int diffValue = Math.abs(topAv – botAv); if (diffValue < 10) topP.setColor(Color.WHITE); else topP.setColor(Color.BLACK); Section A AND Section B may BOTH be executed If Section B is executed then Section A is not executed Neither Section is ever executed It is possible neither Section will be executed (but sometimes one might be).

Which is most true about ONE execution of this code (for a specific diffValue) int diffValue = Math.abs(topAv – botAv); if (diffValue < 10) topP.setColor(Color.WHITE); else if (diffValue < 50) topP.setColor(Color.GREY); else topP.setColor(Color.BLACK); Section A can be executed AND Section B may BOTH be executed but then C can’t be executed If Section A is executed then neither Section B nor C can be All sections can be executed for a single diffValue It’s possible no section is executed for a given diffValue Confused? See page 187 for execution flow diagram

In Lab 5: Which best describes the conditions under which we change pixel color? public void makeConvict() { for (int x = 0; x < this.getWidth(); x++) for (int y = 0; y < this.getHeight(); y++) Pixel currentPix = this.getPixel(x,y); if ( (currentPix.getGreen() > 200) && (y%2==0)) currentPix.setColor(Color.BLACK); } else if( (currentPix.getGreen() > 200) && y%2 == 1) currentPix.setColor(Color.WHITE); Based on the coordinates of the Pixel Based on the color of the Pixel Based on the coordinates for some Pixels, the color for other Pixels Based on a compound condition of color and coordinates of the Pixel