当我在任何图像编辑软件中打开黑色背景上带有一些灰色文本的图像并放大时,我得到“像素完美”的字母放大。
我怎样才能用 opencv 得到相同的结果??
我试着用 cv::resize 来做,但结果非常模糊/不清晰。
旁注,我在这里可能错了,但在我看来,所有图像都倾向于使用 opencv 变得有点模糊/不清晰?
提前致谢!
最佳答案
来自docs你可以看到,有几种不同的插值方法可用于 cv::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
默认使用的双线性插值方法试图通过“计算”中间像素值来平滑生成的图像。根据您的要求,使用最近邻方法 (INTER_NEAREST)。它只是选择最接近新像素位置的像素值。
有关常见插值方法的简短概述,请查看 wikipedia .
关于opencv中的图像缩放/锐度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5244791/