Ignore:
Timestamp:
04/25/12 00:47:23 (13 months ago)
Author:
anthony
Message:

Fix Gaussian Filter which was causing problems with Variable Blur

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ImageMagick/branches/ImageMagick-6/magick/composite.c

    r7603 r7625  
    16461646    return(MagickFalse); 
    16471647  GetMagickPixelPacket(image,&zero); 
     1648  exception=(&image->exception); 
    16481649  destination_image=(Image *) NULL; 
    16491650  amount=0.5; 
     
    16871688        break; 
    16881689      status=MagickTrue; 
    1689       exception=(&image->exception); 
    16901690      composite_view=AcquireVirtualCacheView(composite_image,exception); 
    16911691      image_view=AcquireAuthenticCacheView(image,exception); 
     
    17831783 
    17841784      /* 
     1785        Blur Image by resampling. 
     1786 
    17851787        Blur Image dictated by an overlay gradient map: X = red_channel; 
    17861788          Y = green_channel; compose:args =  x_scale[,y_scale[,angle]]. 
    17871789      */ 
    17881790      destination_image=CloneImage(image,image->columns,image->rows,MagickTrue, 
    1789         &image->exception); 
     1791        exception); 
    17901792      if (destination_image == (Image *) NULL) 
    17911793        return(MagickFalse); 
    17921794      /* 
    1793         Determine the horizontal and vertical maximim blur. 
     1795        Gather the maximum blur sigma values from user. 
    17941796      */ 
    17951797      SetGeometryInfo(&geometry_info); 
     
    17991801        flags=ParseGeometry(value,&geometry_info); 
    18001802      if ((flags & WidthValue) == 0 ) { 
     1803          (void) ThrowMagickException(exception,GetMagickModule(), 
     1804               OptionWarning,"InvalidGeometry","'%s' '%s'", 
     1805               "compose:args",value); 
    18011806          destination_image=DestroyImage(destination_image); 
    18021807          return(MagickFalse); 
    18031808        } 
    1804       /* Width and height of ellipse. 
    1805          Note: The Gaussian Filter uses a sigma = 0.5, so to compensate the 
    1806          input sigma must be doubled to give a correct 'area to resample'. 
     1809      /* 
     1810        Users input sigma now needs to be converted to the EWA ellipse size. 
     1811        The filter defaults to a sigma of 0.5 so to make this match 
     1812        the elipse size needs to be doubled. 
    18071813      */ 
    18081814      width=height=geometry_info.rho*2.0; 
    18091815      if ((flags & HeightValue) != 0 ) 
    18101816        height=geometry_info.sigma*2.0; 
    1811  
    1812 /* Hack -- this make gaussian work! -- But it is not needed for cubic! */ 
    1813 width*=2.0; height*=2.0; 
    18141817 
    18151818      /* default the unrotated ellipse width and height axis vectors */ 
     
    18301833          blur.y2=height*cos(angle); 
    18311834        } 
    1832       /* otherwise lets set a angle range and calculate in the loop */ 
     1835      /* Otherwise lets set a angle range and calculate in the loop */ 
    18331836      angle_start=0.0; 
    18341837      angle_range=0.0; 
     
    18391842        } 
    18401843      /* 
    1841         Blur Image by resampling. 
    1842  
    1843         FUTURE: this is currently broken, especially for small sigma blurs 
    1844         This needs to be fixed to use a non-user filter setup that provides 
    1845         far more control than currently available. 
    1846  
    1847         It should also be set to GaussianFilter, but it is not being effected 
    1848         by ScaleResampleFilter() for some reason. 
     1844        Set up a gaussian cylindrical filter for EWA Bluring. 
     1845 
     1846        FUTURE: Currently broken, small sigma blurs 
     1847          (either goes to zero earily, or blurs on zero blurs) 
     1848 
     1849        Also need to prevent user 'expert' filter options overriding the 
     1850        filter settings I am carfully setting up for image blurring. 
    18491851      */ 
     1852      resample_filter=AcquireResampleFilter(image,exception); 
     1853      SetResampleFilter(resample_filter,GaussianFilter,1.0); 
     1854 
     1855      /* do the variable blurring of each pixel in image */ 
    18501856      pixel=zero; 
    1851       exception=(&image->exception); 
    1852       resample_filter=AcquireResampleFilter(image,&image->exception); 
    1853       SetResampleFilter(resample_filter,GaussianFilter,1.0); 
    18541857      composite_view=AcquireVirtualCacheView(composite_image,exception); 
    18551858      destination_view=AcquireAuthenticCacheView(destination_image,exception); 
     
    18761879          1,exception); 
    18771880        r=QueueCacheViewAuthenticPixels(destination_view,0,y, 
    1878           destination_image->columns,1,&image->exception); 
     1881          destination_image->columns,1,exception); 
    18791882        if ((p == (const PixelPacket *) NULL) || (r == (PixelPacket *) NULL)) 
    18801883          break; 
     
    19601963      */ 
    19611964      destination_image=CloneImage(image,image->columns,image->rows,MagickTrue, 
    1962         &image->exception); 
     1965        exception); 
    19631966      if (destination_image == (Image *) NULL) 
    19641967        return(MagickFalse); 
     
    20412044      */ 
    20422045      pixel=zero; 
    2043       exception=(&image->exception); 
    20442046      image_view=AcquireVirtualCacheView(image,exception); 
    20452047      composite_view=AcquireVirtualCacheView(composite_image,exception); 
     
    20612063          1,exception); 
    20622064        r=QueueCacheViewAuthenticPixels(destination_view,0,y, 
    2063           destination_image->columns,1,&image->exception); 
     2065          destination_image->columns,1,exception); 
    20642066        if ((p == (const PixelPacket *) NULL) || (r == (PixelPacket *) NULL)) 
    20652067          break; 
     
    22142216  midpoint=((MagickRealType) QuantumRange+1.0)/2; 
    22152217  GetMagickPixelPacket(composite_image,&zero); 
    2216   exception=(&image->exception); 
    22172218  composite_view=AcquireVirtualCacheView(composite_image,exception); 
    22182219  image_view=AcquireAuthenticCacheView(image,exception); 
Note: See TracChangeset for help on using the changeset viewer.