1
$\begingroup$

I have learned that an image is to be divided by 8*8 blocks, and the 2D DCT is then applied to these blocks. My question is, what if the image is not divisible by 8? What should I do in this case?

$\endgroup$
1
$\begingroup$

Then it's size is extended by padding zeros or repeating at the end, such that the new size is divisible by 8. Note that reverse repetition at the end reduces the DCT compression size on that block compared to a zero pad approach.

For example if the image was 29 x 27 , then you should add 3 pixels at the right end and 5 lines at the bottom so that it becomes 32 x 32.

Note that you should include the pixel size of the image in the header part so that during decoding process you create the true sized image as 29 x 32

$\endgroup$
  • 1
    $\begingroup$ Good answer, but I would suggest padding the image with something better than zeros. The addition of zeros will introduce a lot more high frequency content to your image and may cause distortion if you're using DCT to compress. One alternative is to repeat the value at the edge of the image, but just see what gives you the best results. $\endgroup$ – goldrik Nov 13 '17 at 22:17
  • $\begingroup$ that's true let me add the improvement... $\endgroup$ – Fat32 Nov 13 '17 at 22:26
  • $\begingroup$ Different padding options are allowed in the standard, as mentioned in the answer to the previous question on [JPEG DCT padding ](dsp.stackexchange.com/a/35343/15892) $\endgroup$ – Laurent Duval Nov 14 '17 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.