This is a python image coder-decoder using the LHE algorithm. It will codify chrominance and/or luminance hops, and will use Huffman coding to represent them as symbols.
You can check a more detailed project in C here: https://github.com/magonzalezc/LHE
You can learn more about LHE in this article: http://oa.upm.es/37459/1/INVE_MEM_2014_200038.pdf
This codec works with the YUV color model, and can use 3 alternatives of it: yuv420, yuv422 and, less frequent, yuv444. From now on, we'll call that choice the chrominance mode. A more detailed description of what YUV is and what are the differences between alternatives can be found in the html file (description.html) with the general description of the program.
Also, you can learn more about those alternatives here: https://en.wikipedia.org/wiki/Chroma_subsampling
-
Install Python 2.7 and the IDLE Editor if you dont have them in your computer.
-
Now we need to install two modules: numpy and pillow. Pillow is an improved version of the module PIL (contained in it), which works with images (opening, loading, getting RGB values, etc). Open a command prompt (cmd), go to the path you installed Python and type:
pip install numpy
pip install pillow
- Open the IDLE editor with example.py and execute it with the F5 key or the Run menu.
-
Install Python 2.7 if you dont have it in your computer.
-
Open a new terminal and type:
sudo apt-get install python-pip
sudo pip install numpy
sudo pip install pillow
- Go to the path where example.py is and execute it with the command:
python example.py
The example program ("example.py") will ask you what do you want to do. Type enc for encoding or dec for decoding. You can also type exit to close the program.
Once you selected encoding, the program will ask you the chrominance mode you want and the image you want to work with. This codec only works with images which are saved in the input_img folder, be sure to save and select one from there. You will know when the program succesfully finishes the encoding.
The program wont ask you anything if you select decoding. You must have a .lhe file in the output_lhe folder (generated by the encoder) and it will create the image in the output_img folder. If you want to decode an external .lhe file, be sure to rename it to lhe_file.lhe and save it in the output_lhe folder. You will know when the program succesfully finishes the decoding.
Note: Please, dont try to decode without encoding first, since it will close the program ^.^