CS161, C++, PhotoChop Assignment Instructions Submit file: main.cpp Make two or more functions that create or modify an
Posted: Mon Jun 06, 2022 4:55 pm
CS161, C++, PhotoChop
Assignment Instructions
Submit file: main.cpp
Make two or more functions that create or modify an
existing image using the PhotoChop code. You must make your
functions from different categories listed below (for example, you
can't do two "Create New Image" functions).
Add your new functions to main.cpp, and change
the main function in that file to show them off. When you
are done, submit your main.cpp file in elearn. If you
have created or used any sample images other than the ones provided
with the codebase, you may submit them as well.
Function ideas
Here are some ideas for possible functions, but feel free to
invent your ideas or modify these suggestions.
Drawing a pattern
(e.g. makeAqua and makeGradient)
Box
Write a function that takes in parameters for starting row,
column, width, and height. It then uses those values to draw a
white box (or whatever color you like) on a black background.
Modifying an image (e.g. redShift)
Only red
Set the blue and green value for each picture to be 0.
Grayscale red
Set the blue and green values for each pixel equal to their red
value. (Or set red and blue equal to green, or set all three to the
average of their values; each of those recipees produces a
different grayscale image.)
Bluescreen
Identify any pixel where the blue value is higher than the red
value. Turn those pixels to white (255,255,255). This filter should
be able to clear most of the background in crab.bmp.
Crop center
Crop center
Make a black or dark border around the edge of the image, only
leaving the middle visible.
Invert
Set each color to be 255 minus the original value.
Darken or lighten
Multiply the red, green and blue values each by a value. A value
between 0 and 1 will darken the image; a value > 1 will brighten
the image.
Noise
For each color of each pixel, pick a random number from -20 to
20 and add it to the color value.
Moving pixels (e.g. rotateRight)
Flip vertical or horizontal
Flip the image in one dimension or the other (left-right or
up-down).
Rotate left
Make a rotation that goes the opposite direction from the
provided rotate.
Combining pixels (e.g. blur)
Sharpen
Calculating a "blended value" that assigns negative weight to
neighboring values will emphasize differences between neighbors and
"sharpen" an image by making edges look more crisp.
For each color, multiply the current pixel's value by 5 and
neighboring pixels' values by -1. Add them all up–this is the new
value.
Using 9 for the current pixel and -2 for the neighbors makes for
a stronger effect. Just make sure the multipliers for the five
cells add to 1.
Find edges
If you do a sharpen filter but make the current pixel multiplier
value 4 instead of 5 (so that the multipliers add to 0 instead of
1), it will do a find edges type filter that shows solid areas of
color as black and areas with sharp changes as white.
8-bit look
Copy pixels that are on an even row and column into their "odd
numbered" neighbors (odd numbered rows and columns from original
are not used).
Zoom
Stretch 1/4 of the image over the entire space. To "zoom in" on
the upper left corner of the image, you would take the values from
that corner and "stretch" them so that each pixel in the original
becomes 4 pixels in the modified version:
Assignment Instructions
Submit file: main.cpp
Make two or more functions that create or modify an
existing image using the PhotoChop code. You must make your
functions from different categories listed below (for example, you
can't do two "Create New Image" functions).
Add your new functions to main.cpp, and change
the main function in that file to show them off. When you
are done, submit your main.cpp file in elearn. If you
have created or used any sample images other than the ones provided
with the codebase, you may submit them as well.
Function ideas
Here are some ideas for possible functions, but feel free to
invent your ideas or modify these suggestions.
Drawing a pattern
(e.g. makeAqua and makeGradient)
Box
Write a function that takes in parameters for starting row,
column, width, and height. It then uses those values to draw a
white box (or whatever color you like) on a black background.
Modifying an image (e.g. redShift)
Only red
Set the blue and green value for each picture to be 0.
Grayscale red
Set the blue and green values for each pixel equal to their red
value. (Or set red and blue equal to green, or set all three to the
average of their values; each of those recipees produces a
different grayscale image.)
Bluescreen
Identify any pixel where the blue value is higher than the red
value. Turn those pixels to white (255,255,255). This filter should
be able to clear most of the background in crab.bmp.
Crop center
Crop center
Make a black or dark border around the edge of the image, only
leaving the middle visible.
Invert
Set each color to be 255 minus the original value.
Darken or lighten
Multiply the red, green and blue values each by a value. A value
between 0 and 1 will darken the image; a value > 1 will brighten
the image.
Noise
For each color of each pixel, pick a random number from -20 to
20 and add it to the color value.
Moving pixels (e.g. rotateRight)
Flip vertical or horizontal
Flip the image in one dimension or the other (left-right or
up-down).
Rotate left
Make a rotation that goes the opposite direction from the
provided rotate.
Combining pixels (e.g. blur)
Sharpen
Calculating a "blended value" that assigns negative weight to
neighboring values will emphasize differences between neighbors and
"sharpen" an image by making edges look more crisp.
For each color, multiply the current pixel's value by 5 and
neighboring pixels' values by -1. Add them all up–this is the new
value.
Using 9 for the current pixel and -2 for the neighbors makes for
a stronger effect. Just make sure the multipliers for the five
cells add to 1.
Find edges
If you do a sharpen filter but make the current pixel multiplier
value 4 instead of 5 (so that the multipliers add to 0 instead of
1), it will do a find edges type filter that shows solid areas of
color as black and areas with sharp changes as white.
8-bit look
Copy pixels that are on an even row and column into their "odd
numbered" neighbors (odd numbered rows and columns from original
are not used).
Zoom
Stretch 1/4 of the image over the entire space. To "zoom in" on
the upper left corner of the image, you would take the values from
that corner and "stretch" them so that each pixel in the original
becomes 4 pixels in the modified version: