0% 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.

Uploaded by

pfedorov
Copyright
© © All Rights Reserved
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% 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.

Uploaded by

pfedorov
Copyright
© © All Rights Reserved
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
You are on page 1/ 11

NATAPON PANTUWONG

JyThon : Image Processing


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

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)


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

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

You might also like