1 / 7

Image Processing in CS1

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

Download Presentation

Image Processing in CS1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Image Processing in CS1 Brad Miller David Ranum Luther College

  2. 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 • getGreen, setGreen • getBlue, setBlue http://knuth.luther.edu/~pythonworks

  3. 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

  4. Edge Detection • Iteration Patterns • Four levels of nesting • Setting boundaries • Edge Cases • Sum of Products

More Related