Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

How to do the define colour distance part - new_background is the background image that you want to use to replace the green screan -

image text in transcribed

How to do the define colour distance part

- new_background is the background image that you want to use to replace the green screan - To make your life easier, you can assume both of the 2 arguments above are 2D list of tuples replace_color is a tuple of RoGB value that will be replaced in the source image. In our example, the replace_calor is green. You need to decide the RGB value yourself. (More details below) - this function should return None and do manipulation directly on the argument 1mage - def color_d1stance(color1, color 2) - colorl is the pixel calor in the source image - color2 is the replace_color (some green RGB value) - You need to calculate the distance between the two color using the following formula. Feel free to inport math and use the sqrt function - distance =(r1r2)2+(g1g2)2+(b1b2)2. - After you've generated your output image, name it creative.png in your workspace. Well download everyone's workspace and automatically take out that file from everyone. If you don't name it like so, it's very likely that your image won't be caught by the autofetching seript and we will not be able to witness your creativity - More explanations: What you need to do is, if the colar distance of the pixelcalor in the source image and the replace color is within a threshold, you need to replace the source pixel color with the corresponding pixel calor in new_baciaground. You will decide the threshold! Feel frec to come up with one from your intuition and run multiple experiments to see if the new image looks good enough. - We will grade your code and look at your output pictures manually. We will have a vote for everyone's picture and give extra points to the top 10, so please unleash your creativity. - You can use the methods provided in the Fudaninglib.py library to test your solution using the terminal. Useful functions include but are not limited to: losd_1ng(). save_1mg() . - Note that you need to close and reopen the file when you save something new to the same file, otherwise the file content does not automatically refresh. Starter code for your change_background. py fron fudaninglib inport * fingort math def change_background(fage, new_background, replace_calar): w Tco0 def colar_distance(calar1, colar2): w Tco0 land the scurce inage and new background inage

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions