]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sat, 23 Mar 2013 21:24:49 +0000 (21:24 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sat, 23 Mar 2013 21:24:49 +0000 (21:24 +0000)
Magick++/lib/Image.cpp
Magick++/lib/Magick++/Include.h
MagickCore/effect.c
MagickCore/effect.h
MagickWand/magick-image.c
MagickWand/magick-image.h
MagickWand/mogrify.c
MagickWand/operation.c
PerlMagick/quantum/quantum.xs

index 4daa9c0b2f42fab402679384d67afda74ba735a9..a3875fe4a9429edb3087cbf3620bebb4603708ee 100644 (file)
@@ -2282,8 +2282,7 @@ void Magick::Image::trim ( void )
 //   the threshold in pixels needed to apply the diffence amount.
 void Magick::Image::unsharpmask ( const double radius_,
                                   const double sigma_,
-                                  const double amount_,
-                                  const double threshold_ )
+                                  const double gain_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -2291,8 +2290,7 @@ void Magick::Image::unsharpmask ( const double radius_,
     UnsharpMaskImage( image(),
                       radius_,
                       sigma_,
-                      amount_,
-                      threshold_,
+                      gain_,
                       &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
@@ -2302,8 +2300,7 @@ void Magick::Image::unsharpmask ( const double radius_,
 void Magick::Image::unsharpmaskChannel ( const ChannelType channel_,
                                          const double radius_,
                                          const double sigma_,
-                                         const double amount_,
-                                         const double threshold_ )
+                                         const double gain_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -2312,8 +2309,7 @@ void Magick::Image::unsharpmaskChannel ( const ChannelType channel_,
     UnsharpMaskImage( image(),
                              radius_,
                              sigma_,
-                             amount_,
-                             threshold_,
+                             gain_,
                              &exceptionInfo );
   (void) SetPixelChannelMask( image(), channel_mask );
   replaceImage( newImage );
index 808a5e5c22148c5071b35fae6874fbabe31faaff..628d62ab9acdfc9ee0585e9c873402bd87ad1288 100644 (file)
@@ -953,7 +953,6 @@ namespace Magick
   using MagickCore::UndefinedRegistryType;
   using MagickCore::UnregisterMagickInfo;
   using MagickCore::UnsharpMaskImage;
-  using MagickCore::UnsharpMaskImage;
   using MagickCore::CacheView;
   using MagickCore::WaveImage;
   using MagickCore::WidthValue;
index 7450535a09979075c98a82add2177e5fbe14dab7..22dd9c6f00c9acb199a44780d25a522757c97f37 100644 (file)
@@ -3316,8 +3316,7 @@ MagickExport Image *SpreadImage(const Image *image,const double radius,
 %  The format of the UnsharpMaskImage method is:
 %
 %    Image *UnsharpMaskImage(const Image *image,const double radius,
-%      const double sigma,const double gain,const double threshold,
-%      ExceptionInfo *exception)
+%      const double sigma,const double gain,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -3331,135 +3330,37 @@ MagickExport Image *SpreadImage(const Image *image,const double radius,
 %    o gain: the percentage of the difference between the original and the
 %      blur image that is added back into the original.
 %
-%    o threshold: the threshold in pixels needed to apply the diffence gain.
-%
 %    o exception: return any errors or warnings in this structure.
 %
 */
 MagickExport Image *UnsharpMaskImage(const Image *image,const double radius,
-  const double sigma,const double gain,const double threshold,
-  ExceptionInfo *exception)
+  const double sigma,const double gain,ExceptionInfo *exception)
 {
-#define SharpenImageTag  "Sharpen/Image"
+  char
+    geometry[MaxTextExtent];
 
-  CacheView
-    *image_view,
-    *unsharp_view;
+  KernelInfo
+    *kernel_info;
 
   Image
     *unsharp_image;
 
-  MagickBooleanType
-    status;
-
-  MagickOffsetType
-    progress;
-
-  double
-    quantum_threshold;
-
-  ssize_t
-    y;
-
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  unsharp_image=BlurImage(image,radius,sigma,exception);
-  if (unsharp_image == (Image *) NULL)
-    return((Image *) NULL);
-  quantum_threshold=(double) QuantumRange*threshold;
-  /*
-    Unsharp-mask image.
-  */
-  status=MagickTrue;
-  progress=0;
-  image_view=AcquireVirtualCacheView(image,exception);
-  unsharp_view=AcquireAuthenticCacheView(unsharp_image,exception);
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status) \
-    magick_threads(image,unsharp_image,image->rows,1)
-#endif
-  for (y=0; y < (ssize_t) image->rows; y++)
-  {
-    register const Quantum
-      *restrict p;
-
-    register Quantum
-      *restrict q;
-
-    register ssize_t
-      x;
-
-    if (status == MagickFalse)
-      continue;
-    p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
-    q=QueueCacheViewAuthenticPixels(unsharp_view,0,y,unsharp_image->columns,1,
-      exception);
-    if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
-      {
-        status=MagickFalse;
-        continue;
-      }
-    for (x=0; x < (ssize_t) image->columns; x++)
-    {
-      register ssize_t
-        i;
-
-      for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
-      {
-        double
-          pixel;
-
-        PixelChannel
-          channel;
-
-        PixelTrait
-          traits,
-          unsharp_traits;
-
-        channel=GetPixelChannelChannel(image,i);
-        traits=GetPixelChannelTraits(image,channel);
-        unsharp_traits=GetPixelChannelTraits(unsharp_image,channel);
-        if ((traits == UndefinedPixelTrait) ||
-            (unsharp_traits == UndefinedPixelTrait))
-          continue;
-        if (((unsharp_traits & CopyPixelTrait) != 0) ||
-            (GetPixelMask(image,p) == 0))
-          {
-            SetPixelChannel(unsharp_image,channel,p[i],q);
-            continue;
-          }
-        pixel=p[i]-(double) GetPixelChannel(unsharp_image,channel,q);
-        if (fabs(2.0*pixel) < quantum_threshold)
-          pixel=(double) p[i];
-        else
-          pixel=(double) p[i]+gain*pixel;
-        SetPixelChannel(unsharp_image,channel,ClampToQuantum(pixel),q);
-      }
-      p+=GetPixelChannels(image);
-      q+=GetPixelChannels(unsharp_image);
-    }
-    if (SyncCacheViewAuthenticPixels(unsharp_view,exception) == MagickFalse)
-      status=MagickFalse;
-    if (image->progress_monitor != (MagickProgressMonitor) NULL)
-      {
-        MagickBooleanType
-          proceed;
-
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-        #pragma omp critical (MagickCore_UnsharpMaskImage)
-#endif
-        proceed=SetImageProgress(image,SharpenImageTag,progress++,image->rows);
-        if (proceed == MagickFalse)
-          status=MagickFalse;
-      }
-  }
-  unsharp_image->type=image->type;
-  unsharp_view=DestroyCacheView(unsharp_view);
-  image_view=DestroyCacheView(image_view);
-  if (status == MagickFalse)
-    unsharp_image=DestroyImage(unsharp_image);
+  assert(exception->signature == MagickSignature);
+  (void) FormatLocaleString(geometry,MaxTextExtent,"Blur:%.20gx%.20g>",
+    radius,sigma);
+  kernel_info=AcquireKernelInfo(geometry);
+  if (kernel_info == (KernelInfo *) NULL)
+    ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
+  (void) FormatLocaleString(geometry,MaxTextExtent,"%.20g,%.20g%%",
+    -100.0+gain*100.0,200.0-gain*100.0);
+  ScaleGeometryKernelInfo(kernel_info,geometry);
+  unsharp_image=MorphologyImage(image,ConvolveMorphology,1,kernel_info,
+    exception);
+  kernel_info=DestroyKernelInfo(kernel_info);
   return(unsharp_image);
 }
index ed68cfe8720da316f706388bd3885c7ac5266ba7..0a42df50764d90c5613f707d9cb435ae3a294004 100644 (file)
@@ -80,7 +80,7 @@ extern MagickExport Image
   *SpreadImage(const Image *,const double,const PixelInterpolateMethod,
     ExceptionInfo *),
   *UnsharpMaskImage(const Image *,const double,const double,const double,
-    const double,ExceptionInfo *);
+    ExceptionInfo *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
index a5c9abeff3446888d23d537353384bb6e1b84fa1..2a29afc5100010e90c8f4a5edc41043862ff4e62 100644 (file)
@@ -11928,8 +11928,7 @@ WandExport MagickBooleanType MagickUniqueImageColors(MagickWand *wand)
 %  The format of the MagickUnsharpMaskImage method is:
 %
 %      MagickBooleanType MagickUnsharpMaskImage(MagickWand *wand,
-%        const double radius,const double sigma,const double amount,
-%        const double threshold)
+%        const double radius,const double sigma,const double gain)
 %
 %  A description of each parameter follows:
 %
@@ -11940,15 +11939,12 @@ WandExport MagickBooleanType MagickUniqueImageColors(MagickWand *wand)
 %
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
-%    o amount: the percentage of the difference between the original and the
+%    o gain: the percentage of the difference between the original and the
 %      blur image that is added back into the original.
 %
-%    o threshold: the threshold in pixels needed to apply the diffence amount.
-%
 */
 WandExport MagickBooleanType MagickUnsharpMaskImage(MagickWand *wand,
-  const double radius,const double sigma,const double amount,
-  const double threshold)
+  const double radius,const double sigma,const double gain)
 {
   Image
     *unsharp_image;
@@ -11959,7 +11955,7 @@ WandExport MagickBooleanType MagickUnsharpMaskImage(MagickWand *wand,
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
   if (wand->images == (Image *) NULL)
     ThrowWandException(WandError,"ContainsNoImages",wand->name);
-  unsharp_image=UnsharpMaskImage(wand->images,radius,sigma,amount,threshold,
+  unsharp_image=UnsharpMaskImage(wand->images,radius,sigma,amount,
     wand->exception);
   if (unsharp_image == (Image *) NULL)
     return(MagickFalse);
index 596cb94be0148f385d8686dcb10b983c79fd20ab..2677cdc1df58f3cb9e852c05b8b69b5bd035ba02 100644 (file)
@@ -304,8 +304,7 @@ extern WandExport MagickBooleanType
   MagickThumbnailImage(MagickWand *,const size_t,const size_t),
   MagickTrimImage(MagickWand *,const double),
   MagickUniqueImageColors(MagickWand *),
-  MagickUnsharpMaskImage(MagickWand *,const double,const double,const double,
-    const double),
+  MagickUnsharpMaskImage(MagickWand *,const double,const double,const double),
   MagickVignetteImage(MagickWand *,const double,const double,const ssize_t,
     const ssize_t),
   MagickWaveImage(MagickWand *,const double,const double,
index cec3a47d25dda6c5e9492766a27b2ae814289ee3..e104d0e100233937f4e3eb3fc1a4ee0a847d1b82 100644 (file)
@@ -3049,7 +3049,7 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
             if ((flags & PsiValue) == 0)
               geometry_info.psi=0.05;
             mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
-              geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
+              geometry_info.sigma,geometry_info.xi,exception);
             break;
           }
         break;
index f3eccc268d50479d2574f419804759cc5bfe780b..d5553bcd06148be189a73d7cd09618acfc9fbc86 100644 (file)
@@ -3339,7 +3339,7 @@ static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand,
           if ((flags & PsiValue) == 0)
             geometry_info.psi=0.05;
           new_image=UnsharpMaskImage(_image,geometry_info.rho,
-            geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception);
+            geometry_info.sigma,geometry_info.xi,_exception);
           break;
         }
       CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
index ca9c6f553b3bd43b4b976284846287205a0412fc..54494bbb8d20d0f77553d249c8768ec3b5b66bb0 100644 (file)
@@ -390,8 +390,7 @@ static struct
       { "black-point-compensation", MagickBooleanOptions} } },
     { "UnsharpMask", { {"geometry", StringReference},
       {"radius", RealReference}, {"sigma", RealReference},
-      {"amount", RealReference}, {"threshold", RealReference},
-      {"channel", MagickChannelOptions} } },
+      {"gain", RealReference}, {"channel", MagickChannelOptions} } },
     { "MotionBlur", { {"geometry", StringReference},
       {"radius", RealReference}, {"sigma", RealReference},
       {"angle", RealReference}, {"channel", MagickChannelOptions} } },
@@ -9489,12 +9488,10 @@ Mogrify(ref,...)
           if (attribute_flag[3] != 0)
             geometry_info.xi=argument_list[3].real_reference;
           if (attribute_flag[4] != 0)
-            geometry_info.psi=argument_list[4].real_reference;
-          if (attribute_flag[5] != 0)
-            channel=(ChannelType) argument_list[5].integer_reference;
+            channel=(ChannelType) argument_list[4].integer_reference;
           channel_mask=SetImageChannelMask(image,channel);
           image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
-            geometry_info.xi,geometry_info.psi,exception);
+            geometry_info.xi,exception);
           if (image != (Image *) NULL)
             (void) SetImageChannelMask(image,channel_mask);
           break;