Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using python and pillow library. only use getpixel() and putpixel() Try a diagon

ID: 3833909 • Letter: U

Question

Using python and pillow library. only use getpixel() and putpixel()

Try a diagonal flip of an image. That is, exchange the values of x and y. To make it interesting, don’t use a square image – that’s too easy. Note that the dimensions of the flipped image will be different. If you start with an image that is 400 pixels wide and 300 high, the flipped version will be 300 wide and 400 high. All pixels on the main diagonal, from the top left down toward the right, stay in the same location. The top edge will end up on the left side, and the left side ends up being the top edge

Explanation / Answer

from PIL import Image e=input('file and location? ') img=Image.open(e) pmap=img.load() imy=img.height imx=img.width if int(input('1 for encoding, 2 for decoding '))==1: a=input('Your message? ') for i in range(len(a)): r , g , b=img.getpixel((i+10,imy//2)) img.putpixel((i+10,imy//2),(ord(a[i]),g,b)) r,g,b=img.getpixel((len(a)+10,imy//2)) img.putpixel((len(a)+10,imy//2),(999,g,b)) #999 is the stop code in decoding else: r=u=0 m='' while r!=999: r , g , b=img.getpixel((10+u,imy//2)) m+=chr(r) u+=1 print(m[:len(a)-1]) img.save(e)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote