使用opencv增加图像比例并最大化分辨率? [英] Increasing image scale and maximizing resolution using opencv?

查看:815
本文介绍了使用opencv增加图像比例并最大化分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始研究OpenCV,我看过一些类似的问题,但我没有找到有用的答案。我有许多像素尺寸为50宽和50高(拇指指甲尺寸)的图像。

I've just started looking into OpenCV, I've looked at some similar questions but I haven't found the answers helpful. I have a number of images with the pixel dimensions of 50 wide and 50 heigh (thumb nail size).

我对以下内容感到有些困惑:

I'm slightly confused regarding the following:

问:通过增加这些图像的比例,我会自动提高分辨率吗?或者我是否需要执行其他功能?

Q. By increasing the scale of these images, am I automatically increasing the resolution? Or do I need to be performing another function?

我必须在增加图像比例的同时获得最大分辨率。

Its essential that I get the maximum resolution possible whilst increasing the scale of the images.

我是使用以下函数:

int IncreaseScale()
{
  char *image_name {"./image/my_image.jpg"};
  cv::Mat Image;
  Image = cv::imread(image_name, 1);
  if(!Image.data)
  {
    //Cant find image
    return 0;
  }
  const float rescale_value {4.10}; 
  cv::Mat Image2;
  cv::resize(Image, Image2, cvSize(0, 0), rescale_value, rescale_value);
  return 1;
}


推荐答案

如前所述,当增加图像的大小时,使用插值是非常有限的。您使用上一分辨率的像素来猜测在增加图像分辨率时它们的值是什么。虽然图像的分辨率会更高,但质量不会更好。

As previously stated by people here, using interpolation is very limited when increasing the size of the image. You are using pixels from the previous resolution to guess on what their values are when you increase the resolution of your image. Though the image will be of higher resolution, it won't be any better in quality.

为了克服这个问题,我们提出了一种技术 超级分辨率 。这样做的想法是,当你观察一个场景时,你会看到不同视角的几个不同的图像。每张图像都提供了其他图像之前没有见过的信息略有差异。您可以确定每个视点的独特之处,然后将这些信息组合在一起,以生成质量更好的增强图像流。遗憾的是,这不适用于单个图像,因为没有从图像流中提取的附加信息。您可以然而使用相同视点的多个图像。在相机传感器处引入的噪声分布应该足以向超分辨率算法提供不同的信息,以便产生更高质量的放大图像。实际上,超分辨率的想法是拍摄几个低质量的图像,并通过将它们的信息组合成最终图像来创建高质量的结果。这个想法已经存在了一段时间,不仅与图像处理有关,而且在显微镜和科学成像的各个领域都有。

One technique that has been proposed to overcome this is the idea of super resolution. The idea of this is that when you look at a scene, you take several different images looking at different view point. Each image offers some slight differences in information that the other images have not seen before. You determine what's unique about each view point then you combine this information together to make an enhanced stream of images that are of better quality. This unfortunately does not work with a single image as there is no additional information to extract from the stream of images. You can however use multiple images of the same view point. The noise profile that is introduced at the camera sensor should be enough to provide different information to the super resolution algorithm in order to produce an upscaled image of higher quality. In fact, the idea of super resolution is to take several images that are of "low quality" and to create a high quality result by combining their information together into a final image. This idea has been around for some time, not just related to image processing but in various areas of microscopy and imaging in science.

只使用一张图像进入该区域人工创建超分辨率图像,根据图像可能会或可能不会。拥有图像流将有更高的成功概率。您可以在此处阅读有关超分辨率的更多详细信息: http://www.infognition.com/articles/ what_is_super_resolution.html

Using just a single image goes into the area of artificially creating super resolution images, which may or may not work depending on the image. Having a stream of images will have a higher probability of success. You can read more details about Super Resolution here: http://www.infognition.com/articles/what_is_super_resolution.html

幸运的是,OpenCV确实有一个实现超级分辨率的模块,它可以在超级分辨率模块。您执行需要输入一系列图像,输出将是一系列具有所需更高分辨率的更高质量的图像。

Fortunately, OpenCV does have a module that implements Super Resolution and it's found in the Super Resolution module. You do need to feed in a series of images and the output will be a series of images that are of higher quality at the desired higher resolution you want.

关于如何使用超级分辨率模块的代码示例可以在OpenCV的Github repo上找到: https://github.com/opencv/opencv/blob/master/samples/gpu/super_resolution.cpp 。不要被愚弄信息来源所在的位置。尽管它位于GPU示例下,但代码设计用于处理CPU和GPU情况,如 if 语句中所示。该代码简单地采用视频输入并具有所需的分辨率,它输出基于超分辨率的结果。

A code example on how to use the Super Resolution module can be found here on OpenCV's Github repo: https://github.com/opencv/opencv/blob/master/samples/gpu/super_resolution.cpp. Don't be fooled on where the source is located. Even though it's placed under GPU examples, the code is designed to handle both CPU and GPU cases as you can see in the if statements. The code simply takes in a video feed and with a desired resolution, it outputs a super-resolution based result.

这篇关于使用opencv增加图像比例并最大化分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆