Top Banner
IMAGE PROCESSING IN CS1 Brad Miller David Ranum Luther College
7

Image Processing in CS1

Jan 03, 2016

Download

Documents

kaseem-dalton

Image Processing in CS1. Brad Miller David Ranum Luther College. Image Processing with cImage. Classes. Methods. Window Image File Image Empty Image List Image Pixel Does not require PIL. Images getWidth , getHeight getPixel,setPixel Pixels getRed , setRed - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Image Processing in CS1

IMAGE PROCESSING IN CS1

Brad Miller

David Ranum

Luther College

Page 2: Image Processing in CS1

IMAGE PROCESSING WITH CIMAGE

Window Image

• File Image• Empty Image• List Image

Pixel Does not require PIL

Images• getWidth, getHeight• getPixel,setPixel

Pixels• getRed, setRed• getGreen, setGreen• getBlue, setBlue

Classes Methods

http://knuth.luther.edu/~pythonworks

Page 3: Image Processing in CS1

def blackWhite(pic): bwpic = EmptyImage(pic.getWidth(), pic.getHeight()) for row in range(pic.getHeight()): for col in range(pic.getWidth()): thepixel = pic.getPixel(col,row) r = thepixel.getRed() g = thepixel.getGreen() b = thepixel.getBlue() gray = (r + g + b)//3 if gray <= 127: p = Pixel(0,0,0) else: p = Pixel(255,255,255) bwpic.setPixel(col,row,p) return bwpic

Page 4: Image Processing in CS1
Page 5: Image Processing in CS1
Page 6: Image Processing in CS1

EDGE DETECTION

Iteration Patterns Four levels of

nesting Setting boundaries

Edge Cases Sum of Products

Page 7: Image Processing in CS1