]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/threshold.c
(no commit message)
[imagemagick] / MagickCore / threshold.c
index 76a5dd903215aa6f72fedb86750571dd279520c1..1e5e3c125e67da2c754e3209dfab4dd4be9f6399 100644 (file)
@@ -202,10 +202,11 @@ MagickExport Image *AdaptiveThresholdImage(const Image *image,
   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++)
   {
@@ -239,15 +240,9 @@ MagickExport Image *AdaptiveThresholdImage(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelMask(image,p) != 0)
-        {
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(threshold_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
-        MagickRealType
+        double
           mean,
           pixel;
 
@@ -273,7 +268,8 @@ MagickExport Image *AdaptiveThresholdImage(const Image *image,
         if ((traits == UndefinedPixelTrait) ||
             (threshold_traits == UndefinedPixelTrait))
           continue;
-        if ((threshold_traits & CopyPixelTrait) != 0)
+        if (((threshold_traits & CopyPixelTrait) != 0) ||
+            (GetPixelMask(image,p) != 0))
           {
             SetPixelChannel(threshold_image,channel,p[center+i],q);
             continue;
@@ -289,8 +285,8 @@ MagickExport Image *AdaptiveThresholdImage(const Image *image,
           }
           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);
@@ -304,7 +300,7 @@ MagickExport Image *AdaptiveThresholdImage(const Image *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);
@@ -389,9 +385,10 @@ MagickExport MagickBooleanType BilevelImage(Image *image,const double threshold,
   */
   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++)
   {
@@ -411,6 +408,9 @@ MagickExport MagickBooleanType BilevelImage(Image *image,const double threshold,
       }
     for (x=0; x < (ssize_t) image->columns; x++)
     {
+      double
+        pixel;
+
       register ssize_t
         i;
 
@@ -419,6 +419,7 @@ MagickExport MagickBooleanType BilevelImage(Image *image,const double threshold,
           q+=GetPixelChannels(image);
           continue;
         }
+      pixel=GetPixelIntensity(image,q);
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -431,7 +432,9 @@ MagickExport MagickBooleanType BilevelImage(Image *image,const double threshold,
         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);
     }
@@ -443,7 +446,7 @@ MagickExport MagickBooleanType BilevelImage(Image *image,const double threshold,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_BilevelImage)
+        #pragma omp critical (MagickCore_BilevelImage)
 #endif
         proceed=SetImageProgress(image,ThresholdImageTag,progress++,
           image->rows);
@@ -488,8 +491,6 @@ MagickExport MagickBooleanType BlackThresholdImage(Image *image,
   const char *thresholds,ExceptionInfo *exception)
 {
 #define ThresholdImageTag  "Threshold/Image"
-#define BlackThreshold(pixel,threshold_percentage) \
-  if (pixel < threshold_percentage) pixel=0;
 
   CacheView
     *image_view;
@@ -504,7 +505,7 @@ MagickExport MagickBooleanType BlackThresholdImage(Image *image,
     progress;
 
   PixelInfo
-    threshold_percentage;
+    threshold;
 
   MagickStatusType
     flags;
@@ -521,41 +522,47 @@ MagickExport MagickBooleanType BlackThresholdImage(Image *image,
   if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
     return(MagickFalse);
   if (IsGrayColorspace(image->colorspace) != MagickFalse)
-    (void) TransformImageColorspace(image,sRGBColorspace,exception);
-  GetPixelInfo(image,&threshold_percentage);
+    (void) TransformImageColorspace(image,RGBColorspace,exception);
+  GetPixelInfo(image,&threshold);
   flags=ParseGeometry(thresholds,&geometry_info);
-  threshold_percentage.red=geometry_info.rho;
-  threshold_percentage.green=geometry_info.rho;
-  threshold_percentage.blue=geometry_info.rho;
-  threshold_percentage.black=geometry_info.rho;
-  threshold_percentage.alpha=100.0;
+  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_percentage.green=geometry_info.sigma;
+    threshold.green=geometry_info.sigma;
   if ((flags & XiValue) != 0)
-    threshold_percentage.blue=geometry_info.xi;
+    threshold.blue=geometry_info.xi;
   if ((flags & PsiValue) != 0)
-    threshold_percentage.alpha=geometry_info.psi;
-  if (threshold_percentage.colorspace == CMYKColorspace)
+    threshold.alpha=geometry_info.psi;
+  if (threshold.colorspace == CMYKColorspace)
     {
       if ((flags & PsiValue) != 0)
-        threshold_percentage.black=geometry_info.psi;
+        threshold.black=geometry_info.psi;
       if ((flags & ChiValue) != 0)
-        threshold_percentage.alpha=geometry_info.chi;
+        threshold.alpha=geometry_info.chi;
+    }
+  if ((flags & PercentValue) != 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++)
   {
-    PixelInfo
-      pixel;
-
     register ssize_t
       x;
 
@@ -570,21 +577,37 @@ MagickExport MagickBooleanType BlackThresholdImage(Image *image,
         status=MagickFalse;
         continue;
       }
-    GetPixelInfo(image,&pixel);
     for (x=0; x < (ssize_t) image->columns; x++)
     {
+      double
+        pixel;
+
+      register ssize_t
+        i;
+
       if (GetPixelMask(image,q) != 0)
         {
           q+=GetPixelChannels(image);
           continue;
         }
-      GetPixelInfoPixel(image,q,&pixel);
-      BlackThreshold(pixel.red,threshold_percentage.red);
-      BlackThreshold(pixel.green,threshold_percentage.green);
-      BlackThreshold(pixel.blue,threshold_percentage.blue);
-      BlackThreshold(pixel.black,threshold_percentage.black);
-      BlackThreshold(pixel.alpha,threshold_percentage.alpha);
-      SetPixelInfoPixel(image,&pixel,q);
+      pixel=GetPixelIntensity(image,q);
+      for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+      {
+        PixelChannel
+          channel;
+
+        PixelTrait
+          traits;
+
+        channel=GetPixelChannelMapChannel(image,i);
+        traits=GetPixelChannelMapTraits(image,channel);
+        if ((traits & UpdatePixelTrait) == 0)
+          continue;
+        if (image->channel_mask != DefaultChannels)
+          pixel=(double) q[i];
+        if (pixel <= GetPixelInfoChannel(&threshold,channel))
+          q[i]=0;
+      }
       q+=GetPixelChannels(image);
     }
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
@@ -595,7 +618,7 @@ MagickExport MagickBooleanType BlackThresholdImage(Image *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);
@@ -634,19 +657,18 @@ MagickExport MagickBooleanType BlackThresholdImage(Image *image,
 
 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
@@ -689,9 +711,10 @@ MagickExport MagickBooleanType ClampImage(Image *image,ExceptionInfo *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,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++)
   {
@@ -743,16 +766,16 @@ MagickExport MagickBooleanType ClampImage(Image *image,ExceptionInfo *exception)
           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
 /*
@@ -1253,7 +1276,7 @@ MagickExport MagickBooleanType OrderedPosterizeImage(Image *image,
   MagickOffsetType
     progress;
 
-  MagickRealType
+  double
     levels[CompositePixelChannel];
 
   register ssize_t
@@ -1312,9 +1335,10 @@ MagickExport MagickBooleanType OrderedPosterizeImage(Image *image,
     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++)
   {
@@ -1367,7 +1391,7 @@ MagickExport MagickBooleanType OrderedPosterizeImage(Image *image,
         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++;
@@ -1382,7 +1406,7 @@ MagickExport MagickBooleanType OrderedPosterizeImage(Image *image,
           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)
@@ -1440,7 +1464,6 @@ MagickExport MagickBooleanType RandomThresholdImage(Image *image,
     flags;
 
   MagickBooleanType
-    concurrent,
     status;
 
   MagickOffsetType
@@ -1449,7 +1472,7 @@ MagickExport MagickBooleanType RandomThresholdImage(Image *image,
   PixelInfo
     threshold;
 
-  MagickRealType
+  double
     min_threshold,
     max_threshold;
 
@@ -1459,6 +1482,9 @@ MagickExport MagickBooleanType RandomThresholdImage(Image *image,
   ssize_t
     y;
 
+  unsigned long
+    key;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -1471,7 +1497,7 @@ MagickExport MagickBooleanType RandomThresholdImage(Image *image,
     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;
@@ -1479,8 +1505,8 @@ MagickExport MagickBooleanType RandomThresholdImage(Image *image,
     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.
@@ -1488,11 +1514,11 @@ MagickExport MagickBooleanType RandomThresholdImage(Image *image,
   status=MagickTrue;
   progress=0;
   random_info=AcquireRandomInfoThreadSet();
-  concurrent=GetRandomSecretKey(random_info[0]) == ~0UL ? MagickTrue :
-    MagickFalse;
-  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) omp_concurrent(concurrent)
+  #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++)
   {
@@ -1525,7 +1551,7 @@ MagickExport MagickBooleanType RandomThresholdImage(Image *image,
         }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
-        MagickRealType
+        double
           threshold;
 
         PixelChannel
@@ -1538,16 +1564,15 @@ MagickExport MagickBooleanType RandomThresholdImage(Image *image,
         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);
     }
@@ -1559,7 +1584,7 @@ MagickExport MagickBooleanType RandomThresholdImage(Image *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);
@@ -1605,8 +1630,6 @@ MagickExport MagickBooleanType WhiteThresholdImage(Image *image,
   const char *thresholds,ExceptionInfo *exception)
 {
 #define ThresholdImageTag  "Threshold/Image"
-#define WhiteThreshold(pixel,threshold_percentage) \
-  if (pixel > threshold_percentage) pixel=QuantumRange;
 
   CacheView
     *image_view;
@@ -1621,7 +1644,7 @@ MagickExport MagickBooleanType WhiteThresholdImage(Image *image,
     progress;
 
   PixelInfo
-    threshold_percentage;
+    threshold;
 
   MagickStatusType
     flags;
@@ -1638,41 +1661,47 @@ MagickExport MagickBooleanType WhiteThresholdImage(Image *image,
   if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
     return(MagickFalse);
   if (IsGrayColorspace(image->colorspace) != MagickFalse)
-    (void) TransformImageColorspace(image,sRGBColorspace,exception);
-  GetPixelInfo(image,&threshold_percentage);
+    (void) TransformImageColorspace(image,RGBColorspace,exception);
+  GetPixelInfo(image,&threshold);
   flags=ParseGeometry(thresholds,&geometry_info);
-  threshold_percentage.red=geometry_info.rho;
-  threshold_percentage.green=geometry_info.rho;
-  threshold_percentage.blue=geometry_info.rho;
-  threshold_percentage.black=geometry_info.rho;
-  threshold_percentage.alpha=100.0;
+  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_percentage.green=geometry_info.sigma;
+    threshold.green=geometry_info.sigma;
   if ((flags & XiValue) != 0)
-    threshold_percentage.blue=geometry_info.xi;
+    threshold.blue=geometry_info.xi;
   if ((flags & PsiValue) != 0)
-    threshold_percentage.alpha=geometry_info.psi;
-  if (threshold_percentage.colorspace == CMYKColorspace)
+    threshold.alpha=geometry_info.psi;
+  if (threshold.colorspace == CMYKColorspace)
     {
       if ((flags & PsiValue) != 0)
-        threshold_percentage.black=geometry_info.psi;
+        threshold.black=geometry_info.psi;
       if ((flags & ChiValue) != 0)
-        threshold_percentage.alpha=geometry_info.chi;
+        threshold.alpha=geometry_info.chi;
+    }
+  if ((flags & PercentValue) != 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++)
   {
-    PixelInfo
-      pixel;
-
     register ssize_t
       x;
 
@@ -1687,21 +1716,37 @@ MagickExport MagickBooleanType WhiteThresholdImage(Image *image,
         status=MagickFalse;
         continue;
       }
-    GetPixelInfo(image,&pixel);
     for (x=0; x < (ssize_t) image->columns; x++)
     {
+      double
+        pixel;
+
+      register ssize_t
+        i;
+
       if (GetPixelMask(image,q) != 0)
         {
           q+=GetPixelChannels(image);
           continue;
         }
-      GetPixelInfoPixel(image,q,&pixel);
-      WhiteThreshold(pixel.red,threshold_percentage.red);
-      WhiteThreshold(pixel.green,threshold_percentage.green);
-      WhiteThreshold(pixel.blue,threshold_percentage.blue);
-      WhiteThreshold(pixel.black,threshold_percentage.black);
-      WhiteThreshold(pixel.alpha,threshold_percentage.alpha);
-      SetPixelInfoPixel(image,&pixel,q);
+      pixel=GetPixelIntensity(image,q);
+      for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+      {
+        PixelChannel
+          channel;
+
+        PixelTrait
+          traits;
+
+        channel=GetPixelChannelMapChannel(image,i);
+        traits=GetPixelChannelMapTraits(image,channel);
+        if ((traits & UpdatePixelTrait) == 0)
+          continue;
+        if (image->channel_mask != DefaultChannels)
+          pixel=(double) q[i];
+        if (pixel > GetPixelInfoChannel(&threshold,channel))
+          q[i]=QuantumRange;
+      }
       q+=GetPixelChannels(image);
     }
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
@@ -1712,7 +1757,7 @@ MagickExport MagickBooleanType WhiteThresholdImage(Image *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);