Question

i want to make an image scrambling using DCT in matlab. i used a grayscale image. i want to random dc with random value. how to set the DC coefficient of each block to a random value 0-255 and leave all others??these are steps for experiment:Divide a gray image into 8x8 blocks;Perform DCT on each block;set the DC coefficient of each block to a random value 0-255 and leave all others;Perform inverse DCT and restore the image;Compare the restored image with the original one by SSIM. thank you

Was it helpful?

Solution

The question is "how to set the DC coefficient of each block to a (given) value...". So the procedure you mention (DCT, set DC coefficient, then iDCT) should work. You would use Matlab's dct2 and idct2 functions.

However, from the DCT definition, the DC coefficient is the sum of the values of the pixels in each of your blocks; setting it to a random value and taking the inverse transform will produce a block that would be different from the original one only by a constant. That's no surprise because you are just changing the DC level. So you could skip the DCT/iDCT and directly add or subtract a random value to all pixels in each block.

But you can see that each block would look like the original one, except for a different luminosity; also, the boundaries between blocks would be quite visible, so the scrambling method could be easily reversed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top