2
$\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$
2

1 Answer 1

2
$\begingroup$

Then its 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 the decoding process you create the true sized image as 29 x 27.

$\endgroup$
2
  • 2
    $\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, 2017 at 22:17
  • 2
    $\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$ Nov 14, 2017 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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