Quote:Original post by Formski
When I set QuantizeValue to 1, there is no issue with the resultant output image. When I set QuantizeValue to 100 there is significant lines between each block. I'm guessing that it is related to the Wavelet transform on the border coefficients, but I'm at a bit of a loss on it.
Formski
I believe it's an off-by-one error.
for (n=0;2*n+3<N;n++)
This looks like a single pass across entire block. But when calculating the coefficients you don't take into account that although your image data is continuous, image itself isn't, and is composed of scanlines.
This means that right-most pixels will be calculated as difference between right-most and left-most-of-next-row pixels.
If you still choose to go with 256x256 initial blocks, then you'll need to handle edge cases specifically, either by padding an extra pixel to right and bottom, or by stopping one row and one column early.
Still, you could probably just feed your original image into compressor without breaking it up first. They you could just pad the up to nearest multiple of two, or terminate your pass early. This doesn't solve problem as such, but allows you a more uniform approach, the algorithm doesn't care about initial size.