使用C++或C语言处理图像

moh*_*mad 6 c c++ image-processing

首先是我是初学者.好的?

我已经阅读了相关的答案和问题,但请帮我解决这个问题:

如何在C++中打开JPEG图像文件,将其转换为灰度图像,获取其直方图,将其调整为较小的图像,裁剪其特定区域或显示其特定区域?

对于这些任务,一般来说C或C++更快吗?

哪些库最简单,最快?运行时间非常重要.

谢谢.

ayu*_*ush 9

这是一个使用magick库的例子.

读取图像,裁剪图像并将其写入新文件的程序(异常处理是可选的,但强烈建议):

#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;
}
Run Code Online (Sandbox Code Playgroud)

在这里查看更多示例