Work with images in C ++ or C

The first thing is that I'm new. Good?

I read related answers and questions, but please help me with this problem:

How can I open a JPEG image file in C ++, convert it to a grayscale image, get its histogram, resize it to a smaller image, crop a specific area or show a specific area?

For these tasks, most likely C or C ++?

Which libraries are the easiest and fastest? Opening hours are very important.

Thank.

+5
source share
5 answers

here is an example using 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;
}

+7

C ++, . OpenCV wiki, , ImageMagick wiki, . JPEG JPEG. , ; API , .

, C ++ , . , C ++. , ++, , - , , . ( ++, ). , ; , .

!

+2

Qt QImage ( ). , , , , .

, , ImageMagick OpenCV. OpenCV / ...

, ...

+2

libgd - .

gdImageCreateFromJpeg
gdImageCopyMergeGray
gdImageCopyResized

, C.

+1

All Articles