Image statistics - need help
Posted: 2013-03-23T06:36:44-07:00
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:
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?
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();