gpt4 book ai didi

image-processing - OpenCV 图像处理

转载 作者:太空宇宙 更新时间:2023-11-03 21:37:55 26 4
gpt4 key购买 nike

我有一张图片,我想放大并查看高细节。它的大小不明,大部分是黑白相间的,上面有一些文字。当我放大时,文本变得不可读,我认为这是因为没有足够的像素/纹素来显示,所以我将图像放大了 2 倍。现在我已经缩放了它,它仍然不可读。

然后我开始使用 OpenCV:

void resizeFirst(){
Mat src = imread( "../floor.png", 1 );
Mat tmp;
resize(src,tmp,Size(),3,3,INTER_CUBIC);
Mat dst = tmp.clone();
Size s(3,3);
//blur( tmp, dst, s, Point(-1,-1) );//homogeneous
GaussianBlur(tmp, dst, s, 3);//gaussian
//medianBlur ( tmp, dst, 5 );//median
//bilateralFilter ( tmp, dst, 5, 5*2, 5/2 );
addWeighted(tmp, 1.5, dst, -0.5, 0, dst);
imwrite("sharpenedImage.png",dst);
}

void blurFirst(){
Mat src = imread( "../floor.png", 1 );
Size s(3,3);
Mat dst;
GaussianBlur(src, dst, s, 3);//gaussian
addWeighted(src, 2, dst, -1, 0, dst);
Mat tmp;
resize(dst,tmp,Size(),3,3,INTER_CUBIC);
imwrite("sharpenedImage0.png",tmp);
}

输出更好,但图像仍然不清晰。有没有人对如何在放大图像时保持文本清晰有任何想法?

编辑:下面是示例图片。

Original Image

Enhanced Image

第一个是较小的原始分辨率,第二个我调整大小并尝试按照下面的方式进行高斯锐化

最佳答案

Resize函数提供了不同的插值方法

INTER_NEAREST nearest-neighbor interpolation
INTER_LINEAR bilinear interpolation (used by default)
INTER_AREA resampling using pixel area relation. It may be the preferred method for image decimation, as it gives moire-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method
INTER_CUBIC bicubic interpolation over 4x4 pixel neighborhood
INTER_LANCZOS4 Lanczos interpolation over 8x8 pixel neighborhood

尝试所有插值方法并使用最适合您的方法。但是,调整大小功能会改变图像的纵横比。

关于image-processing - OpenCV 图像处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14422593/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com