Image statistics - need help

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
TheWho
Posts: 2
Joined: 2013-03-09T12:27:44-07:00
Authentication code: 6789

Image statistics - need help

Post by TheWho »

Hey guys,
I was trying to get image statistics using MagickWand but I get wrong results. Obviously I'm doing something wrong, but I can't figure out what. I'm reading JPEG file. My code is as follows:

Code: Select all

  MagickBooleanType status;
  MagickWand  *magick_wand;
  ChannelStatistics *chan_stat;
  double mean_red, std_red;

  /*
    Read an image.
  */
  MagickWandGenesis();
  magick_wand=NewMagickWand();
  status=MagickReadImage(magick_wand,pFilename);
  if (status == MagickFalse)
    ThrowWandException(magick_wand);

  /*
   Get stats
  */
 chan_stat=MagickGetImageChannelStatistics(magick_wand);
  mean_red=chan_stat[RedChannel].mean;

 /*
    Close session
  */
  magick_wand=DestroyMagickWand(magick_wand);
  MagickWandTerminus();
Seems that chan_stat structure is not being initialized, since the figures are garbage. When I run command line 'identify -verbose' all numbers are ok. Any advice?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Image statistics - need help

Post by el_supremo »

At the moment I can't see anything wrong with the code except that when you are done you should free up the channel statistics:

Code: Select all

    MagickRelinquishMemory(chan_stat);
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Image statistics - need help

Post by el_supremo »

Show us some of the statistics you get when you use the builtin logo: image.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Post Reply