我们如何在不失去质量的情况下在C ++中调整图像大小? [英] How we can resize image in C++ without loosing its quality ?

查看:97
本文介绍了我们如何在不失去质量的情况下在C ++中调整图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何在不失去质量的情况下调整c ++中的图像大小?我们也可以使用GFL库。我尝试过使用StretchBlt。



我尝试了什么:



我尝试使用StretchBlt,但图像质量正在下降,因为我没有得到正确的像素值我想要正确的像素值。使用GFL库我得到了但速度太慢了。任何人都可以帮忙吗?

解决方案

[无耻的自我推销]

看看我的文章:< a href =http://www.codeproject.com/Articles/22271/Plain-C-Resampling-DLL>普通C重采样DLL [ ^ ]。

[/ shameless sel-promotion]


您必须了解图像的呈现方式才能回答问题。



选择时一个用于显示的图像,它具有内在的最大分辨率,由图像的尺寸(像素)定义。



就图像质量而言,你能做的最好,将显示图像的全尺寸。这很难实现,例如,12 MP图像需要3000x4000像素的屏幕。



为了使图像适合屏幕,你将会必须只显示一些像素。例如,您可以通过仅显示每隔一个像素(即,每个方向的一半数据,即数据的3 MP)将该图片压缩到1500x2000像素屏幕上。当然,这意味着丢失了一些细节。



实际上,你可能只会显示更像是十分之一的像素每个方向(300x400)(即图像数据的第100个)。它的细节会更少。



现在,如果调整大小是图像的非整数除数,你会得到一些内部算法的如何显示的想法数据(如果你很幸运)或一些非均匀分散的选择,一些数据不太正确,或一些缺失的行/列。



所以,你的问题的答案是:一个更大的再现应该,至少,保留(或甚至增强)细节(只要你不扩展超出真实图像的尺寸)。较小的演绎将失去细节。显示数据。 。 。或者没有。


您正在寻找的是由Penelope Garcia(犯罪心理)和Abby Sciuto(NCIS)(合作作者)制作的特殊图书馆,供他们独家使用。


实际上,它不存在。否则,使用智能手机拍摄夜空的简单照片将会击败望远镜。

提高分辨率是上述同一个库的功能。 :)

How we can resize image in c++ without loosing its quality ? We can use GFL library also. I tried using StretchBlt.

What I have tried:

I tried using StretchBlt but quality of an image is losing, because of that I am not getting proper pixel value i want proper pixel value. Using GFL library I am getting that but speed is too slow. Can anyone help ?

解决方案

[shameless self-promotion]
Have a look at my article: Plain C Resampling DLL[^].
[/shameless sel-promotion]


You must understand how an image is rendered to be able to answer the question.

When you select an image for display it has it's on intrinsic maximum resolution which is defined by the image's dimension (pixels).

The very best you can do, in terms of image quality, would be to display the image at it's full size. This is rarely possible as, for example, a 12 MP image would require a screen with 3000x4000 pixels.

To fit the picture on the screen, you're going to have to show only some of the pixels. For example, you could squeeze that picture onto a 1500x2000 pixel screen by only displaying every other pixel (i.e., half the data in each direction, which is 3 MP of the data). This means, of course, that some detail is lost.

In practical terms, you'll likely only be displaying something more like on 1 in 10 of the pixels in each direction (300x400) (i.e., 100th of the image's data). It will have even less detail.

Now, should the resizing be a non-integral divisor of the image, you'll get some internal algorithm's idea of how to display the data (if you're lucky) or some non-evenly-dispersed selection, some of the data just not quite right, or some missing rows/columns.

So, the answer to your question is: a larger rendition should, at least, preserve (or even enhance) the detail (so long you don't expand beyond the real image's dimensions). A smaller rendition will lose detail. The data is either displayed . . . or not.


What you are looking for is a special library made by Penelope Garcia (Criminal Minds) and Abby Sciuto (NCIS) (co-writers) for their exclusive usage .

In reality, it does not exist. Otherwise, a simple picture of the night sky with your smartphone would beat telescopes.
Improving resolution is a functionality od the same library above. :)


这篇关于我们如何在不失去质量的情况下在C ++中调整图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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