I decided I'd attempt an image compression (From pixel RGBs) idea I had for a bit of extra credit in class. I've finished, but I find the levels of compression I get varies HUGELY from image to image. With this image, I'm getting a file size 1.25x the size of the coresponding PNG. With this image however, I'm getting a file size 22.5x the size of the PNG.
My compression works by first assigning each color in the image with an int(starting from 0), then using that int rather than the actual color in the file. The file is formatted as:
0*qj8c1*50i2p2*pg93*9zlds4*2rk5*4ok4r6*8mv1w7*2r25l8*3m89o9*9yp7c10*111*2clz112*g1j13*2w34z14*auq15*3zhg616*mmhc17*5lgsi18*25lw919*7ip84+0!0!0!0!0!0!0!0!0!0!0!0!0!1!1!1!@2!2!2!2!2!2!2!2!2!2!2!2!2!3!3!3!@4!4!4!4!4!4!4!4!4!4!4!4!4!5!5!5!@6!6!6!6!6!6!6!6!6!6!6!6!6!0!0!0!@3!3!3!3!3!3!3!3!3!3!3!3!3!2!2!2!@1!1!1!1!1!1!1!1!1!1!1!1!1!4!4!4!@7!7!7!7!7!7!7!7!7!7!7!7!7!6!6!6!@5!5!5!5!5!5!5!5!5!5!5!5!5!8!8!8!@9!9!9!9!9!9!9!9!9!9!9!9!9!10!10!10!@8!8!8!8!8!8!8!8!8!8!8!8!8!11!11!11!@12!12!12!12!12!12!12!12!12!12!12!12!12!7!7!7!@13!13!13!13!13!13!13!13!13!13!13!13!13!14!14!14!@15!15!15!15!15!15!15!15!15!15!15!15!15!16!16!16!@17!17!17!17!17!17!17!17!17!17!17!17!17!13!13!13!@18!18!18!18!18!18!18!18!18!18!18!18!18!15!15!15!@10!10!10!10!10!10!10!10!10!10!10!10!10!19!19!19!@
Where the first bit (With the *s and base36 numbers) is the dictionary defining the colors, and the second part seperated by !s is the actual image.
Why am I seeing the level of compression vary so hugely image from image? Is there a flaw in my compression algorithm?
Edit: The fact that the actual level of compression is poor compared to JPEG or PNG isn't an issue, I wasn't expecting to rival any major formats.
Thanks