You will write a program that creates negative image of a given image but leaves a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You will write a program that creates negative image of a given image but leaves a frame of size percent with original colors around the image. Your program negativelmagelnFrame(picture, percent) will take a JES picture object and a percentage as input. Define percent with default value 0.01. so it becomes an optional input variable. Two pictures are attached to see the desired effect. 1. The function luminance(pixel) is provided for you in the program stub. It calculates the luminance of the color of the pixel provided. 2. (4 points) You may initialize variables that contain values you use frequently in your program. You will know whether that is necessary or appropriate once you start writing your code. Create a copy of the input picture using duplicatePicture, so that the original input is never changed. 3. (4 points) Use double loops or a single loop to go over all pixels. 4. (4 points) Use if / elif / else to determine whether a pixel has a luminance in the range 0- 63, 64 127, 128 191, or 192 255. Based on the result, set the color of the pixel to a grayscale value of 32, 96, 160, or 224. Recall that any color created as makeColor(y.y.y) is gray. 5. Test your program on the provided picture. The result should look similar to the provided result. Problem8.py Minimize File Preview ZOOM def luminance (pixel): return 0. 299*getRed(pixel)+0.587 getGreen (pixel)+0.114 getBlue(pixel) def fourToneGrayScale(picture): Care-Bears WELCOME TO CARE-A-LOT Care-Bears WELCOME TO CARE-A-LOT You will write a program that creates negative image of a given image but leaves a frame of size percent with original colors around the image. Your program negativelmagelnFrame(picture, percent) will take a JES picture object and a percentage as input. Define percent with default value 0.01. so it becomes an optional input variable. Two pictures are attached to see the desired effect. 1. The function luminance(pixel) is provided for you in the program stub. It calculates the luminance of the color of the pixel provided. 2. (4 points) You may initialize variables that contain values you use frequently in your program. You will know whether that is necessary or appropriate once you start writing your code. Create a copy of the input picture using duplicatePicture, so that the original input is never changed. 3. (4 points) Use double loops or a single loop to go over all pixels. 4. (4 points) Use if / elif / else to determine whether a pixel has a luminance in the range 0- 63, 64 127, 128 191, or 192 255. Based on the result, set the color of the pixel to a grayscale value of 32, 96, 160, or 224. Recall that any color created as makeColor(y.y.y) is gray. 5. Test your program on the provided picture. The result should look similar to the provided result. Problem8.py Minimize File Preview ZOOM def luminance (pixel): return 0. 299*getRed(pixel)+0.587 getGreen (pixel)+0.114 getBlue(pixel) def fourToneGrayScale(picture): Care-Bears WELCOME TO CARE-A-LOT Care-Bears WELCOME TO CARE-A-LOT
Expert Answer:
Answer rating: 100% (QA)
Imported PIL Library from PIL import Image Open an Image def openimagepath newImage Imageopenpath return newImage Save Image def saveimageimage path imagesavepath png Create a new image def createimag... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these mechanical engineering questions
-
For this assignment you will write a program that inserts 20 random integers from 0 to 100 in order in a linked list object. The program will create another linked list, but with 15 random integers...
-
Write a program that creates two priority queues, {"George", "Jim", "John", "Blake", "Kevin", "Michael"} and {"George", "Katie", "Kevin", "Michelle", "Ryan"} and displays their union, difference, and...
-
One of the lovely properties of a linear map T on a vector space like R (distinguishing it from other arbitrary functions) is that we only need to know what I does to a small number of linearly...
-
Consider the many moments of joy in the movie. Why include them? What risky acts of courage do Katherine, Mary and Dorothy take? How are they rewarded? The film shows the strong relationships that...
-
Refer to the situation of problem 8-72. The study also compared average portfolios of microloans. For the Alpha group it was $50 million, and for the Beta group it was $14 million. Assume the Alpha...
-
Overheard at the water cooler in the corporate headquarters of a large manufacturing company: "The competition is really threatening us with their new product line. I think we should consider...
-
Consider the air pollution and mortality data given in Table B.15. a. Is there a problem with collinearity? Discuss how you arrived at this decision. b. Perform a ridge trace on these data. c. Select...
-
The Collins Corporation shows the following inventory, dividends, revenue, and expense account balances before closing: Required Prepare closingentries. Debit Credit Debi Credit $300 Dividends...
-
Explain the trading techniques that can be used with options and financial futures contracts and note how these securities can be used in conjunction with common stock, or bond investments
-
Costa, Inc., recently converted from a 5-day, 40-hour workweek to a 4-day, 40-hour workweek, with overtime continuing to be paid at one and one-half times the regular hourly rate for all hours worked...
-
1 A firm short-run production is given by Q = 2VL, where L is the number of units of labor. If the price per unit sold is $70, the price per unit of labor is $10, find the value of L needed to...
-
I bought my Peloton when it had a fair value of $ 2 , 4 7 5 . Peloton offered me the ability to pay $ 6 9 / mo for 3 6 months instead of paying upfront. I took it . What was my liability the day I...
-
Find the total capacitance (in F) of this combination of series and parallel capacitors shown below. 6.5 F 14 F 0.80 F
-
What is the volume of a lead ball at 23C if the ball's volume at 60C is 30 cm? Take the coefficient of volume expansion of lead to be 6.0 10-5/C.
-
A wheel rotating with a constant angular acceleration turns through 10 revolutions dur- ing a 3 s time interval. Its angular velocity at the end of this interval is 12 rad/s. What is the angular...
-
Problem 1. Jennifer sits in a Ferris wheel that is rotating at a constant frequency, and Jennifer moves at constant speed 9 m/s. At the highest point of her circular path, the upward normal force the...
-
Consider the following reaction. What would be the equilibrium constant expression? 4Br2(g) + CH4(9) 4HBr(g) + CBr4(g)
-
Maria Castigliani is head of the purchasing department of Ambrosiana Merceti, a medium-sized construction company. One morning she walked into the office and said, The main problem in this office is...
-
Write a program that stores, retrieves, adds, and updates addresses as shown in Figure 17.20. Use a fixed-length string for storing each attribute in the address. Use random access file for reading...
-
Write a program that obtains the execution time for finding all the prime numbers less than 8,000,000, 10,000,000, 12,000,000, 14,000,000, 16,000,000, and 18,000,000 using the algorithms in Listings...
-
Find the first ten square numbers that are greater than Long.MAX_VALUE. A square number is a number in the form of n2. For example, 4, 9, and 16 are square numbers. Find an efficient approach to run...
-
You are considering purchasing a defunct mine in Africa. Your firm has developed a method to extract valuable rare earth minerals from the mining entrails. The cost of the mine together with the...
-
Let us consider the scenario tree of Fig. 11.10 and define consider decision Data From Fig. 11.10 Data From Example 11.17 cision variables Z and Z, representing the number of stock shares that we buy...
-
Consider the following bonds: a. What is the percentage change in the price of each bond if its yield to maturity falls from 6% to 5%? b. Which of the bonds AD is most sensitive to a 1% drop in the...
Study smarter with the SolutionInn App