This document discusses using JyThon to manipulate images through opening, displaying, and modifying pixel colors of images. It covers getting and setting pixel color values, using loops to apply changes across all pixels, and copying an image onto a canvas through nested for loops. The document provides examples and prompts the reader to try various image transformations like scaling, rotating, and effects like blurring through pixel color modifications.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
117 views11 pages
Jy Thon
This document discusses using JyThon to manipulate images through opening, displaying, and modifying pixel colors of images. It covers getting and setting pixel color values, using loops to apply changes across all pixels, and copying an image onto a canvas through nested for loops. The document provides examples and prompts the reader to try various image transformations like scaling, rotating, and effects like blurring through pixel color modifications.
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) 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)
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. 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. 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)
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