status=MagickTrue;
progress=0;
number_pixels=(MagickSizeType) width*height;
- image_view=AcquireCacheView(image);
- threshold_view=AcquireCacheView(threshold_image);
+ image_view=AcquireVirtualCacheView(image,exception);
+ threshold_view=AcquireAuthenticCacheView(threshold_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,4) shared(progress,status)
+ #pragma omp parallel for schedule(static,4) shared(progress,status) \
+ dynamic_number_threads(image,image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- MagickRealType
+ double
mean,
pixel;
}
pixels+=image->columns*GetPixelChannels(image);
}
- mean=(MagickRealType) (pixel/number_pixels+bias);
- SetPixelChannel(threshold_image,channel,(Quantum) ((MagickRealType)
+ mean=(double) (pixel/number_pixels+bias);
+ SetPixelChannel(threshold_image,channel,(Quantum) ((double)
p[center+i] <= mean ? 0 : QuantumRange),q);
}
p+=GetPixelChannels(image);
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_AdaptiveThresholdImage)
+ #pragma omp critical (MagickCore_AdaptiveThresholdImage)
#endif
proceed=SetImageProgress(image,AdaptiveThresholdImageTag,progress++,
image->rows);
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,8) shared(progress,status)
+ #pragma omp parallel for schedule(static,4) shared(progress,status) \
+ dynamic_number_threads(image,image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
}
for (x=0; x < (ssize_t) image->columns; x++)
{
+ double
+ pixel;
+
register ssize_t
i;
q+=GetPixelChannels(image);
continue;
}
+ pixel=GetPixelIntensity(image,q);
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
PixelChannel
traits=GetPixelChannelMapTraits(image,channel);
if ((traits & UpdatePixelTrait) == 0)
continue;
- q[i]=(Quantum) ((MagickRealType) q[i] <= threshold ? 0 : QuantumRange);
+ if (image->channel_mask != DefaultChannels)
+ pixel=(double) q[i];
+ q[i]=(Quantum) (pixel <= threshold ? 0 : QuantumRange);
}
q+=GetPixelChannels(image);
}
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_BilevelImage)
+ #pragma omp critical (MagickCore_BilevelImage)
#endif
proceed=SetImageProgress(image,ThresholdImageTag,progress++,
image->rows);
MagickOffsetType
progress;
- MagickRealType
- threshold[5];
+ PixelInfo
+ threshold;
MagickStatusType
flags;
- register ssize_t
- i;
-
ssize_t
y;
if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
if (IsGrayColorspace(image->colorspace) != MagickFalse)
- (void) TransformImageColorspace(image,sRGBColorspace,exception);
+ (void) TransformImageColorspace(image,RGBColorspace,exception);
+ GetPixelInfo(image,&threshold);
flags=ParseGeometry(thresholds,&geometry_info);
- for (i=0; i < 5; i++)
- threshold[i]=geometry_info.rho;
+ threshold.red=geometry_info.rho;
+ threshold.green=geometry_info.rho;
+ threshold.blue=geometry_info.rho;
+ threshold.black=geometry_info.rho;
+ threshold.alpha=100.0;
if ((flags & SigmaValue) != 0)
- threshold[1]=geometry_info.sigma;
+ threshold.green=geometry_info.sigma;
if ((flags & XiValue) != 0)
- threshold[2]=geometry_info.xi;
+ threshold.blue=geometry_info.xi;
if ((flags & PsiValue) != 0)
- threshold[3]=geometry_info.psi;
- if ((flags & ChiValue) != 0)
- threshold[4]=geometry_info.chi;
+ threshold.alpha=geometry_info.psi;
+ if (threshold.colorspace == CMYKColorspace)
+ {
+ if ((flags & PsiValue) != 0)
+ threshold.black=geometry_info.psi;
+ if ((flags & ChiValue) != 0)
+ threshold.alpha=geometry_info.chi;
+ }
if ((flags & PercentValue) != 0)
- for (i=0; i < 5; i++)
- threshold[i]*=(QuantumRange/100.0);
+ {
+ threshold.red*=(QuantumRange/100.0);
+ threshold.green*=(QuantumRange/100.0);
+ threshold.blue*=(QuantumRange/100.0);
+ threshold.black*=(QuantumRange/100.0);
+ threshold.alpha*=(QuantumRange/100.0);
+ }
/*
White threshold image.
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,8) shared(progress,status)
+ #pragma omp parallel for schedule(static,4) shared(progress,status) \
+ dynamic_number_threads(image,image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
}
for (x=0; x < (ssize_t) image->columns; x++)
{
+ double
+ pixel;
+
register ssize_t
i;
- ssize_t
- n;
-
if (GetPixelMask(image,q) != 0)
{
q+=GetPixelChannels(image);
continue;
}
- n=0;
+ pixel=GetPixelIntensity(image,q);
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
PixelChannel
traits=GetPixelChannelMapTraits(image,channel);
if ((traits & UpdatePixelTrait) == 0)
continue;
- if ((MagickRealType) q[i] < threshold[n++ % 5])
- q[i]=QuantumRange;
+ if (image->channel_mask != DefaultChannels)
+ pixel=(double) q[i];
+ if (pixel <= GetPixelInfoChannel(&threshold,channel))
+ q[i]=0;
}
q+=GetPixelChannels(image);
}
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_WhiteThresholdImage)
+ #pragma omp critical (MagickCore_BlackThresholdImage)
#endif
proceed=SetImageProgress(image,ThresholdImageTag,progress++,
image->rows);
static inline Quantum ClampToUnsignedQuantum(const Quantum quantum)
{
-#if defined(MAGICKCORE_HDRI_SUPPORT)
if (quantum <= 0)
return(0);
if (quantum >= QuantumRange)
return(QuantumRange);
return(quantum);
-#else
- return(quantum);
-#endif
}
MagickExport MagickBooleanType ClampImage(Image *image,ExceptionInfo *exception)
{
+#if !defined(MAGICKCORE_HDRI_SUPPORT)
+ return(MagickTrue);
+#else
#define ClampImageTag "Clamp/Image"
CacheView
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,8) shared(progress,status)
+ #pragma omp parallel for schedule(static,4) shared(progress,status) \
+ dynamic_number_threads(image,image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_ClampImage)
+ #pragma omp critical (MagickCore_ClampImage)
#endif
- proceed=SetImageProgress(image,ClampImageTag,progress++,
- image->rows);
+ proceed=SetImageProgress(image,ClampImageTag,progress++,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
image_view=DestroyCacheView(image_view);
return(status);
+#endif
}
\f
/*
MagickOffsetType
progress;
- MagickRealType
+ double
levels[CompositePixelChannel];
register ssize_t
return(MagickFalse);
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,8) shared(progress,status)
+ #pragma omp parallel for schedule(static,4) shared(progress,status) \
+ dynamic_number_threads(image,image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
threshold=(ssize_t) (QuantumScale*q[i]*(levels[n]*(map->divisor-1)+1));
level=threshold/(map->divisor-1);
threshold-=level*(map->divisor-1);
- q[i]=RoundToQuantum((MagickRealType) (level+(threshold >=
+ q[i]=ClampToQuantum((double) (level+(threshold >=
map->levels[(x % map->width)+map->width*(y % map->height)]))*
QuantumRange/levels[n]);
n++;
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
-#pragma omp critical (MagickCore_OrderedPosterizeImage)
+ #pragma omp critical (MagickCore_OrderedPosterizeImage)
#endif
proceed=SetImageProgress(image,DitherImageTag,progress++,image->rows);
if (proceed == MagickFalse)
PixelInfo
threshold;
- MagickRealType
+ double
min_threshold,
max_threshold;
ssize_t
y;
+ unsigned long
+ key;
+
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
assert(exception->signature == MagickSignature);
if (thresholds == (const char *) NULL)
return(MagickTrue);
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
+ return(MagickFalse);
GetPixelInfo(image,&threshold);
min_threshold=0.0;
- max_threshold=(MagickRealType) QuantumRange;
+ max_threshold=(double) QuantumRange;
flags=ParseGeometry(thresholds,&geometry_info);
min_threshold=geometry_info.rho;
max_threshold=geometry_info.sigma;
max_threshold=min_threshold;
if (strchr(thresholds,'%') != (char *) NULL)
{
- max_threshold*=(MagickRealType) (0.01*QuantumRange);
- min_threshold*=(MagickRealType) (0.01*QuantumRange);
+ max_threshold*=(double) (0.01*QuantumRange);
+ min_threshold*=(double) (0.01*QuantumRange);
}
/*
Random threshold image.
*/
status=MagickTrue;
progress=0;
- if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
- return(MagickFalse);
random_info=AcquireRandomInfoThreadSet();
- image_view=AcquireCacheView(image);
+ key=GetRandomSecretKey(random_info[0]);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,8) shared(progress,status)
+ #pragma omp parallel for schedule(static,4) shared(progress,status) \
+ dynamic_number_threads(image,image->columns,image->rows,key == ~0UL)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
}
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- MagickRealType
+ double
threshold;
PixelChannel
traits=GetPixelChannelMapTraits(image,channel);
if ((traits & UpdatePixelTrait) == 0)
continue;
- if ((MagickRealType) q[i] < min_threshold)
+ if ((double) q[i] < min_threshold)
threshold=min_threshold;
else
- if ((MagickRealType) q[i] > max_threshold)
+ if ((double) q[i] > max_threshold)
threshold=max_threshold;
else
- threshold=(MagickRealType) (QuantumRange*
+ threshold=(double) (QuantumRange*
GetPseudoRandomValue(random_info[id]));
- q[i]=(Quantum) ((MagickRealType) q[i] <= threshold ? 0 :
- QuantumRange);
+ q[i]=(double) q[i] <= threshold ? 0 : QuantumRange;
}
q+=GetPixelChannels(image);
}
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_RandomThresholdImage)
+ #pragma omp critical (MagickCore_RandomThresholdImage)
#endif
proceed=SetImageProgress(image,ThresholdImageTag,progress++,
image->rows);
MagickOffsetType
progress;
- MagickRealType
- threshold[5];
+ PixelInfo
+ threshold;
MagickStatusType
flags;
- register ssize_t
- i;
-
ssize_t
y;
if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
if (IsGrayColorspace(image->colorspace) != MagickFalse)
- (void) TransformImageColorspace(image,sRGBColorspace,exception);
+ (void) TransformImageColorspace(image,RGBColorspace,exception);
+ GetPixelInfo(image,&threshold);
flags=ParseGeometry(thresholds,&geometry_info);
- for (i=0; i < 5; i++)
- threshold[i]=geometry_info.rho;
+ threshold.red=geometry_info.rho;
+ threshold.green=geometry_info.rho;
+ threshold.blue=geometry_info.rho;
+ threshold.black=geometry_info.rho;
+ threshold.alpha=100.0;
if ((flags & SigmaValue) != 0)
- threshold[1]=geometry_info.sigma;
+ threshold.green=geometry_info.sigma;
if ((flags & XiValue) != 0)
- threshold[2]=geometry_info.xi;
+ threshold.blue=geometry_info.xi;
if ((flags & PsiValue) != 0)
- threshold[3]=geometry_info.psi;
- if ((flags & ChiValue) != 0)
- threshold[4]=geometry_info.chi;
+ threshold.alpha=geometry_info.psi;
+ if (threshold.colorspace == CMYKColorspace)
+ {
+ if ((flags & PsiValue) != 0)
+ threshold.black=geometry_info.psi;
+ if ((flags & ChiValue) != 0)
+ threshold.alpha=geometry_info.chi;
+ }
if ((flags & PercentValue) != 0)
- for (i=0; i < 5; i++)
- threshold[i]*=(QuantumRange/100.0);
+ {
+ threshold.red*=(QuantumRange/100.0);
+ threshold.green*=(QuantumRange/100.0);
+ threshold.blue*=(QuantumRange/100.0);
+ threshold.black*=(QuantumRange/100.0);
+ threshold.alpha*=(QuantumRange/100.0);
+ }
/*
White threshold image.
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,8) shared(progress,status)
+ #pragma omp parallel for schedule(static,4) shared(progress,status) \
+ dynamic_number_threads(image,image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
}
for (x=0; x < (ssize_t) image->columns; x++)
{
+ double
+ pixel;
+
register ssize_t
i;
- ssize_t
- n;
-
if (GetPixelMask(image,q) != 0)
{
q+=GetPixelChannels(image);
continue;
}
- n=0;
+ pixel=GetPixelIntensity(image,q);
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
PixelChannel
traits=GetPixelChannelMapTraits(image,channel);
if ((traits & UpdatePixelTrait) == 0)
continue;
- if ((MagickRealType) q[i] > threshold[n++ % 5])
+ if (image->channel_mask != DefaultChannels)
+ pixel=(double) q[i];
+ if (pixel > GetPixelInfoChannel(&threshold,channel))
q[i]=QuantumRange;
}
q+=GetPixelChannels(image);
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_WhiteThresholdImage)
+ #pragma omp critical (MagickCore_WhiteThresholdImage)
#endif
proceed=SetImageProgress(image,ThresholdImageTag,progress++,
image->rows);