double imageMean(const char *blob, size_t size)
{
MagickWand * magick_wand = NewMagickWand();
MagickBooleanType ir =MagickFalse;
try{
ir=MagickReadImageBlob(magick_wand,blob,size);
//ir=MagickReadImage(magick_wand, filename);
}catch(...){
DestroyMagickWand(magick_wand);
return 0;
}
if (ir == MagickFalse) {
DestroyMagickWand(magick_wand);
return 0;
}
ChannelStatistics *channel_statistics;
channel_statistics = MagickGetImageChannelStatistics(magick_wand);
double scale = 1.0;
if(channel_statistics[CompositeChannels].depth < MAGICKCORE_QUANTUM_DEPTH)
scale=(double) QuantumRange/((size_t) QuantumRange >> ((size_t)
MAGICKCORE_QUANTUM_DEPTH-channel_statistics[CompositeChannels].depth));
scale = 1.0 / scale;
double mean = scale * channel_statistics[CompositeChannels].mean;
DestroyMagickWand(magick_wand);
return mean;
}
阅读(1404) | 评论(0) | 转发(0) |