View Full Version : Trying to implement custom matrices in jpeg encoder


ReferenceDivx
8th October 2002, 02:35
I've been working on some code for the last 6 hours, but have been unable to get it working properly. I found some code that take a raw image in and outputs a jpeg image. I've looked through a lot of the functions such as levelshift, dct, quantization, and huffman encoding. However, I just can't seem to get it working.

I didn't write the code. However, it is quite interesting. I want to to do somthing cool things with the code if I can ever get it to work. Oh, if you know of another implementation of a jpeg coder, you could also give me a link to that too.

http://www.hvsmetrics.com/encoder.zip //this is the encoder

I also found a book on the internet that has source with it on jpeg encoding, however I couldn't find the source.
http://www.colosseumbuilders.com/imageformats/compressedimageformats.htm


thanks

ReferenceDivx
9th October 2002, 00:35
I finally got it to work. After about 10 hours of hacking the code. I finally realized that the function in the program rgb to yuv actually "DOES NOTHING" argh. It has a few problems i see though. First, the image looks lighter than the actual image. Second if i adjust the image setting, the picture gets shifted to the left or right and wraps around to the other side.

When i get the code working better I'll post it so that other people can see some compression code.

ReferenceDivx
9th October 2002, 07:45
Is this a correct formula to convert from RGB to YUV

Y = ((77 * R + 150 * G + 29 * B) >> 8);
Cb = ((-43 * R - 85 * G + 128 * B) >> 8) + 128;
Cr = ((128 * R - 107 * G - 21 * B) >> 8) + 128;

the encode images aren't as dark as the original.