Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get clear image after low frequency suppression of image?

I'm suppressing the low DC frequencies of several (unequal) blocks in an image in the Dicrete Cosine Transform (DCT) domain. After that doing an inverse DCT to get back the image with only the high frequency portions remaining.

  cvConvertScale( img , img_32 ); //8bit to 32bit conversion 
cvMinMaxLoc( img_32, &Min, &Max ); 
cvScale( img_32 , img_32 , 1.0/Max ); //quantization for 32bit 

cvDCT( img_32 , img_dct , CV_DXT_FORWARD ); //DCT 
//display( img_dct, "DCT");

cvSet2D(img_dct, 0,  0, cvScalar(0)); //suppress constant background

//cvConvertScale( img_dct, img_dct, -1, 255 ); //invert colors

cvDCT( img_dct , img_out , CV_DXT_INVERSE ); //IDCT
//display(img_out, "IDCT");

enter image description hereenter image description hereenter image description here

The objective is to identify and isolate elements which is present in high frequencies from previously detected regions in the image. However in several cases the text is very thin and faint (low contrast). In these cases the IDCT yeilds images which are so dark that even the high frequency portions become too faint for further analysis to work.

What manipulations are there so that we can obtain a clearer picture from the IDCT after background suppression? CvEqualizeHist() gives too much noise.

EDIT:

Whole picture uploaded here as belisarius asked. The low frequency suppression is not being done on the entire image, but on small ROI set to the smallest bounding rectangle around text/low frequency portions.

like image 253
AruniRC Avatar asked Jun 08 '11 06:06

AruniRC


1 Answers

Based on your example image, Let's start with one possible strategy to isolate the text.

The code is in Mathematica.

(* Import your image*)
i1 = Import["http://i.stack.imgur.com/hYwx8.jpg"];
i = ImageData@i1;

(*Get the red channel*)
j = i[[All, All, 1]]
(*Perform the DCT*)
t = FourierDCT[j];
(*Define a high pass filter*)
truncate[data_, f_] :=
  Module[{i, j},
   {i, j} = Floor[Dimensions[data]/Sqrt[f]];
   PadRight[Take[data, -i, -j], Dimensions[data], 0.]
   ];

(*Apply the HP filter, and do the reverse DCT*)
k = Image[FourierDCT[truncate[t, 4], 3]] // ImageAdjust

enter image description here

(*Appy a Gradient Filter and a Dilation*)
l = Dilation[GradientFilter[k, 1] // ImageAdjust, 5]

enter image description here

(*Apply a MinFilter and Binarize*)
m = Binarize[MinFilter[l, 10], .045]

enter image description here

(*Perform a Dilation and delete small components to get a mask*)
mask = DeleteSmallComponents@Dilation[m, 10]

enter image description here

(*Finally apply the mask*)
ImageMultiply[mask, Image@i]

enter image description here

To be continued ...

Edit

Answering questions in comments:

The GradientFilter description is under "more information" here: http://reference.wolfram.com/mathematica/ref/GradientFilter.html.

The MinFilter description is under "more information" here: http://reference.wolfram.com/mathematica/ref/MinFilter.html

like image 93
Dr. belisarius Avatar answered Nov 15 '22 10:11

Dr. belisarius