Question
I get the following error Function 'transpose' (no options) was 51% incorrect on 'blocks.png'. I have attached blocks png. The bolded is what I need
I get the following error
Function 'transpose' (no options) was 51% incorrect on 'blocks.png'.
I have attached blocks png. The bolded is what I need help with. I believe the first 2 functions are helping functions.
# Function useful for debugging def display(image): height = len(image) width = len(image[0]) # Find the maximum string size for padding maxsize = 0 for row in image: for pixel in row: text = repr(pixel) if len(text) > maxsize: maxsize = len(text) # Pretty print the pixels print() for pos1 in range(height): row = image[pos1] for pos2 in range(width): pixel = row[pos2] middle = repr(pixel) padding = maxsize-len(middle) prefix = ' ' if pos1 == 0 and pos2 == 0: prefix = '[ [ ' elif pos2 == 0: prefix = ' [ ' suffix = ',' if pos1 == height-1 and pos2 == width-1: suffix = (' '*padding)+' ] ]' elif pos2 == width-1: suffix = (' '*padding)+' ],' print(prefix+middle+suffix) # This function does not modify the image return
# Example function illustrating image manipulation def dered(image):
# Get the image size height = len(image) width = len(image[0]) for row in range(height): for col in range(width): pixel = image[row][col] pixel.red = 0 # This function DOES modify the image return True
def transpose(image): """ Returns True after transposing the image All plug-in functions must return True or False. This function returns True because it modifies the image. It transposes the image, swaping colums and rows. Transposing is tricky because you cannot just change the pixel values; you have to change the size of the image table. A 10x20 image becomes a 20x10 image. The easiest way to transpose is to make a transposed copy with the pixels from the original image. Then remove all the rows in the image and replace it with the rows from the transposed copy. Parameter image: The image buffer Precondition: image is a 2d table of RGB objects """ # Change this to return True when the function is implemented temp = [] temp = [[image[j][i] for j in range(len(image))] for i in range(len(image[0]))] image = temp
return True
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started