Please use python.
You can import only:
from typing import Dict, List
from PIL import Image
import random
Questions are:
---------------------------------------------------------------------------------------------------------------------------------
1. def rotate_picture_90_left(img: Image) -> Image:
"""Return a NEW picture that is the given Image img rotated 90
degrees
to the left.
Hints:
- create a new blank image that has reverse width and height
- reverse the coordinates of each pixel in the original picture,
img,
and put it into the new picture
"""
-----------------------------------------------------------------------------------------------------------------------------------
2. def rotate_picture_90_right(img: Image) -> Image:
"""
Return a NEW picture that is the given Image img rotated 90
degrees
to the right.
"""
---------------------------------------------------------------------------------------------------------------------------------
only the following methods are allowed to use
- Image.new(mode, size, color): creates a new image (use 'RGB' for mode)
- Image.open(filename): opens an existing image file
- Image.size: returns the image size in pixels as a 2-tuple, (width, height)
- Image.load(): returns a PixelAccess object of all of the image's pixels
- Image.show(): display the image represented by the Image object
- Image.save(filename): saves an image
- Image.close(): closes an open Image file
Hello
This code should be enough for you
from PIL import Image
import random
def rotate_picture_90_left(img: Image):
width=img.size[0]
height=img.size[1]
result=Image.new('RGBA',(height,width))
px=img.load()
px2=result.load()
dict={}
for y in range(height):
for x in range(width):
px2[(y,width-1-x)]=px[(x,y)]
return result
def rotate_picture_90_right(img:Image):
width=img.size[0]
height=img.size[1]
result=Image.new('RGBA',(height,width))
px=img.load()
px2=result.load()
for y in range(height):
for x in range(width):
px2[(height-1-y,x)]=px[(x,y)]
return result
def flip_horizontal(img:Image):
width=img.size[0]
height=img.size[1]
px=img.load()
for y in range(int(height/2)):
for x in range(int(width)):
px[(x,y)],px[(x,height-1-y)]=px[(x,height-1-y)],px[(x,y)]
#print('Hi')
return img;
def flip_vertical(img:Image):
width=img.size[0]
height=img.size[1]
px=img.load()
for x in range(int(width/2)):
for y in range(int(height)):
px[(x,y)],px[(width-1-x,y)]=px[(width-1-x,y)],px[(x,y)]
return img
def driver():
img=Image.open("000000000785.jpg")
img1=Image.open("000000000785.jpg")
img2=Image.open("000000000785.jpg")
result1=rotate_picture_90_left(img)
result2=rotate_picture_90_right(img)
horizontal_flip=flip_horizontal(img1)
vertical_flip=flip_vertical(img2)
img.show()
horizontal_flip.show()#or you can write img1.show()
vertical_flip.show()#or you can write img2.show()
result1.show()
result2.show()
driver()
Regards
Please use python. You can import only: from typing import Dict, List from PIL import Image...
def blur(img: Image) -> Image: """Blur Image, img, based on the given pixel_size Hints: - For each pixel, calculate average RGB values of its neighbouring pixels (i.e. newRed = average of all the R values of each adjacent pixel, ...) - Set the RGB value of the center pixel to be the average RGB values of all the pixels around it Be careful at the edges of the image: not all pixels have 8 neighboring pixels! """ please use python...
from PIL import Image import random # NOTE: Feel free to add in any constant values you find useful to use BLACK = (0, 0, 0) WHITE = (255, 255, 255) # NOTE: Feel free to add in any helper functions to organize your code but # do NOT rename any existing functions (or else, autograder # won't be able to find them!!) # NOTE: The following function is already completed for you as an example # You can use...
Please design the function in version 3 of python 4. Write a function extract(pixels, rmin, rmax, cmin, cmax) that takes the 2-D list pixels containing pixels for an image, and that creates and returns a new 2-D list that represents the portion of the original image that is specified by the other four parameters. The extracted portion of the image should consist of the pixels that fall in the intersection of the rows of pixels that begin with row rmin...
Assignment Λ You shall write a Java program that accepts 5 command-line arguments and generates an image of a Sierpinski triangle, as a 24- bit RGB PNG image file. Specifications The command-line arguments shall consist of the following 1. The width (in pixels) of the image, as a positive decimal integer 2. The height (in pixels) of the image, as a positive decimal integer 3. The minimum area (in pixels) that a triangle must have in order to be drawn,...
the following python code edits BMP image file to negative but I need help with modifying this code so it turns it the same BMP image file into a black and white instead of a negative. heres python code I have so far [pasted below] ## # This program processes a digital image by creating a negative of a BMP image. # from io import SEEK_CUR from sys import exit def main() : filename = input("Please enter the file name:...
Please assist. I keep getting the error message in the middle screen when I run the program on the left. The image on the right is the section of images.py where it's indicating the issue with the .split is. How do I fix this? images.cy - /Users/carrietarpy Downloads/lab9-3/images.py 12.7.18) Python 2.7.18 Shell Python 2.7.15 (v2.7.18:542 102112, Apr 19 2820, 29:48:48) [GCC 4.7.1 Compatible Apple II w 6.3 Clong-FA3.0.57)] on der in Type "help", "copyright', 'credits' or "license()' for more inforyotion...
AssignmentBitmap files map three 8-bit (1-byte) color channels per pixel. A pixel is a light-emitting "dot" on your screen. Whenever you buy a new monitor, you will see the pixel configuration by its width and height, such as 1920 x 1080 (1080p) or 3840x2160 (4K). This tells us that we have 1080 rows (height), and each row has 1920 (width) pixels.The bitmap file format is fairly straight forward where we tell the file what our width and height are. When...
Can you please assist me with this HTML? Below is what I have but it isn't working. Filename: jpf_sudoku.css /* Table Styles */ table.spuzzle { border-collapse: collapse; margin-top: 0px; margin-bottom: 0px; margin-left: auto; margin-right: auto; width: 90%; } table.spuzzle td { border: 5px outset gray; width: 33.3%; } table.spuzzle th { font color: gray; padding-right: 10px; padding-bottom: 10px; } /* Inner Table Styles */ table.subTable { border-collapse: collapse; width: 100%; } table.subTable td { box-shadow: 0px 0px 15px inset; border:...
Hi. I require your wonderful help with figuring out this challenging code. import java.awt.Color; import java.awt.image.BufferedImage; import java.io.*; import javax.imageio.ImageIO; public class ImageLab { /* * This is the grayscale example. Use it for inspiration / help, but you dont * need to change it. * * Creates and returns a new BufferedImage of the same size as the input * image. The new image is the grayscale version of the input (red, green, and * blue components averaged together)....
#PYTHON# In this exercise you will write code which loads a collection of images (which are all the same size), computes a pixelwise average of the images, and displays the resulting average. The images below give some examples that were generated by averaging "100 unique commemorative photographs culled from the internet" by Jason Salavon. Your program will do something similar. Write a function in the cell below that loads in one of the sets of images and computes their average....