42#include "MagickCore/studio.h"
43#include "MagickCore/cache-view.h"
44#include "MagickCore/exception.h"
45#include "MagickCore/exception-private.h"
46#include "MagickCore/image.h"
47#include "MagickCore/linked-list.h"
48#include "MagickCore/list.h"
49#include "MagickCore/memory_.h"
50#include "MagickCore/pixel-accessor.h"
51#include "MagickCore/prepress.h"
52#include "MagickCore/resource_.h"
53#include "MagickCore/registry.h"
54#include "MagickCore/semaphore.h"
55#include "MagickCore/splay-tree.h"
56#include "MagickCore/string_.h"
57#include "MagickCore/thread-private.h"
86MagickExport
double GetImageTotalInkDensity(
Image *image,
101 assert(image != (
Image *) NULL);
102 assert(image->signature == MagickCoreSignature);
103 if (IsEventLogging() != MagickFalse)
104 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
105 if (image->colorspace != CMYKColorspace)
107 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
108 "ColorSeparatedImageRequired",
"`%s'",image->filename);
112 total_ink_density=0.0;
113 image_view=AcquireVirtualCacheView(image,exception);
114#if defined(MAGICKCORE_OPENMP_SUPPORT)
115 #pragma omp parallel for schedule(static) shared(status) \
116 magick_number_threads(image,image,image->rows,1)
118 for (y=0; y < (ssize_t) image->rows; y++)
129 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
130 if (p == (
const Quantum *) NULL)
135 for (x=0; x < (ssize_t) image->columns; x++)
137 density=(double) GetPixelRed(image,p)+(double) GetPixelGreen(image,p)+
138 (double) GetPixelBlue(image,p)+(double) GetPixelBlack(image,p);
139 if (density > total_ink_density)
140#if defined(MAGICKCORE_OPENMP_SUPPORT)
141 #pragma omp critical (MagickCore_GetImageTotalInkDensity)
144 if (density > total_ink_density)
145 total_ink_density=density;
147 p+=GetPixelChannels(image);
150 image_view=DestroyCacheView(image_view);
151 if (status == MagickFalse)
152 total_ink_density=0.0;
153 return(total_ink_density);