Sir this code works very well for gray images... I tried this for color images by converting the RGB to YCbCr and then did the code for each Y, Cb, Cr separately and then combined it.... it worked without any errors .... but the i couldnt restore the color image as the input image.... please could you help me to work with the color images also.... please do reply...
Thank you Vinay for the explanation. But for lower values of m,say 4, where bpp would then be 0.5, there appears a lot more block noise than expected at that bitrate. any adjustments you might suggest?
The n indicate the pixel depth of the input image. So, for an RGB Color image, it is 24, and for a monochrome image (gray scale image), it is 8 bits. And m indicates the amount of compression that you can afford. The range of m should be [1, n]. For example, when you are computing DCT for an 8-bit image, the DCT coefficients you obtain are normalized with normalization matrix and then rounded off (normalization+rounding off = quantization). And then these Quantized coefficients are converted to binary form and NOW you have a choice whether to retain all the bits of each DCT coefficient or only some. That will be specified by the user as m.
Hi Vinay, i run the DCT code but i need more explanation on the n,m part. e.g when i run n=8,m=2, i get an error about exceeding matrix dimensions. n is also indicated as bits per pixel, but when i try a value like n= 0.5, i still get an error.
Please enlighten me on that part(n,m) and how to use then to calculate the right bit per pixel values. Otherwise thank you for the code
Dear Mehdi, the code is not generalized for Images of arbitrary sizes. So, you have to include a code for padding additional rows and columns to make row number and column number a multiple of 2. That should solve the problem. If you have any other issues, let me know.