d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > 1,000 Fg For Python Help
Add Reply New Topic New Poll
Member
Posts: 36,838
Joined: Aug 12 2007
Gold: 10,445.00
Apr 23 2017 06:16pm
missed class so was not there when they did this, pm me if you can do this, need it soon

Create a set of 2 functions to remove all the red from an image.

Function #1: Use the negativePixel function as a pattern to implement this. Name the function removeRed. The function will receive one parameter, the oldpixel, and it must return the newPixel
Function #2: Use the function makeNegative as a pattern to implement this. Name the function makeRedLess. The function will receive one parameter, the name of the image file that will have the red color removed from all of it's pixels.
Both the removeRed function and the makeRedLess function should be inside one Python program. The last line in the Python program should be to call the makeRedLess function to remove all of the red from the image "lutherBell.gif" This program should be named with your last name and _week14_1.py to avoid having points deducted -- DO NOT ZIP THE PROGRAM!

Week14_2: Create a set of two functions to convert an image file to the "sepia tone":

Background: Sepia tone is a brownish color that was used for photographs in the 1800s. The formula for creating a sepia tone is as follows:
newRed = (currentRed * 0.393 + currentGreen * 0.769 + currentBlue * 0.189)
newGreen = (currentRed * 0.349 + currentGreen * 0.686 + currentBlue * 0.168)>
newBlue = (currentRed * 0.272 + currentGreen * 0.534 + currentBlue * 0.131)
Function #1: Use the negativePixel function as a pattern to implement this. Name the function makeSepia. The function will receive one parameter, the oldpixel, and it must return the newPixel.
Function #2: Include in your program the existing (pre-written) pixelMapper function furnished to you in this week's examples.
Function #3: Modify the generalTransform function again furnished to you, so that instead of using the grayPixel function it uses the makeSepia function you just created.
All three functions, the makeSepia function, the pixelMapper function, and the newly modified generalTransform function should be inside one Python program. The last line in the Python program should be to call the generalTransform function to apply the Sepia tone to the image "lutherBell.gif" This program must be named with your last name and _week14_2.py to avoid having points deducted -- DO NOT ZIP THE PROGRAM!
Member
Posts: 1,263
Joined: Feb 11 2008
Gold: 2,650.00
Apr 24 2017 02:30am
Quote (Hboy @ Apr 23 2017 07:16pm)
Function #1: Use the negativePixel function as a pattern to implement this. Name the function removeRed. The function will receive one parameter, the oldpixel, and it must return the newPixel


Presumably you already have a negativePixel function which modifies RGB values. I would assume you would duplicate and modify that to removeRed, which sets RGB value to zero for red.

Quote (Hboy @ Apr 23 2017 07:16pm)
Function #2: Use the function makeNegative as a pattern to implement this. Name the function makeRedLess. The function will receive one parameter, the name of the image file that will have the red color removed from all of it's pixels.


Presumably you already have a makeNegative function which takes a filename and iterates over pixels with calls to negativePixel. Just duplicate and replace the calls with removeRed.

Quote (Hboy @ Apr 23 2017 07:16pm)
Function #1: Use the negativePixel function as a pattern to implement this. Name the function makeSepia. The function will receive one parameter, the oldpixel, and it must return the newPixel.


Same as above with the provided formulas.

Quote (Hboy @ Apr 23 2017 07:16pm)
Function #2: Include in your program the existing (pre-written) pixelMapper function furnished to you in this week's examples.


Sounds like nothing to do here.

Quote (Hboy @ Apr 23 2017 07:16pm)
Function #3: Modify the generalTransform function again furnished to you, so that instead of using the grayPixel function it uses the makeSepia function you just created.


Just replace the grayPixel calls in generalTransform with the new function.

Quote (Hboy @ Apr 23 2017 07:16pm)
All three functions, the makeSepia function, the pixelMapper function, and the newly modified generalTransform function should be inside one Python program. The last line in the Python program should be to call the generalTransform function to apply the Sepia tone to the image "lutherBell.gif"


Not much to do here.

Looks pretty straightforward if you have the previous iteration of work the instructions reference.
Member
Posts: 3,197
Joined: May 4 2013
Gold: 1,457.00
Apr 24 2017 03:12am
If you missed class you really don't want to cheat your way through it. Next class you'll have even more problems.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll