Question
Image Decoder C++ Problem Program Input Enter image name: The user will always enter a png image with the phrase Puzzle.png at the end. The
Image Decoder C++ Problem
Program Input Enter image name:
The user will always enter a png image with the phrase Puzzle.png at the end. The images will be square with an even number of rows and columns.
Program Outputs Corrected image saved to XXX
Replace the word Puzzle with Fixed in the original name, saving the new image to file Assignment Details
A digital image is essentially a multidimensional collection of pixels, which are the smallest components of the image. Think of an image as a closely-packed grid of dots that each have their own color, represented using the RGB format: Red-Green-Blue. By combining thousands or millions of these pixels, we can create rich digital images! Your goal for this assignment is to solve different image puzzles by implementing a pixel decoding algorithm. For each puzzle, a real image was taken and the pixels scrambled to hide the true image. Check out the following example for the Statue of Liberty:
Figure 1: Statue of Liberty image scrambled by lowering the blue and green pixel values.
Sample Output
After applying the pixel decoding algorithm, you should get a recognizable image back (Note that the colors of the image will no longer be perfect due to the algorithm).
Test Case 1:
Enter image name: Alpha_Puzzle.png Corrected image saved to Alpha_Fixed.png
Test Case 2:
Enter image name: Bravo_Puzzle.png Corrected image saved to Bravo_Fixed.png
Test Case 3:
Enter image name: Charlie_Puzzle.png Corrected image saved to Charlie_Fixed.png
Pixel Decoding Algorithm
Use the following steps to solve the puzzle:
Create a blank image of the same size as the image puzzle Go to every row and column location in the image and do the following:
Move pixels from the image puzzle to a new row and column location in the blank image:
If at an odd row index, use the formula: new row = (row 1)/2
If at an even row index, use the formula: new row = row/2 + (image height)/2
If at an a col in the left half, use the formula: new col = (image width)/21col
If at an a col in the right half, use the formula: new col = 3(image width)/2 1col
Fix the colors in the image: Multiply all the red and blue pixel values by 3
Set all the green pixel values to 0 Rearrange the image:
The image has been split into 4 quadrants based on the two diagonals through the middle of the image
Fix the quadrants by swapping the top and bottom quadrants Save the fixed image to a file where the word Puzzle has been replaced by Fixed
Useful image commands
Feel free to use the following image commands to help with the homework! Check any online C++ help or the class notes for more information on using each command:
#include png.hpp - new header for access to image information using namespace png; - new namespace for access to image functions/routines imagergb pixel - data type for color images .get width() - returns the width of the image .get height() - returns the height of the image .write() - saves your image to your computer in the Debug folder values
Alpha Image
Bravo Image
Charlie Image
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started