1 / 11

JyThon : Image Processing

JyThon : Image Processing. Natapon Pantuwong. Manipulate Pictures. Open image file with JyThon >>> file = pickAFile () >>> print file /user/ guzdial / mediasource /babara.jpg >>> picture = makePicture (file) >>> show(picture) >>> print picture

taro
Download Presentation

JyThon : Image Processing

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. JyThon : Image Processing NataponPantuwong

  2. Manipulate Pictures Open image file with JyThon >>> file = pickAFile() >>> print file /user/guzdial/mediasource/babara.jpg >>> picture = makePicture(file) >>> show(picture) >>> print picture Picture, filename/Users/guzdial/mediasources/babara.jpg height 294 width 222

  3. Manipulate Picture >>> print getWidth(picture) >>> print getHeight(picture) >>> pixel = getPixel(picture,1,1) >>> print pixel Pixel, color = color r =168 g=131 b=105 >>> pixel = getPixels(picture) >>> print pixel[0] Pixel, color = color r =168 g=131 b=105

  4. Manipulate Picture >>> print getX(pixel) >>> print getY(pixel) >>> print getRed(pixel) >>> setRed(pixel,255) >>> color = getColor(pixel) >>> print color color r=255,g =131, b=105 >>> newColor = makeColor(0,100,0) >>> setColor(pixel,newColor)

  5. Manipulate Picture >>> print distance(color,newcolor) >>> makeLighter(color) >>> makedarker(color) >>> writePictureTo (picture, “/Users/guzdial/newpicture.jpg”)

  6. Manipulate Picture >>> file = “Users/guzdial/mediasources/katie.jpg” >>> pict = makePicture(file) >>> show(pict) >>> setColor (getPixel(pict,10,100),yellow) >>> setColor (getPixel(pict,10,101),yellow) >>> setColor (getPixel(pict,10,102),yellow) >>> setColor (getPixel(pict,10,103),yellow) >>> setColor (getPixel(pict,10,104),yellow) >>> repaint(pict)

  7. Using Loops in Pictures >>> for pixel in getPixels(picture) value = getRed(pixel) setRed(pixel,value) >>> for pixel in getPixels(picture) value = getRed(pixel) setRed(pixel,value*0.5)

  8. Using Loops in Picture Your Turn!!! Make sun set picture from beach picture. Assume that when sun set, blue and green will be decreased 30%. Negative Image which invert black and white of gray level. Grayscale image which computed by average of red, green and blue of each pixel.

  9. Looping Across the Pixels with range >>> for x in range(1,getWidth(picture)) for y in range(1,getHeight(picture)) pixel = getPixel(picture,x,y) Your Turn!!! Let lighten the picture. Mirror your image vertical or horizontal.

  10. Copying and Transforming Image #Set up the source and target pictures barbf = getMediaPath(“babara.jpg”) barb = makePicture(barbf) canvasf = getMediaPath(“7inx95in.jpg”) canvas = makePicture(canvasf) targetX = 1 for sourceX in range(1,getWidth(barb)): targetY = 1 for sourceY in range(1,getHeight(barb)): color = getColor(getPixel(barb,sourceX,sourceY)) setColor(getPixel(canvas,targetX,targetY),color) targetY = targetY + 1 targetX = targetX + 1 show(barb) show(canvas)

  11. Copying and Transforming Pictures Your Turn!! Translation with (10,15) Rotate CW 90 degree. Scale up by 2 Scale down by 2 Blurring Sharpening Blue Screen

More Related