prepress.c

Go to the documentation of this file.
00001 /*
00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00003 %                                                                             %
00004 %                                                                             %
00005 %                                                                             %
00006 %           PPPP    RRRR    EEEEE  PPPP   RRRR   EEEEE  SSSSS  SSSSS          %
00007 %           P   P   R   R   E      P   P  R   R  E      SS     SS             %
00008 %           PPPP    RRRR    EEE    PPPP   RRRR   EEE     SSS    SSS           %
00009 %           P       R R     E      P      R R    E         SS     SS          %
00010 %           P       R  R    EEEEE  P      R  R   EEEEE  SSSSS  SSSSS          %
00011 %                                                                             %
00012 %                                                                             %
00013 %                         MagickCore Prepress Methods                         %
00014 %                                                                             %
00015 %                              Software Design                                %
00016 %                                John Cristy                                  %
00017 %                                October 2001                                 %
00018 %                                                                             %
00019 %                                                                             %
00020 %  Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization      %
00021 %  dedicated to making software imaging solutions freely available.           %
00022 %                                                                             %
00023 %  You may not use this file except in compliance with the License.  You may  %
00024 %  obtain a copy of the License at                                            %
00025 %                                                                             %
00026 %    http://www.imagemagick.org/script/license.php                            %
00027 %                                                                             %
00028 %  Unless required by applicable law or agreed to in writing, software        %
00029 %  distributed under the License is distributed on an "AS IS" BASIS,          %
00030 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
00031 %  See the License for the specific language governing permissions and        %
00032 %  limitations under the License.                                             %
00033 %                                                                             %
00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00035 %
00036 %
00037 */
00038 
00039 /*
00040   Include declarations.
00041 */
00042 #include "magick/studio.h"
00043 #include "magick/cache-view.h"
00044 #include "magick/exception.h"
00045 #include "magick/exception-private.h"
00046 #include "magick/hashmap.h"
00047 #include "magick/image.h"
00048 #include "magick/list.h"
00049 #include "magick/memory_.h"
00050 #include "magick/prepress.h"
00051 #include "magick/registry.h"
00052 #include "magick/semaphore.h"
00053 #include "magick/splay-tree.h"
00054 #include "magick/string_.h"
00055 
00056 /*
00057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00058 %                                                                             %
00059 %                                                                             %
00060 %                                                                             %
00061 %   G e t I m a g e T o t a l I n k D e n s i t y                             %
00062 %                                                                             %
00063 %                                                                             %
00064 %                                                                             %
00065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00066 %
00067 %  GetImageTotalInkDensity() returns the total ink density for a CMYK image.
00068 %  Total Ink Density (TID) is determined by adding the CMYK values in the
00069 %  darkest shadow area in an image.
00070 %
00071 %  The format of the GetImageTotalInkDensity method is:
00072 %
00073 %      double GetImageTotalInkDensity(const Image *image)
00074 %
00075 %  A description of each parameter follows:
00076 %
00077 %    o image: the image.
00078 %
00079 */
00080 MagickExport double GetImageTotalInkDensity(Image *image)
00081 {
00082   double
00083     total_ink_density;
00084 
00085   ExceptionInfo
00086     *exception;
00087 
00088   long
00089     y;
00090 
00091   MagickBooleanType
00092     status;
00093 
00094   CacheView
00095     *image_view;
00096 
00097   assert(image != (Image *) NULL);
00098   if (image->debug != MagickFalse)
00099     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
00100   assert(image->signature == MagickSignature);
00101   if (image->colorspace != CMYKColorspace)
00102     {
00103       (void) ThrowMagickException(&image->exception,GetMagickModule(),
00104         ImageError,"ColorSeparatedImageRequired","`%s'",image->filename);
00105       return(0.0);
00106     }
00107   status=MagickTrue;
00108   total_ink_density=0.0;
00109   exception=(&image->exception);
00110   image_view=AcquireCacheView(image);
00111 #if defined(MAGICKCORE_OPENMP_SUPPORT)
00112   #pragma omp parallel for schedule(dynamic,4) shared(status)
00113 #endif
00114   for (y=0; y < (long) image->rows; y++)
00115   {
00116     double
00117       density;
00118 
00119     register const IndexPacket
00120       *indexes;
00121 
00122     register const PixelPacket
00123       *p;
00124 
00125     register long
00126       x;
00127 
00128     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
00129     if (p == (const PixelPacket *) NULL)
00130       {
00131         status=MagickFalse;
00132         continue;
00133       }
00134     indexes=GetCacheViewVirtualIndexQueue(image_view);
00135     for (x=0; x < (long) image->columns; x++)
00136     {
00137       density=(double) p->red+p->green+p->blue+indexes[x];
00138       if (density > total_ink_density)
00139 #if defined(MAGICKCORE_OPENMP_SUPPORT)
00140   #pragma omp critical (MagickCore_GetImageTotalInkDensity)
00141 #endif
00142         {
00143           if (density > total_ink_density)
00144             total_ink_density=density;
00145         }
00146       p++;
00147     }
00148   }
00149   image_view=DestroyCacheView(image_view);
00150   if (status == MagickFalse)
00151     total_ink_density=0.0;
00152   return(total_ink_density);
00153 }

Generated on 19 Nov 2009 for MagickCore by  doxygen 1.6.1