[SOLVED] Program that has three functions: sepia(), remove_all_red(), and gray_scale()

15.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon ImageTone.zip (7.3 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
5/5 - (5 votes)
  1. Write a program that has three functions: sepia(), remove_all_red(), and gray_scale().

 

Sepia Tone images are those brownish colored images that may remind you of times past. The formula for creating a sepia tone is as follows:

 

newR = (R Γ— 0.393 + G Γ— 0.769 + B Γ— 0.189)

newG = (R Γ— 0.349 + G Γ— 0.686 + B Γ— 0.168)

newB = (R Γ— 0.272 + G Γ— 0.534 + B Γ— 0.131)

 

Red removal from an image:

 

Simply set the R component to 0.

 

Gray scale conversion:

 

newR = (R Γ— 0.289 + G Γ— 0.587 + B Γ— 0.114)

newG = (R Γ— 0.289 + G Γ— 0.587 + B Γ— 0.114)

newB = (R Γ— 0.289 + G Γ— 0.587 + B Γ— 0.114)

 

 

Β 

Hint: Remember that rgb values must be integers between 0 and 255.

You can get each pixel by using p = img.getPixel(col, row)

Components of each pixel can be retrieved by p.getRed(), p.getGreen(), p.getBlue()

 

#Starter code
import image

img = image.Image(“sample.jpg”)
newimg = image.EmptyImage(img.getWidth(), img.getHeight())
win = image.ImageWin()

img.draw(win)
win.exitonclick()

 

 

 

 

  • ImageTone.zip