首先,我是一个初学者。好的?
我已阅读相关答案和问题,但请帮助我解决这个问题:
如何在 C++ 中打开 JPEG 图像文件,将其转换为灰度图像,获取其直方图,将其调整为较小的图像,裁剪其特定区域,或显示其特定区域?
对于这些任务,一般来说 C 还是 C++ 更快?
什么库是最简单和最快的?运行时间非常重要。
Thanks.
这是一个使用的示例magick http://www.imagemagick.org/script/index.php图书馆。
读取图像、裁剪图像并将其写入新文件的程序(异常处理是可选的,但强烈建议):
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
int main(int argc,char **argv)
{
// Construct the image object. Seperating image construction from the
// the read operation ensures that a failure to read the image file
// doesn't render the image object useless.
Image image;
try {
// Read a file into image object
image.read( "girl.jpeg" );
// Crop the image to specified size (width, height, xOffset, yOffset)
image.crop( Geometry(100,100, 100, 100) );
// Write the image to a file
image.write( "x.jpeg" );
}
catch( Exception &error_ )
{
cout << "Caught exception: " << error_.what() << endl;
return 1;
}
return 0;
}
在这里查看更多示例 http://www.imagemagick.org/Magick++/Image.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)