#include "MagickCore/monitor.h"
#include "MagickCore/monitor-private.h"
#include "MagickCore/option.h"
+#include "MagickCore/pixel.h"
#include "MagickCore/pixel-accessor.h"
#include "MagickCore/quantum.h"
#include "MagickCore/quantum-private.h"
*clut_view,
*image_view;
- double
- *clut_map;
-
MagickBooleanType
status;
MagickOffsetType
progress;
+ PixelInfo
+ *clut_map;
+
register ssize_t
- x;
+ i;
- ssize_t
- adjust,
+ ssize_t adjust,
y;
assert(image != (Image *) NULL);
return(MagickFalse);
if (IsGrayColorspace(image->colorspace) != MagickFalse)
(void) TransformImageColorspace(image,sRGBColorspace,exception);
- clut_map=(double *) AcquireQuantumMemory(MaxMap+1UL,GetPixelChannels(image)*
- sizeof(*clut_map));
- if (clut_map == (double *) NULL)
+ clut_map=(PixelInfo *) AcquireQuantumMemory(MaxMap+1UL,sizeof(*clut_map));
+ if (clut_map == (PixelInfo *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
/*
status=MagickTrue;
progress=0;
adjust=(ssize_t) (clut_image->interpolate == IntegerInterpolatePixel ? 0 : 1);
- clut_view=AcquireCacheView(clut_image);
+ clut_view=AcquireVirtualCacheView(clut_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4)
#endif
- for (x=0; x <= (ssize_t) MaxMap; x++)
+ for (i=0; i <= (ssize_t) MaxMap; i++)
{
- register ssize_t
- i;
-
- for (i=0; i < (ssize_t) GetPixelChannels(clut_image); i++)
- (void) InterpolatePixelChannel(clut_image,clut_view,(PixelChannel) i,
- method,QuantumScale*x*(clut_image->columns-adjust),QuantumScale*x*
- (clut_image->rows-adjust),clut_map+x*GetPixelChannels(clut_image)+i,
- exception);
+ GetPixelInfo(clut_image,clut_map+i);
+ (void) InterpolatePixelInfo(clut_image,clut_view,method,
+ QuantumScale*i*(clut_image->columns-adjust),QuantumScale*i*
+ (clut_image->rows-adjust),clut_map+i,exception);
}
clut_view=DestroyCacheView(clut_view);
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
+ PixelInfo
+ pixel;
+
register Quantum
*restrict q;
status=MagickFalse;
continue;
}
+ GetPixelInfo(image,&pixel);
for (x=0; x < (ssize_t) image->columns; x++)
{
- register ssize_t
- i;
-
if (GetPixelMask(image,q) != 0)
{
q+=GetPixelChannels(image);
continue;
}
- for (i=0; i < (ssize_t) GetPixelChannels(clut_image); i++)
- {
- PixelChannel
- channel;
-
- PixelTrait
- clut_traits,
- traits;
-
- channel=GetPixelChannelMapChannel(clut_image,i);
- clut_traits=GetPixelChannelMapTraits(clut_image,channel);
- traits=GetPixelChannelMapTraits(clut_image,channel);
- if ((traits == UndefinedPixelTrait) ||
- (clut_traits == UndefinedPixelTrait) ||
- ((traits & UpdatePixelTrait) == 0))
- continue;
- SetPixelChannel(clut_image,channel,ClampToQuantum(clut_map[
- ScaleQuantumToMap(GetPixelChannel(clut_image,channel,q))*
- GetPixelChannels(clut_image)+channel]),q);
- }
+ GetPixelInfoPixel(image,q,&pixel);
+ pixel.red=clut_map[ScaleQuantumToMap(pixel.red)].red;
+ pixel.green=clut_map[ScaleQuantumToMap(pixel.green)].green;
+ pixel.blue=clut_map[ScaleQuantumToMap(pixel.blue)].blue;
+ pixel.black=clut_map[ScaleQuantumToMap(pixel.black)].black;
+ pixel.alpha=clut_map[ScaleQuantumToMap(pixel.alpha)].alpha;
+ SetPixelInfoPixel(image,&pixel,q);
q+=GetPixelChannels(image);
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
}
}
image_view=DestroyCacheView(image_view);
- clut_map=(double *) RelinquishMagickMemory(clut_map);
+ clut_map=(PixelInfo *) RelinquishMagickMemory(clut_map);
if ((clut_image->matte != MagickFalse) &&
((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0))
(void) SetImageAlphaChannel(image,ActivateAlphaChannel,exception);
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ContrastStretchImage() is a simple image enhancement technique that attempts
-% to improve the contrast in an image by `stretching' the range of intensity
+% to improve the contrast in an image by 'stretching' the range of intensity
% values it contains to span a desired range of values. It differs from the
% more sophisticated histogram equalization in that it can only apply a
% linear scaling function to the image pixel values. As a result the
-% `enhancement' is less harsh.
+% 'enhancement' is less harsh.
%
% The format of the ContrastStretchImage method is:
%
status=MagickTrue;
(void) ResetMagickMemory(histogram,0,(MaxMap+1)*GetPixelChannels(image)*
sizeof(*histogram));
- image_view=AcquireCacheView(image);
+ image_view=AcquireVirtualCacheView(image,exception);
for (y=0; y < (ssize_t) image->rows; y++)
{
register const Quantum
p+=GetPixelChannels(image);
}
}
+ image_view=DestroyCacheView(image_view);
/*
Find the histogram boundaries by locating the black/white levels.
*/
*/
status=MagickTrue;
progress=0;
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
- enhance_view=AcquireCacheView(enhance_image);
+ image_view=AcquireVirtualCacheView(image,exception);
+ enhance_view=AcquireAuthenticCacheView(enhance_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
status=MagickTrue;
(void) ResetMagickMemory(histogram,0,(MaxMap+1)*GetPixelChannels(image)*
sizeof(*histogram));
- image_view=AcquireCacheView(image);
+ image_view=AcquireVirtualCacheView(image,exception);
for (y=0; y < (ssize_t) image->rows; y++)
{
register const Quantum
p+=GetPixelChannels(image);
}
}
+ image_view=DestroyCacheView(image_view);
/*
Integrate the histogram to get the equalization map.
*/
Equalize image.
*/
progress=0;
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
cube_size=level*level;
width=(double) hald_image->columns;
GetPixelInfo(hald_image,&zero);
- image_view=AcquireCacheView(image);
- hald_view=AcquireCacheView(hald_image);
+ hald_view=AcquireVirtualCacheView(hald_image,exception);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
Form histogram.
*/
(void) ResetMagickMemory(histogram,0,(MaxMap+1)*sizeof(*histogram));
- image_view=AcquireCacheView(image);
+ image_view=AcquireVirtualCacheView(image,exception);
for (y=0; y < (ssize_t) image->rows; y++)
{
register const Quantum
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
if (grayscale != MagickFalse)
{
#if defined(MAGICKCORE_OPENMP_SUPPORT)
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status)
#endif