Menu

[solved]-Write Program Three Functions Sepia Removeallred Grayscale Sepia Tone Images Brownish Col Q38998291

Write a program that has three functions: sepia(),remove_all_red(), and gray_scale().

Sepia Tone images are those brownish colored images that mayremind you of times past. The formula for creating a sepia tone isas 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)

where R, G, and B are the original image pixel red, green andblue values.

Hint: Remember thatRGB 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()

We are using Python 3. PyCharm.

Expert Answer


Answer to Write a program that has three functions: sepia(), remove_all_red(), and gray_scale(). Sepia Tone images are those brown… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *