const double white_point,
const double gamma )
{
+ ExceptionInfo exceptionInfo;
+ GetExceptionInfo( &exceptionInfo );
modifyImage();
- (void) LevelImage( image(), black_point, white_point, gamma );
- throwImageException();
+ (void) LevelImage( image(), black_point, white_point, gamma, &exceptionInfo );
+ throwException( exceptionInfo );
+ (void) DestroyExceptionInfo( &exceptionInfo );
}
// Magnify image by integral size
if ((flags & SigmaValue) == 0)
white_point=(double) QuantumRange-black_point;
if ((flags & AspectValue ) == 0)
- status=LevelImage(image,black_point,white_point,gamma);
+ status=LevelImage(image,black_point,white_point,gamma,&image->exception);
else
status=LevelizeImage(image,black_point,white_point,gamma);
return(status);
MagickStatusType
status;
+ register ssize_t
+ i;
+
log_mean=log(0.5);
if (image->sync != MagickFalse)
{
/*
- Apply gamma correction equally accross all given channels.
+ Apply gamma correction equally across all given channels.
*/
(void) GetImageMean(image,&mean,&sans,exception);
gamma=log(mean*QuantumScale)/log_mean;
- return(LevelImage(image,0.0,(double) QuantumRange,gamma));
+ return(LevelImage(image,0.0,(double) QuantumRange,gamma,exception));
}
/*
Auto-gamma each channel separately.
*/
status=MagickTrue;
- if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
- {
- PushPixelChannelMap(image,RedChannel);
- (void) GetImageMean(image,&mean,&sans,exception);
- gamma=log(mean*QuantumScale)/log_mean;
- status=status && LevelImage(image,0.0,(double) QuantumRange,gamma);
- PopPixelChannelMap(image);
- }
- if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
- {
- PushPixelChannelMap(image,GreenChannel);
- (void) GetImageMean(image,&mean,&sans,exception);
- gamma=log(mean*QuantumScale)/log_mean;
- status=status && LevelImage(image,0.0,(double) QuantumRange,gamma);
- PopPixelChannelMap(image);
- }
- if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
- {
- PushPixelChannelMap(image,BlueChannel);
- (void) GetImageMean(image,&mean,&sans,exception);
- gamma=log(mean*QuantumScale)/log_mean;
- status=status && LevelImage(image,0.0,(double) QuantumRange,gamma);
- PopPixelChannelMap(image);
- }
- if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
- (image->colorspace == CMYKColorspace))
- {
- PushPixelChannelMap(image,BlackChannel);
- (void) GetImageMean(image,&mean,&sans,exception);
- gamma=log(mean*QuantumScale)/log_mean;
- status=status && LevelImage(image,0.0,(double) QuantumRange,gamma);
- PopPixelChannelMap(image);
- }
- if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
- (image->matte == MagickTrue))
- {
- PushPixelChannelMap(image,AlphaChannel);
- (void) GetImageMean(image,&mean,&sans,exception);
- gamma=log(mean*QuantumScale)/log_mean;
- status=status && LevelImage(image,0.0,(double) QuantumRange,gamma);
- PopPixelChannelMap(image);
- }
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ {
+ PixelTrait
+ traits;
+
+ traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+ if ((traits & UpdatePixelTrait) == 0)
+ continue;
+ PushPixelChannelMap(image,(ChannelType) i);
+ status=GetImageMean(image,&mean,&sans,exception);
+ gamma=log(mean*QuantumScale)/log_mean;
+ status&=LevelImage(image,0.0,(double) QuantumRange,gamma,exception);
+ PopPixelChannelMap(image);
+ if (status == MagickFalse)
+ break;
+ }
return(status != 0 ? MagickTrue : MagickFalse);
}
\f
%
% The format of the LevelImage method is:
%
-% MagickBooleanType LevelImage(Image *image,const char *levels)
+% MagickBooleanType LevelImage(Image *image,const double black_point,
+% const double white_point,const double gamma,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
-% o levels: Specify the levels where the black and white points have the
-% range of 0-QuantumRange, and gamma has the range 0-10 (e.g. 10x90%+2).
-% A '!' flag inverts the re-mapping.
+% o black_point: The level to map zero (black) to.
+%
+% o white_point: The level to map QuantumRange (white) to.
+%
+% o exception: return any errors or warnings in this structure.
%
*/
MagickExport MagickBooleanType LevelImage(Image *image,
- const double black_point,const double white_point,const double gamma)
+ const double black_point,const double white_point,const double gamma,
+ ExceptionInfo *exception)
{
#define LevelImageTag "Level/Image"
#define LevelQuantum(x) (ClampToQuantum((MagickRealType) QuantumRange* \
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
MagickBooleanType
status;
*/
status=MagickTrue;
progress=0;
- exception=(&image->exception);
image_view=AcquireCacheView(image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
for (x=0; x < (ssize_t) image->columns; x++)
{
if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
- SetPixelRed(image,LevelQuantum(
- GetPixelRed(image,q)),q);
+ SetPixelRed(image,LevelQuantum(GetPixelRed(image,q)),q);
if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
- SetPixelGreen(image,
- LevelQuantum(GetPixelGreen(image,q)),q);
+ SetPixelGreen(image,LevelQuantum(GetPixelGreen(image,q)),q);
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
- SetPixelBlue(image,
- LevelQuantum(GetPixelBlue(image,q)),q);
+ SetPixelBlue(image,LevelQuantum(GetPixelBlue(image,q)),q);
if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
(image->matte == MagickTrue))
- SetPixelAlpha(image,
- LevelQuantum(GetPixelAlpha(image,q)),q);
+ SetPixelAlpha(image,LevelQuantum(GetPixelAlpha(image,q)),q);
if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
(image->colorspace == CMYKColorspace))
- SetPixelBlack(image,
- LevelQuantum(GetPixelBlack(image,q)),q);
+ SetPixelBlack(image,LevelQuantum(GetPixelBlack(image,q)),q);
q+=GetPixelChannels(image);
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
%
% o black_point: The level to map zero (black) to.
%
-% o white_point: The level to map QuantiumRange (white) to.
+% o white_point: The level to map QuantumRange (white) to.
%
% o gamma: adjust gamma by this factor before mapping values.
%
if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
{
PushPixelChannelMap(image,RedChannel);
- status|=LevelImage(image,black_color->red,white_color->red,1.0);
+ status|=LevelImage(image,black_color->red,white_color->red,1.0,
+ &image->exception);
PopPixelChannelMap(image);
}
if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
{
PushPixelChannelMap(image,GreenChannel);
- status|=LevelImage(image,black_color->green,white_color->green,1.0);
+ status|=LevelImage(image,black_color->green,white_color->green,1.0,
+ &image->exception);
PopPixelChannelMap(image);
}
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
{
PushPixelChannelMap(image,BlueChannel);
- status|=LevelImage(image,black_color->blue,white_color->blue,1.0);
+ status|=LevelImage(image,black_color->blue,white_color->blue,1.0,
+ &image->exception);
PopPixelChannelMap(image);
}
if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
(image->colorspace == CMYKColorspace))
{
PushPixelChannelMap(image,BlackChannel);
- status|=LevelImage(image,black_color->black,white_color->black,1.0);
+ status|=LevelImage(image,black_color->black,white_color->black,1.0,
+ &image->exception);
PopPixelChannelMap(image);
}
if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
(image->matte == MagickTrue))
{
PushPixelChannelMap(image,AlphaChannel);
- status|=LevelImage(image,black_color->alpha,white_color->alpha,1.0);
+ status|=LevelImage(image,black_color->alpha,white_color->alpha,1.0,
+ &image->exception);
PopPixelChannelMap(image);
}
}
break;
}
histogram=(MagickRealType *) RelinquishMagickMemory(histogram);
- status=LevelImage(image,(double) black,(double) white,1.0);
+ status=LevelImage(image,(double) black,(double) white,1.0,&image->exception);
return(status);
}
\f
EqualizeImage(Image *image),
GammaImage(Image *,const double,ExceptionInfo *),
HaldClutImage(Image *,const Image *),
- LevelImage(Image *,const double,const double,const double),
+ LevelImage(Image *,const double,const double,const double,ExceptionInfo *),
LevelizeImage(Image *,const double,const double,const double),
LevelImageColors(Image *,const PixelInfo *,const PixelInfo *,
const MagickBooleanType),
min+=black;
max-=white;
if (fabs(min-max) >= MagickEpsilon)
- status&=LevelImage(image,min,max,1.0);
+ status&=LevelImage(image,min,max,1.0,exception);
return(status != 0 ? MagickTrue : MagickFalse);
}
/*
min+=black;
max-=white;
if (fabs(min-max) >= MagickEpsilon)
- status&=LevelImage(image,min,max,1.0);
+ status&=LevelImage(image,min,max,1.0,exception);
PopPixelChannelMap(image);
}
if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
min+=black;
max-=white;
if (fabs(min-max) >= MagickEpsilon)
- status&=LevelImage(image,min,max,1.0);
+ status&=LevelImage(image,min,max,1.0,exception);
PopPixelChannelMap(image);
}
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
min+=black;
max-=white;
if (fabs(min-max) >= MagickEpsilon)
- status&=LevelImage(image,min,max,1.0);
+ status&=LevelImage(image,min,max,1.0,exception);
PopPixelChannelMap(image);
}
if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
min+=black;
max-=white;
if (fabs(min-max) >= MagickEpsilon)
- status&=LevelImage(image,min,max,1.0);
+ status&=LevelImage(image,min,max,1.0,exception);
PopPixelChannelMap(image);
}
if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
min+=black;
max-=white;
if (fabs(min-max) >= MagickEpsilon)
- status&=LevelImage(image,min,max,1.0);
+ status&=LevelImage(image,min,max,1.0,exception);
PopPixelChannelMap(image);
}
return(status != 0 ? MagickTrue : MagickFalse);
/* #undef AUTOTRACE_DELEGATE */
/* Define if coders and filters are to be built as modules. */
-/* #undef BUILD_MODULES */
+#ifndef MAGICKCORE_BUILD_MODULES
+#define MAGICKCORE_BUILD_MODULES 1
+#endif
/* Define if you have the bzip2 library */
#ifndef MAGICKCORE_BZLIB_DELEGATE
#endif
/* Define if you have FFTW library */
-/* #undef FFTW_DELEGATE */
+#ifndef MAGICKCORE_FFTW_DELEGATE
+#define MAGICKCORE_FFTW_DELEGATE 1
+#endif
/* Location of filter modules */
#ifndef MAGICKCORE_FILTER_PATH
#endif
/* Define if you have the <lcms2.h> header file. */
-#ifndef MAGICKCORE_HAVE_LCMS2_H
-#define MAGICKCORE_HAVE_LCMS2_H 1
-#endif
+/* #undef HAVE_LCMS2_H */
/* Define if you have the <lcms2/lcms2.h> header file. */
/* #undef HAVE_LCMS2_LCMS2_H */
/* Define if you have the <lcms.h> header file. */
-/* #undef HAVE_LCMS_H */
+#ifndef MAGICKCORE_HAVE_LCMS_H
+#define MAGICKCORE_HAVE_LCMS_H 1
+#endif
/* Define if you have the <lcms/lcms.h> header file. */
/* #undef HAVE_LCMS_LCMS_H */
#endif
/* Define if you have JBIG library */
-/* #undef JBIG_DELEGATE */
+#ifndef MAGICKCORE_JBIG_DELEGATE
+#define MAGICKCORE_JBIG_DELEGATE 1
+#endif
/* Define if you have JPEG version 2 "Jasper" library */
#ifndef MAGICKCORE_JP2_DELEGATE
#endif
/* Define if you have LQR library */
-/* #undef LQR_DELEGATE */
+#ifndef MAGICKCORE_LQR_DELEGATE
+#define MAGICKCORE_LQR_DELEGATE 1
+#endif
/* Define if using libltdl to support dynamically loadable modules */
#ifndef MAGICKCORE_LTDL_DELEGATE
/* Define to the system default library search path. */
#ifndef MAGICKCORE_LT_DLSEARCH_PATH
-#define MAGICKCORE_LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/atlas:/usr/lib64/mysql:/usr/lib64/qt-3.3/lib:/usr/lib64/tcl8.5/tclx8.4:/usr/lib64/tcl8.5:/usr/lib/wine/:/usr/lib64/wine/:/usr/lib64/xulrunner-2"
+#define MAGICKCORE_LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/R/lib:/usr/lib64/atlas:/opt/modules/pkg/intel/f77/10.0.025/lib:/usr/local/lib:/usr/lib64/mysql:/usr/lib64/qt-3.3/lib:/usr/lib64/xulrunner-2"
#endif
/* The archive extension */
/* #undef NO_MINUS_C_MINUS_O */
/* Define if you have OPENEXR library */
-/* #undef OPENEXR_DELEGATE */
+#ifndef MAGICKCORE_OPENEXR_DELEGATE
+#define MAGICKCORE_OPENEXR_DELEGATE 1
+#endif
/* Define to the address where bug reports for this package should be sent. */
#ifndef MAGICKCORE_PACKAGE_BUGREPORT
#endif
/* Define if you have RSVG library */
-/* #undef RSVG_DELEGATE */
+#ifndef MAGICKCORE_RSVG_DELEGATE
+#define MAGICKCORE_RSVG_DELEGATE 1
+#endif
/* Define to the type of arg 1 for `select'. */
#ifndef MAGICKCORE_SELECT_TYPE_ARG1
/* Define if you have WEBP library */
-/* #undef WEBP_DELEGATE */
+#ifndef MAGICKCORE_WEBP_DELEGATE
+#define MAGICKCORE_WEBP_DELEGATE 1
+#endif
/* Define to use the Windows GDI32 library */
/* #undef WINGDI32_DELEGATE */
/* #undef WITH_DMALLOC */
/* Define if you have WMF library */
-/* #undef WMF_DELEGATE */
+#ifndef MAGICKCORE_WMF_DELEGATE
+#define MAGICKCORE_WMF_DELEGATE 1
+#endif
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
*/
#define MagickPackageName "ImageMagick"
#define MagickCopyright "Copyright (C) 1999-2011 ImageMagick Studio LLC"
-#define MagickSVNRevision "4944"
+#define MagickSVNRevision "exported"
#define MagickLibVersion 0x700
#define MagickLibVersionText "7.0.0"
#define MagickLibVersionNumber 5,0,0
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->images == (Image *) NULL)
ThrowWandException(WandError,"ContainsNoImages",wand->name);
- status=LevelImage(wand->images,black_point,white_point,gamma);
- if (status == MagickFalse)
- InheritException(wand->exception,&wand->images->exception);
+ status=LevelImage(wand->images,black_point,white_point,gamma,
+ &wand->images->exception);
return(status);
}
\f
if ((*option == '+') || ((flags & AspectValue) != 0))
(void) LevelizeImage(*image,black_point,white_point,gamma);
else
- (void) LevelImage(*image,black_point,white_point,gamma);
+ (void) LevelImage(*image,black_point,white_point,gamma,
+ exception);
InheritException(exception,&(*image)->exception);
break;
}
attribute_flag[0]=attribute_flag[5];
}
PushPixelChannelMap(image,channel);
- (void) LevelImage(image,black_point,white_point,gamma);
+ (void) LevelImage(image,black_point,white_point,gamma,exception);
PopPixelChannelMap(image);
break;
}
}
/* process image */
- LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma);
+ LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
+ &msl_info->image[n]->exception);
break;
}
}