0

I am very new to Java and Image Processing. I am trying to take DCT(Discrete cosine transform) of 8*8 blocks and then do quantization and later get the original image by dequantizing followed by IDCT.

But my final decoded image has green,red and blue points appearing randomly at some regions of image though over all original image content is preserved. I know this is something to do with rounding during quantization process as not using Math.round function would give me original picture correctly. I could not figure out the actual reason.You can see the difference in the Images attached

Code Snippet:

//Following gives the DCT for 3 buffers with r ,g and b values
temp_DCT_r=FormDCT(temp_DCT_r);
temp_DCT_g=FormDCT(temp_DCT_g);
temp_DCT_b=FormDCT(temp_DCT_b);

//This does the quantization to DCT values for a given
//quantization level                
PerformQuantization(temp_DCT_r,Quantization_Level);
PerformQuantization(temp_DCT_g,Quantization_Level);
PerformQuantization(temp_DCT_b,Quantization_Level);

//Following the quantization function
public static void PerformQuantization(double[][] F,int Quantization_Level) 
{
int N = 8;  

for (int u=0;u<N;u++) 
 {
    for (int v=0;v<N;v++) 
    {                       
       F[u][v]= Math.round(F[u][v]/(Math.pow(2, Quantization_Level)));

    }                
  }
}

Original Image Decoded Image

1 Answers1

0

I got the problem. Problem is in rounding off the number during quantization. When I take IDCT, there was an error. R,G and B values vary from 0 255 while DCT/IDCT has negative values. Sometimes round of results causes problem in quandrant change i.e instead of 0 round off gives -1, similarly instead of -1 round off gives 0. Identify that condition and have special handling to make it work