week 10 - clark science center€¦ · week 10 csc111 — spring 2015. d. thiebaut, computer...
TRANSCRIPT
![Page 2: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/2.jpg)
D. Thiebaut, Computer Science, Smith College
Next Few Lectures
• Image Processing with Nested For-Loops
• Lists can be Used to Solve Many Problems (Chap. 11)
• Class Inheritance
![Page 3: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/3.jpg)
D. Thiebaut, Computer Science, Smith College
Image Geometry & Coordinate System
Scanning Images using Nested For-Loops
Sweep
How RGB Works
Python Code for Image Processing
Demo
![Page 4: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/4.jpg)
D. Thiebaut, Computer Science, Smith College
Image Processing
![Page 5: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/5.jpg)
D. Thiebaut, Computer Science, Smith College
• Different image types: jpg, png, gif, eps, svg, tiff, etc.
• Zelle graphics.py library compatible with gif images only.
• Jpg and png files can be converted to gif using Web services (e.g. http://image.online-convert.com/convert-to-gif)
![Page 6: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/6.jpg)
D. Thiebaut, Computer Science, Smith College
Image Geometry
width
height
309 pixels × 163 pixels ~50K pixels
![Page 7: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/7.jpg)
D. Thiebaut, Computer Science, Smith College
width
height
309 pixels × 163 pixels ~50K pixels
0 1 2 3 4 5 6 70 1 2 3 4
307 308
307 308
161 162
0 1 2 3 4
161 162
0 1 2 3 4 5 6 7
Image Geometry
![Page 8: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/8.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 70 1 2 3 4
307 308
307 308
161 162
0 1 2 3 4
0, 4308, 4
307, 162
161 162
0 1 2 3 4 5 6 7
Image Geometry
![Page 9: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/9.jpg)
D. Thiebaut, Computer Science, Smith College
Image Geometry & Coordinate System
Scanning Images using Nested For-Loops
Sweep
How RGB Works
Python Code for Image Processing
Demo
![Page 10: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/10.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4
Change all the pixels to red
![Page 11: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/11.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( WIDTH ): for y in range( HEIGHT ): makePixelRed( x, y )
![Page 12: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/12.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
(Use numbers: easier to understand)
![Page 13: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/13.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
![Page 14: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/14.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0
![Page 15: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/15.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0
![Page 16: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/16.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=0
![Page 17: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/17.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=0
![Page 18: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/18.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=0
![Page 19: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/19.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=1
![Page 20: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/20.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=1
![Page 21: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/21.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=2
![Page 22: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/22.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=2
![Page 23: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/23.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=3
![Page 24: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/24.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=3
![Page 25: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/25.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=4
![Page 26: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/26.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=4
![Page 27: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/27.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=0y=
![Page 28: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/28.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=1y=
![Page 29: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/29.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=1y=0
![Page 30: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/30.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=1y=0
![Page 31: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/31.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
x=1y=01234
![Page 32: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/32.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
![Page 33: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/33.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
![Page 34: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/34.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for x in range( 8 ): for y in range( 5 ): makePixelRed( x, y )
![Page 35: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/35.jpg)
D. Thiebaut, Computer Science, Smith College
Switching the Loops
![Page 36: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/36.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for y in range( 5 ): for x in range( 8 ): makePixelRed( x, y )
![Page 37: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/37.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for y in range( 5 ): for x in range( 8 ): makePixelRed( x, y )
![Page 38: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/38.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for y in range( 5 ): for x in range( 8 ): makePixelRed( x, y )
y=0x=0
![Page 39: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/39.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for y in range( 5 ): for x in range( 8 ): makePixelRed( x, y )
x=01234567y=0
![Page 40: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/40.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for y in range( 5 ): for x in range( 8 ): makePixelRed( x, y )
![Page 41: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/41.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for y in range( 5 ): for x in range( 8 ): makePixelRed( x, y )
![Page 42: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/42.jpg)
D. Thiebaut, Computer Science, Smith College
Image Geometry & Coordinate System
Scanning Images using Nested For-Loops
Sweep
How RGB Works
Python Code for Image Processing
Demo
![Page 43: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/43.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for y in range( 5 ): for x in range( 8 ): makePixelRed( x, y )
sweep
![Page 44: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/44.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for y in range( ? ): for x in range( ? ): makePixelRed( x, y )
sweep ?
![Page 45: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/45.jpg)
D. Thiebaut, Computer Science, Smith College
0 1 2 3 4 5 6 7
0 1 2 3 4 WIDTH = 8
HEIGHT = 5
for y in range( 4, -1, -1 ): for x in range( 8 ): makePixelRed( x, y )
sweep!
![Page 46: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/46.jpg)
D. Thiebaut, Computer Science, Smith College
Image Geometry & Coordinate System
Scanning Images using Nested For-Loops
Sweep
How RGB Works
Python Code for Image Processing
Demo
![Page 47: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/47.jpg)
D. Thiebaut, Computer Science, Smith College
How RGB Works
pixel
![Page 48: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/48.jpg)
D. Thiebaut, Computer Science, Smith College
pixel
0-255
Red Green Blue0-255 0-255
RGB System
How RGB Works
![Page 49: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/49.jpg)
D. Thiebaut, Computer Science, Smith College
pixel
255
Red Green Blue0 0
RGB System
How RGB Works
![Page 50: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/50.jpg)
D. Thiebaut, Computer Science, Smith College
pixel
255
Red Green Blue0 0
RGB System
How RGB Works
![Page 51: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/51.jpg)
D. Thiebaut, Computer Science, Smith College
pixel
0
Red Green Blue255 0
RGB System
How RGB Works
![Page 52: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/52.jpg)
D. Thiebaut, Computer Science, Smith College
pixel
0
Red Green Blue255 0
RGB System
How RGB Works
![Page 53: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/53.jpg)
D. Thiebaut, Computer Science, Smith College
pixel
0
Red Green Blue0 255
RGB System
How RGB Works
![Page 54: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/54.jpg)
D. Thiebaut, Computer Science, Smith College
pixel
0
Red Green Blue0 255
RGB System
How RGB Works
![Page 55: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/55.jpg)
D. Thiebaut, Computer Science, Smith College
pixel
51
Red Green Blue255 255
RGB System
How RGB Works
![Page 56: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/56.jpg)
D. Thiebaut, Computer Science, Smith College
pixel
51
Red Green Blue255 255
RGB System
http://www.rapidtables.com/web/color/RGB_Color.htm
How RGB Works
![Page 57: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/57.jpg)
D. Thiebaut, Computer Science, Smith College
pixel at x, y
51
Red Green Blue255 255
red, green, blue = cat.getPixel( x, y )
How RGB Works
![Page 58: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/58.jpg)
D. Thiebaut, Computer Science, Smith College
pixel at x, y
51
Red Green Blue255 255
# create color red color = color_rgb( 255, 0, 0 )
# set pixel at x, y to red cat.setPixel( x, y, color )
How RGB Works
![Page 59: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/59.jpg)
D. Thiebaut, Computer Science, Smith College
pixel at x, y
255
Red Green Blue0 0
# create color red color = color_rgb( 255, 0, 0 )
# set pixel at x, y to red cat.setPixel( x, y, color )
How RGB Works
![Page 60: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/60.jpg)
D. Thiebaut, Computer Science, Smith College
Why 255?
![Page 61: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/61.jpg)
D. Thiebaut, Computer Science, Smith College
1 bit
0 1 0 - 1
binary decimal
![Page 62: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/62.jpg)
D. Thiebaut, Computer Science, Smith College
2 bits
00 01 10 11
0 - 3
binary decimal
22 = 4
![Page 63: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/63.jpg)
D. Thiebaut, Computer Science, Smith College
3 bits
000 001 010 011 100 101 110 111
0 - 7
binary decimal
23 = 8
![Page 64: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/64.jpg)
D. Thiebaut, Computer Science, Smith College
4 bits
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
0 - 15
binary decimal
24 = 16
![Page 65: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/65.jpg)
D. Thiebaut, Computer Science, Smith College
8 bits = byte
00000000 00000001 00000010 00000011 00000100 00000101 00000110
. . . 11111000 11111001 11111010 11111011 11111100 11111101 11111110 11111111
0 - 255
binary decimal
28 = 256
![Page 66: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/66.jpg)
D. Thiebaut, Computer Science, Smith College
8 bits = byte
00000000 00000001 00000010 00000011 00000100 00000101 00000110
. . . 11111000 11111001 11111010 11111011 11111100 11111101 11111110 11111111
0 - 255
binary decimal
51
Red Green Blue255 255
1 pixel = 3 bytes
![Page 67: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/67.jpg)
D. Thiebaut, Computer Science, Smith College
8 bits = byte
00000000 00000001 00000010 00000011 00000100 00000101 00000110
. . . 11111000 11111001 11111010 11111011 11111100 11111101 11111110 11111111
0 - 255
binary decimal
51 255 255
1 pixel = 3 bytes
256 x 256 x 256 = 16,777,216 colors
Red Green Blue
![Page 68: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/68.jpg)
D. Thiebaut, Computer Science, Smith College
Special Colors
255 255 255
0 0 0
101 101 101
Red Green Blue
Red Green Blue
Red Green Blue
![Page 69: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/69.jpg)
D. Thiebaut, Computer Science, Smith College
Image Geometry & Coordinate System
Scanning Images using Nested For-Loops
Sweep
How RGB Works
Python Code for Image Processing
Demo
![Page 70: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/70.jpg)
D. Thiebaut, Computer Science, Smith College
Zelle's Graphics Libraryand Images
http://mcsp.wartburg.edu/zelle/python/graphics/graphics/node12.html
![Page 71: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/71.jpg)
D. Thiebaut, Computer Science, Smith College
Drawing an Image
![Page 72: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/72.jpg)
D. Thiebaut, Computer Science, Smith College
Processing Pixels of an Image
![Page 73: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/73.jpg)
D. Thiebaut, Computer Science, Smith College
Demo Time!
![Page 74: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/74.jpg)
D. Thiebaut, Computer Science, Smith College
Transformations to Try
• Modify RED component
• Saturate
• Draw a horizontal line (beginning of a border)
![Page 75: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/75.jpg)
D. Thiebaut, Computer Science, Smith College
We stopped here last time…
![Page 76: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/76.jpg)
D. Thiebaut, Computer Science, Smith College
Mirroring an Image
Displaying a Checker Board
8x8 Grid
Alternating Colors
Creating a Class for a Checkers Piece
Using a Gif Image for a Piece
![Page 77: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/77.jpg)
D. Thiebaut, Computer Science, Smith College
Transformations to Try• Mirror top half of cat image
![Page 78: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/78.jpg)
D. Thiebaut, Computer Science, Smith College
x=398, y=0
x=398, y=417
418
![Page 79: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/79.jpg)
D. Thiebaut, Computer Science, Smith College
x=398, y=0
x=398, y=417
418
x=398, y=1
x=398, y=416
![Page 80: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/80.jpg)
D. Thiebaut, Computer Science, Smith College
x=398, y=0
x=398, y=417
418
x=398, y=1
x=398, y=416
x=398, y=208x=398, y=209
![Page 81: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/81.jpg)
D. Thiebaut, Computer Science, Smith College
x=398, y=0
x=398, y=417
418
x=398, y=1
x=398, y=416
x=398, y=208x=398, y=209
Observation 1: y_source + y_destination = 417, always
![Page 82: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/82.jpg)
D. Thiebaut, Computer Science, Smith College
x=398, y=0
x=398, y=417
418
x=398, y=1
x=398, y=416
x=398, y=208x=398, y=209
Observation 2: 417 = image height - 1
![Page 83: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/83.jpg)
D. Thiebaut, Computer Science, Smith College
Mirroring an Image
Displaying a Checker Board
8x8 Grid
Alternating Colors
Creating a Class for a Checkers Piece
Using a Gif Image for a Piece
![Page 84: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/84.jpg)
D. Thiebaut, Computer Science, Smith College
Graphic Problem of the Day:
“Playing” Checkers
Image credit: http://www.freeimageslive.co.uk/free_stock_image/checkersjpg
![Page 85: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/85.jpg)
D. Thiebaut, Computer Science, Smith College
Problems to Solve:• Display 8x8 board with alternating colors
• Generate the graphics for a piece (white and black circular shapes)
• Display the board with the black and white pieces
• Spiffy it up with real images
![Page 86: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/86.jpg)
D. Thiebaut, Computer Science, Smith College
Display 8x8 Board
![Page 87: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/87.jpg)
D. Thiebaut, Computer Science, Smith College
i=0 1 2 3 4 5 6 7j=0 1
2 3 4 5 6 7
600pxside = 600/8 =75 px
![Page 88: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/88.jpg)
D. Thiebaut, Computer Science, Smith College
i=0 1 2 3 4 5 6 7j=0 1
2 3 4 5 6 7
600px
p1
p2
side = 600/8 =75 px
![Page 89: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/89.jpg)
D. Thiebaut, Computer Science, Smith College
i=0 1 2 3 4 5 6 7j=0 1
2 3 4 5 6 7
600px
p1
p2
# i is 0, j is 0
p1 = Point( ?, ? ) p2 = Point( ?, ? )
rect = Rectangle( p1, p2 ) rect.setFill( “green” ) rect.draw( win )
side = 600/8 =75 px
![Page 90: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/90.jpg)
D. Thiebaut, Computer Science, Smith College
i=0 1 2 3 4 5 6 7j=0 1
2 3 4 5 6 7
600px
p1
p2
# i is 1, j is 2
p1 = Point( ?, ? ) p2 = Point( ?, ? )
rect = Rectangle( p1, p2 ) rect.setFill( “green” ) rect.draw( win )
side = 600/8 =75 px
![Page 91: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/91.jpg)
D. Thiebaut, Computer Science, Smith College
i=0 1 2 3 4 5 6 7j=0 1
2 3 4 5 6 7
600pxside = 600/8 =75 px
p1
p2
# i is 1, j is 2x = i * side y = j * side p1 = Point( x, y ) p2 = Point( x+side, y+side )
rect = Rectangle( p1, p2 ) rect.setFill( “green” ) rect.draw( win )
![Page 92: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/92.jpg)
D. Thiebaut, Computer Science, Smith College
i=0 1 2 3 4 5 6 7j=0 1
2 3 4 5 6 7
600pxside = 600/8 =75 px
for i in range( 8 ): for j in range( 8 ):
x = i * side y = j * side p1 = Point( x, y ) p2 = Point( x+side, y+side )
rect = Rectangle( p1, p2 ) rect.setFill( “green” ) rect.draw( win )
p1
p2
![Page 93: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/93.jpg)
D. Thiebaut, Computer Science, Smith College
i=0 1 2 3 4 5 6 7j=0 1
2 3 4 5 6 7
600pxside = 600/8 =75 px
for i in range( 8 ): for j in range( 8 ):
x = i * side y = j * side p1 = Point( x, y ) p2 = Point( x+side, y+side )
rect = Rectangle( p1, p2 ) rect.setFill( “green” ) rect.draw( win )
p1
p2
For fun, replace with: color_rgb( i*j, 255-i*j, (i+j)*10 )
![Page 94: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/94.jpg)
D. Thiebaut, Computer Science, Smith College
Mirroring an Image
Displaying a Checker Board
8x8 Grid
Alternating Colors
Creating a Class for a Checkers Piece
Using a Gif Image for a Piece
![Page 95: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/95.jpg)
D. Thiebaut, Computer Science, Smith College
Alternating Black
and White Cells
i - j
![Page 96: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/96.jpg)
D. Thiebaut, Computer Science, Smith College
Alternating Black
and White Cells
i - j
![Page 97: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/97.jpg)
D. Thiebaut, Computer Science, Smith College
Mirroring an Image
Displaying a Checker Board
8x8 Grid
Alternating Colors
Creating a Class for a Checkers Piece
Using a Gif Image for a Piece
![Page 98: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/98.jpg)
D. Thiebaut, Computer Science, Smith College
Checkers on Board
![Page 99: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/99.jpg)
D. Thiebaut, Computer Science, Smith College
Checkers on Board
![Page 100: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/100.jpg)
D. Thiebaut, Computer Science, Smith College
Mirroring an Image
Displaying a Checker Board
8x8 Grid
Alternating Colors
Creating a Class for a Checkers Piece
Using a Gif Image for a Piece
![Page 101: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/101.jpg)
D. Thiebaut, Computer Science, Smith College
Using an Image
http://pixgood.com/checkers-pieces-clip-art.html
copy
Resize Convert to gif
![Page 102: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/102.jpg)
D. Thiebaut, Computer Science, Smith College
Using an Image
http://pixgood.com/checkers-pieces-clip-art.html
copy
Resize Convert to gif ?
![Page 103: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/103.jpg)
D. Thiebaut, Computer Science, Smith College
![Page 104: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/104.jpg)
D. Thiebaut, Computer Science, Smith College
![Page 105: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/105.jpg)
D. Thiebaut, Computer Science, Smith College
We stopped here last time…
![Page 106: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/106.jpg)
D. Thiebaut, Computer Science, Smith College
Review Wheel, Car, Checkers
Checkers: Animation Loop & Interactivity
A Virtual Aquarium
![Page 107: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/107.jpg)
D. Thiebaut, Computer Science, Smith College
Review Wheel & Car Classes
http://cs.smith.edu/dftwiki/index.php/CSC111_Programs_for_Week_9_2015#wheel1.py
![Page 108: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/108.jpg)
D. Thiebaut, Computer Science, Smith College
Review DisplayCheckers.py
In “Programs for Week 10” page…
![Page 109: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/109.jpg)
D. Thiebaut, Computer Science, Smith College
Review Wheel, Car, Checkers
Checkers: Animation Loop & Interactivity
A Virtual Aquarium
![Page 110: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/110.jpg)
D. Thiebaut, Computer Science, Smith College
Building an Animation Loop
Adding Interactivity
![Page 111: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/111.jpg)
D. Thiebaut, Computer Science, Smith College
RemovingCheckers
with the Mouse
![Page 112: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/112.jpg)
D. Thiebaut, Computer Science, Smith College
MovingCheckers
with the Mouse
![Page 113: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/113.jpg)
D. Thiebaut, Computer Science, Smith College
Virtual Aquarium
![Page 114: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/114.jpg)
D. Thiebaut, Computer Science, Smith College
![Page 115: Week 10 - Clark Science Center€¦ · Week 10 CSC111 — Spring 2015. D. Thiebaut, Computer Science, Smith College Next Few Lectures • Image Processing with Nested For-Loops •](https://reader030.vdocuments.site/reader030/viewer/2022041121/5f3531c2659a3e474a164d6c/html5/thumbnails/115.jpg)
D. Thiebaut, Computer Science, Smith College