Wavelets - lscott1994/PythonPracticum GitHub Wiki
SamplePPM.py SamplePPM.py produces a sampled image by reading in all the rgb values for a PPM image. Then it finds the average for each rgb value horizontally (that is, a pixel is averaged with its neighbor). After the values have been averaged "horizontally", the values are averaged again, but vertically (that is, values are averaged with a value one row down). This generates an image half the size as the original PPM.
BoxAvg.py BoxAvg.py is loosely based off of the box blur (which I've implemented and also uploaded, as I apparently have a hard time differentiating averaging/sampling and blurring and wrote the program before realizing blur != sample. Nice!). Anyways, the program just averages each value twice. It reads in a PPM and adds the rgb values to a list. Instead of averaging its neighboring index, each value is averaged with the value to the left, the value to the right, and the values immediately above and below (in terms of rows) said value. The sampled image generated is a quarter the size of the originally PPM.
Comparison
The two programs are very similar. Aside from from the size of the sampled image, the main differences between the two programs are how thee actual averaging is implemented. In the SamplePPM.py, I was not as efficient as I could have been. Instead of averaging horizontally, then vertically, I could have done this all in one step. This is basically what I do in the BoxAvg.py program, where it averages 5 samples at once, since I used a 2D array instead of one list (in short, it was way easier for me to 'see' what I was doing with a 2D array with 'columns' and 'row's instead of one long list).
There are the two samples (SamplePPM's sample, then the BoxAvg sample). (For reference, I zoomed in on the image so they could be seen easier, they're not actually the same size).

RLE.py RLE.py contains functions to convert a PPM to an RLE, and to convert an RLE back to a PPM (I know it's supposed to be RWV-n, but I wasn't able to implement in time). To compress a PPM to an RLE, the program reads in a PPM and adds it to a list. The program iterates through the list and compares an index value [currentValue] to its next index value [currentValue+1]. If they have the same value, then the count goes up and currentValue = currentValue + 1. When the currentValue does not match the value of currentValue+1, then the count of currentValue and the value of currentValue are added to a list. This is repeated until the end of the image file. To decode the RLE, the program reads in the RLE list. Then it simply iterates through the list, appending the value in that list for x amount of times, where x is the value of count in the list. Once done, the image is formatted and written.