42#include "magick/studio.h"
43#include "magick/cache-view.h"
44#include "magick/exception.h"
45#include "magick/exception-private.h"
46#include "magick/hashmap.h"
47#include "magick/image.h"
48#include "magick/list.h"
49#include "magick/memory_.h"
50#include "magick/pixel-accessor.h"
51#include "magick/prepress.h"
52#include "magick/registry.h"
53#include "magick/resource_.h"
54#include "magick/semaphore.h"
55#include "magick/splay-tree.h"
56#include "magick/string_.h"
57#include "magick/thread-private.h"
83MagickExport
double GetImageTotalInkDensity(
Image *image)
100 assert(image != (
Image *) NULL);
101 assert(image->signature == MagickCoreSignature);
102 if (IsEventLogging() != MagickFalse)
103 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
104 if (image->colorspace != CMYKColorspace)
106 (void) ThrowMagickException(&image->exception,GetMagickModule(),
107 ImageError,
"ColorSeparatedImageRequired",
"`%s'",image->filename);
111 total_ink_density=0.0;
112 exception=(&image->exception);
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,2)
118 for (y=0; y < (ssize_t) image->rows; y++)
132 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
138 indexes=GetCacheViewVirtualIndexQueue(image_view);
139 for (x=0; x < (ssize_t) image->columns; x++)
141 density=(double) GetPixelRed(p)+(double) GetPixelGreen(p)+
142 (double) GetPixelBlue(p)+(double) GetPixelIndex(indexes+x);
143 if (density > total_ink_density)
144#if defined(MAGICKCORE_OPENMP_SUPPORT)
145 #pragma omp critical (MagickCore_GetImageTotalInkDensity)
148 if (density > total_ink_density)
149 total_ink_density=density;
154 image_view=DestroyCacheView(image_view);
155 if (status == MagickFalse)
156 total_ink_density=0.0;
157 return(total_ink_density);