我正在抑制离散余弦变换 (DCT) 域中图像中几个(不相等的) block 的低直流频率。之后进行逆 DCT 以取回仅保留高频部分的图像。
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");
目标是从图像中先前检测到的区域中识别和隔离高频元素。然而,在某些情况下,文本非常细且模糊(低对比度)。在这些情况下,IDCT 产生的图像非常暗,以至于即使是高频部分也变得太微弱,无法进行进一步分析。
有哪些操作可以让我们在背景抑制后从 IDCT 中获得更清晰的图像? CvEqualizeHist()
给出了太多噪音。
编辑:
Whole picture按照 belisarius 的要求上传到这里。低频抑制不是在整个图像上进行的,而是在设置为文本/低频部分周围的最小边界矩形的小 ROI 上进行的。
最佳答案
根据您的示例图像,让我们从一种隔离文本的可能策略开始。
代码在 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
(*Appy a Gradient Filter and a Dilation*)
l = Dilation[GradientFilter[k, 1] // ImageAdjust, 5]
(*Apply a MinFilter and Binarize*)
m = Binarize[MinFilter[l, 10], .045]
(*Perform a Dilation and delete small components to get a mask*)
mask = DeleteSmallComponents@Dilation[m, 10]
(*Finally apply the mask*)
ImageMultiply[mask, Image@i]
待续...
编辑
回答评论中的问题:
GradientFilter
说明在“更多信息”下:http://reference.wolfram.com/mathematica/ref/GradientFilter.html .
MinFilter
说明在“更多信息”下:http://reference.wolfram.com/mathematica/ref/MinFilter.html
关于image-processing - 图像低频抑制后如何得到清晰的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6275206/