GetPixels converts an image to a text file of grayscale pixel values and reconstructs the image. I wrote it so I could manipulate the value of an image’s pixels using convolution kernels and easily look at the results.
Find the code at GitHub.
GetPixels is open source software licensed under the Creative Commons Attribution-ShareAlike International license. That means you can share and adapt the work for any purpose as long as you give me credit and share your work alike.
./GetPixels.o <op> <image.png> <pixels.txt> <width> <height>
op is the desired operation. Use ‘1’ for image->pixels and ‘2’ for pixels->image.
image.png is the relative file path to the image and
pixels.txt is the text file.
width are the values in pixels of the image.
I used OpenCV 2.4.8 and g++ to compile on Linux Mint 15 (Olivia).
The program will alert you if the height or width is less than 1, if the input image or input pixel file don’t exist, or if the operation chosen is not 1 or 2.
Note: The output files will be created and overwrite any existing files without prompting!
If you give the program a portrait of dimensions 240x320 but you tell the program it’s a landscape of dimensions 320x240, you’ll get a broken reconstruction: