Misc #6 - RGB Pixel Shifter Program in C++

For my glitch project I have written a program in C++ that would allow me to switch the rgb values of the image, creating really cool glitches. 

I started off with my program being able to do vertical flip, transpose and grayscale to the image. Than, I took this code and changed it so when the user is applying these transformations to the image the pixel's R G B values do not correspond to what they should. 

Our image must first be in the format of ppm, for this to work. PPM is a portable pixmap format, that allows us to use the pixels. The first line of pixels is called the header file where the size of the height width and the maximum color of the pixel are indicated. Every pixel after that is stored in a 2D dimensional array you can think of it as a matrix. 

This function grey_scale's original purpose was to average every pixel's color to form a grayscale image. It traverses through the matrix of pixels and transforms each individual's pixel's r g b value to something different. 

The blue text indicates the original code to grayscale an image and the red text shows the changes.
The next thing I changed was the pixels in the vertical flip. What the vertical flip does is that it takes the image and flips it upside down. 
For the changes you can see that I disarranged the rgb values so that they were in different positions. What this does is that when it flips the colours associated with the bottom row pixels would differ than what they were intended for. 

My final command that I ran was   -g  -t  -t -v -v -g  -t -t -g  -g -g -g -g -g. Where -g = grayscale, t = transpose and v = vertical flip. By repeating the commands like -g over again it acts as a recursive process where the changed pixels are sent again to get further distorted and you can get some really cool glitches. 

You can see the rest of the code on my Github, along with the instructions on how to run it.

Comments