So we started working with ppm images. What is a ppm image file? It's fairly simple - an identifier (for a ppm, it's either a "P3" or "P6" on its own line) followed by some comments (all of which are preceded by a "#") followed by the width and height of the image, the maximum color attribute value, and then three values which give the red, green, and blue attributes for each pixel (in P3 it's given in ASCII; in P6 it's given in binary in B-R-G order). Having that brief intro, it's on to:
We were supposed to write one interesting filter, but I lost count and wrote five. What? You thought I was good at math? Oh well. Click a link below to go the description for each of the filters.
Yeah, okay, I wrote something else to demonstrate my filters for more than just cows. You can see it, but READ THE WARNING FIRST. So with that in mind, click here to get really crazy, Supercomp-style.
![]() |
This was pretty simple: if a pixel has RGB values of (creativity alert!) R, G, and B; replace them with (255-R), (255-G), and (255-B). | ![]() |
![]() |
This is modified thresholding. If a value is less than 1/4 the maximum, set it to 0; if a value is greater than 3/4 the maximum, set it to the maximum; otherwise, set it to half of the maximum. Repeat on all three attributes for and on all pixels. | ![]() |
![]() |
For each attribute of each pixel (x,y) with a given radius r, average the corresponding attributes for each existing pixel from (x-r,y-r) to (x+r,y+r). | ![]() |
![]() |
Given a factor S (preferably between 0 and 1), use the following formula: newpixel(x,y) = [newpixel(x-1,y)+S*oldpixel(x,y)]/[1+S]. By taking into account the pixels to the left by a steadily decreasing factor, it creates a sort of smear effect. To even it out, the filter then does the same thing but proceeds right-to-left instead of left-to-right again. | ![]() |
![]() |
My favorite, but the most complicated (perhaps that's why?). For each pixel, look to the left. Divide the current pixel's red value by that pixel's red value, and if this ratio is between (1+R)-1 and (1+R), add 1/12 the maximum color value to each of the red, green, and blue attributes of the new pixel (initialized to 0). Repeat for the green and blue attributes; then do the same for the pixels up, down, and to the right. | ![]() |
Enough of that; go back to the top if you wish. If you don't wish, maybe you'd like to see my image filter code. Still no? Onward to My Use of the Filter in OpenGL, or Adventures on Bovine Mountain.