Question: USE PYTHON3; DO NOT IMPORT ANY PACKAGES Please do part 1(everything in the images) and don't change any parameters by adding or removing them. Thank

USE PYTHON3; DO NOT IMPORT ANY PACKAGES

Please do part 1(everything in the images) and don't change any parameters by adding or removing them. Thank you!

USE PYTHON3; DO NOT IMPORT ANY PACKAGES Please do part 1(everything inthe images) and don't change any parameters by adding or removing them.

Code in the text editor(fill out all parts please):

# Part 1: RGB Image #

class RGBImage: """ TODO: add description """

def __init__(self, pixels): """ TODO: add description """ # YOUR CODE GOES HERE # self.pixels = ... # initialze the pixels list here

def size(self): """ TODO: add description """ # YOUR CODE GOES HERE #

def get_pixels(self): """ TODO: add description """ # YOUR CODE GOES HERE #

def copy(self): """ TODO: add description """ # YOUR CODE GOES HERE #

def get_pixel(self, row, col): """ TODO: add description """ # YOUR CODE GOES HERE #

def set_pixel(self, row, col, new_color): """ TODO: add description """ # YOUR CODE GOES HERE #

In this part, you will implement the RGBImage class, a template for image objects in RGB color spaces. You need to implement the following methods: _init__(self, pixels) A constructor that initializes a RGBImage instance and necessary instance variables. The argument pixels is a 3-dimensional matrix, where pixels[c][i][j] indicates the intensity value in channel c at position (i, j). You must assign this matrix to self.pixels. You can assume that the index of the channel c is guaranteed to be o (red channel), 1 (green channel) or 2 (blue channel). You can also assume that each channel contains a valid (row x col) matrix. size (self) A getter method that returns the size of the image, where size is defined as a tuple of (number of rows, number of columns). get_pixels (self) A getter method that returns a DEEP COPY of the pixels matrix of the image (as a 3-dimensional list). This matrix of pixels is exactly the same pixels passed to the constructor Note: Make sure that this returns a deep copy of the pixels matrix, otherwise there will be many issues later on with Image Processing modifying additional images, which will impact the tests and your score. You won't be able to import the copy package, so you have to create the deep copy manually. We can create a deep copy of a 1D-list 'x' with a list comprehension ([elem for elem in x]) or with (list(x)). This is a 1D-list, so the implementation will differ for pixels since it is a 3D-list. If you try to just use (list(pixels)) you will not be creating a deep copy of all the dimensions of the list and will run into issues. copy (self) A method that returns a COPY of the RGBImage instance. You should create a new RGBImage instance using a deep copy of the pixels matrix (you can utilize the get_pixels function) and return this new instance. Note: Make sure that the new RGBImage instance is initialized with a deep copy of the pixels matrix, otherwise there will be many issues later on with Image Processing modifying additional images, which will impact the tests and your score. get_pixel (self, row, col) A getter method that returns the color of the pixel at position (row, col). The color should be returned as a 3-element tuple: (red int reen intensity, blue intensity) at that position. Requirement: Assert that row and col are valid indices. set_pixel (self, row, col, new_color) A setter method that updates the color of the pixel at position (row, col) to the new_color in place. The argument new_color is a 3-element tuple (red intensity, green intensity, blue intensity). However, if any color intensity in this tuple is provided as -1, you should not update the intensity at the corresponding channel Requirement: Assert that row and col are valid indices

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!