MagickCore 6.9.13
Loading...
Searching...
No Matches
prepress.c
1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% PPPP RRRR EEEEE PPPP RRRR EEEEE SSSSS SSSSS %
7% P P R R E P P R R E SS SS %
8% PPPP RRRR EEE PPPP RRRR EEE SSS SSS %
9% P R R E P R R E SS SS %
10% P R R EEEEE P R R EEEEE SSSSS SSSSS %
11% %
12% %
13% MagickCore Prepress Methods %
14% %
15% Software Design %
16% Cristy %
17% October 2001 %
18% %
19% %
20% Copyright 1999 ImageMagick Studio LLC, a non-profit organization %
21% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% https://imagemagick.org/script/license.php %
27% %
28% Unless required by applicable law or agreed to in writing, software %
29% distributed under the License is distributed on an "AS IS" BASIS, %
30% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31% See the License for the specific language governing permissions and %
32% limitations under the License. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36%
37*/
38
39/*
40 Include declarations.
41*/
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"
58
59/*
60%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61% %
62% %
63% %
64% G e t I m a g e T o t a l I n k D e n s i t y %
65% %
66% %
67% %
68%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69%
70% GetImageTotalInkDensity() returns the total ink density for a CMYK image.
71% Total Ink Density (TID) is determined by adding the CMYK values in the
72% darkest shadow area in an image.
73%
74% The format of the GetImageTotalInkDensity method is:
75%
76% double GetImageTotalInkDensity(const Image *image)
77%
78% A description of each parameter follows:
79%
80% o image: the image.
81%
82*/
83MagickExport double GetImageTotalInkDensity(Image *image)
84{
86 *image_view;
87
88 double
89 total_ink_density;
90
92 *exception;
93
94 MagickBooleanType
95 status;
96
97 ssize_t
98 y;
99
100 assert(image != (Image *) NULL);
101 assert(image->signature == MagickCoreSignature);
102 if (IsEventLogging() != MagickFalse)
103 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
104 if (image->colorspace != CMYKColorspace)
105 {
106 (void) ThrowMagickException(&image->exception,GetMagickModule(),
107 ImageError,"ColorSeparatedImageRequired","`%s'",image->filename);
108 return(0.0);
109 }
110 status=MagickTrue;
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)
117#endif
118 for (y=0; y < (ssize_t) image->rows; y++)
119 {
120 double
121 density;
122
123 const IndexPacket
124 *indexes;
125
126 const PixelPacket
127 *p;
128
129 ssize_t
130 x;
131
132 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
133 if (p == (const PixelPacket *) NULL)
134 {
135 status=MagickFalse;
136 continue;
137 }
138 indexes=GetCacheViewVirtualIndexQueue(image_view);
139 for (x=0; x < (ssize_t) image->columns; x++)
140 {
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)
146#endif
147 {
148 if (density > total_ink_density)
149 total_ink_density=density;
150 }
151 p++;
152 }
153 }
154 image_view=DestroyCacheView(image_view);
155 if (status == MagickFalse)
156 total_ink_density=0.0;
157 return(total_ink_density);
158}