Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/http://creativecommons.org/licenses/by-nc-

Slides:



Advertisements
Similar presentations
Pass by Value. COMP104 Pass by Value / Slide 2 Passing Parameters by Value * A function returns a single result (assuming the function is not a void function)
Advertisements

RAPTOR Syntax and Semantics By Lt Col Schorsch
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
James Tam Programming: Part II In this section of notes you will learn about more advanced programming concepts such as looping, functions.
Conditionals-part11 Barb Ericson Georgia Institute of Technology Nov 2009.
Games and Simulations O-O Programming in Java The Walker School
TOPIC 9 MODIFYING PIXELS IN A MATRIX: COPYING, CROPPING 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
CSE 8A Lecture 8 Reading for next class: None Prepare for In-term exam 2 PSA4: Collage and Picture Flip, DON’T WAIT (it’s longer than the previous PSAs)
NestedLoops-part31 Nested Loops – part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Java: Chapter 1 Computer Systems Computer Programming II.
TOPIC 7 MODIFYING PIXELS IN A MATRIX NESTED FOR LOOPS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by.
NestedLoops-part11 Nested Loops – part 1 Barb Ericson Georgia Institute of Technology Nov 2009.
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/
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 11 Fall 2010.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CPS120: Introduction to Computer Science Lecture 14 Functions.
TOPIC 11 RETURNING VALUES FROM METHODS PICTURE TRANSFORMATIONS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
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/
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CPSC1301 Computer Science 1 Chapter 4 Manipulating Pictures, Arrays, and Loops part 5.
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.
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/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CSE 8A Lecture 13 Reading for next class: Chapter 9 Today’s topics: –Sounds! Finish PSA 6: Chromakey! DUE TUESDAY Interm exam 3 next Thursday.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CSE8A Lecture 5 TODO: –FINISH PSA2 WITH YOUR PARTNER! Read next class: Section 5.1. PLAY WITH CODE! –Get stuck, then figure out how to get unstuck – it’s.
04-ManipulatingPictures-part21 Manipulating Pictures, Arrays, and Loops part 2 Barb Ericson Georgia Institute of Technology June 2008.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Georgia Institute of Technology Two-Dimensional Arrays and Nested Loops – part 2 Barb Ericson Georgia Institute of Technology August 2005.
Barbara Ericson Georgia Tech Sept 2005
Topic 9 Modifying Pixels in a Matrix: Copying, Cropping
Manipulating Pictures, Arrays, and Loops part 2
Manipulating Pictures, Arrays, and Loops part 2
Creative Commons Attribution Non-Commercial Share Alike License
Barb Ericson Georgia Institute of Technology Dec 2009
Topic 10 The if statement Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
Sit-In Lab 1 Ob-CHESS-ion
Georgia Institute of Technology
Barb Ericson Georgia Institute of Technology August 2005
Two-Dimensional Arrays and Nested Loops – part 1
Introduction to Programming
Two-Dimensional Arrays and Nested Loops – part 1
Workshop for Programming And Systems Management Teachers
CSE 8A Lecture 6 Reading for next class:
Creative Commons Attribution Non-Commercial Share Alike License
Two-Dimensional Arrays and Nested Loops – part 2
Georgia Institute of Technology
Creative Commons Attribution Non-Commercial Share Alike License
CSC1401 Viewing a picture as a 2D image - 2
Creative Commons Attribution Non-Commercial Share Alike License
Barb Ericson Georgia Institute of Technology May 2006
Nested Loops Circles inside Circles
Introduction to Programming in MATLAB
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
Manipulating Pictures, Arrays, and Loops
Loops & Nested Loops CSE 120 Winter 2019
Nested Loops Circles inside Circles
CSC1401 Manipulating Pictures 2
C Parameter Passing.
Presentation transcript:

Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/ sa/3.0/ Original Developer: Beth Simon, 2009

CSE8A Lecture 14 Read next class: read pg Grades – expectations Feedback: –Review solutions to quizzes –Review clicker questions –Review PSAs (with others and tutors) –Review labs

Chapter 6: Conditionally modifying pixels All pixels change is COLOR meets criteria All pixels change if meet both a COLOR and COORDINATE criteria All pixels change if COORDINATES meet criteria

Does the order of the for loops matter? public void fillBottom(Color newColor) { Pixel pix; for (int aaa = 0; aaa < this.getHeight(); aaa++) { for (int bbb = 0; bbb < this.getWidth(); bbb++) { >>> { pix = this.getPixel(bbb,aaa); pix.setColor(newColor); } A.Yes, since we are changing the bottom half, we have to “fill in” across the rows in the inner loop B.Yes, because we need to make sure the if statement is checking aaa not bbb C.Yes, I have my own explanation D.No, the if statement controls the assignment

How many times is the variable pix assigned a value? A.1 B.this.getWidth() times C.this.getHeight() times D.this.getHeight()* this.getWidth() times E.this.getHeight()/2* this.getWidth() times public void fillBottom(Color newColor) { Pixel pix; for (int aaa = 0; aaa < this.getHeight(); aaa++) { for (int bbb = 0; bbb < this.getWidth(); bbb++) { >>> { pix = this.getPixel(bbb,aaa); pix.setColor(newColor); }

Remember this code? public void everyOtherPixel(Color newColor) { Pixel[] pixArray = this.getPixels(); for (int i = 0; i < pixArray.length(); i = i + 2) { pixArray[i].setColor(newColor); }

How is this the same? public void everyOtherColumn(Color newColor) { Pixel pix; for (int aaa = 0; aaa < this.getHeight(); aaa++) { for (int bbb = 0; bbb < this.getWidth(); bbb = bbb + 2) { pix = this.getPixel(bbb,aaa); pix.setColor(newColor); }

How many iterations of the loop body are executed? A.getHeight()-1 * getWidth()-1 B.getHeight()-1 * (getWidth()-1)/2 C.getHeight() * getWidth() D.getHeight() * getWidth()/2 E.None of the above public void everyOtherColumn(Color newColor) { Pixel pix; for (int aaa = 0; aaa < this.getHeight(); aaa++) { for (int bbb = 0; bbb < this.getWidth(); bbb = bbb + 2) { pix = this.getPixel(bbb,aaa); pix.setColor(newColor); }

Same code with if statement control public void everyOtherColumn(Color newColor) { Pixel pix; for (int aaa = 0; aaa < this.getHeight(); aaa++) { for (int bbb = 0; bbb < this.getWidth(); bbb++) { > pix = this.getPixel(bbb,aaa); pix.setColor(newColor); } A) if(bbb<this.getWidth()/2) C) if ((bbb % 2) == 0) B) if(bbb<this.getHeight()/2) D) if ( (this.getPixel(bbb,aaa) % 2) == 0)

If you can do it both ways, which is “better”? Efficiency Software Engineering Design –Readability –Modifyability We just looked at: –Looping over restricted bounds (< or %2 == 0) –Looping over all bounds with if statement inside

What parameters would YOU provide a user for a red eye reduction method? 1.Top left pixel coordinates for box to look for red eye in 2.Bottom right pixel coordinates for box to look for red eye in 3.Start index and end index for location to look for red eye in. 4.Color to change red eyes to 5.Threshold value to determine if eyes are “red” AXXXXX BXXXX CXXX DXXX EXXX

Book code for RedEye reduction: Parameters for good Software Engineering public void removeRedEye(int startX, int startY, int endX, int endY, Color newColor ) { Pixel pix; for (int x = ; x < ; x++) { for (int y = ; y < ;y++) { pix = this.getPixel(x,y); if (pix.colorDistance(Color.red) < 167) pix.setColor( ); }