From 10b8bc801774c852503dfc90a706dfa942f9cc2e Mon Sep 17 00:00:00 2001 From: anthony Date: Sat, 2 Oct 2010 12:48:46 +0000 Subject: [PATCH] Sigma Fix for Cylindrical Gaussian Filters (including Mapped Blurs) --- ChangeLog | 8 +++++++ magick/composite.c | 2 +- magick/resample.c | 5 +++-- magick/resize.c | 53 ++++++++++++++++++++++++---------------------- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index aab443b4b..230b41ae5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-10-02 6.6.4-9 Anthony Thyssen + * Added sqrt(2) bluring default for Gaussian Filter if used as a + Cylindrical EWA filter. This resulted in the last aliasing issue + that was present in tests for Gaussian EWA resampling. + However it is still a very blury filter for default use in EWA. + * Adjusted Variable Mapping Blur Composition so user arguments actual + relate properly to the sigma of the blur for a maximum mapping value. + 2010-09-28 6.6.4-8 Nicolas Robidoux * Chantal Racette double checked the bounding parallelogram computation in resample.c (and I tightened the comments). diff --git a/magick/composite.c b/magick/composite.c index c04c86321..db6f048ad 100644 --- a/magick/composite.c +++ b/magick/composite.c @@ -1761,7 +1761,7 @@ MagickExport MagickBooleanType CompositeImageChannel(Image *image, pixel=zero; exception=(&image->exception); resample_filter=AcquireResampleFilter(image,&image->exception); - SetResampleFilter(resample_filter,GaussianFilter,1.0); + SetResampleFilter(resample_filter,GaussianFilter,2.0); destination_view=AcquireCacheView(destination_image); composite_view=AcquireCacheView(composite_image); for (y=0; y < (ssize_t) composite_image->rows; y++) diff --git a/magick/resample.c b/magick/resample.c index fc245dc4c..eaa9fcefc 100644 --- a/magick/resample.c +++ b/magick/resample.c @@ -1779,10 +1779,11 @@ MagickExport void SetResampleFilter(ResampleFilter *resample_filter, resample_filter->filter = PointFilter; } + /* Get the practical working support for the filter, + * after any API call blur factors have been accoded for. + */ #if EWA resample_filter->support = GetResizeFilterSupport(resize_filter); - if ( resample_filter->filter == GaussianFilter ) - resample_filter->support = 2.0; /* larger gaussian support */ #else resample_filter->support = 2.0; /* fixed support size for HQ-EWA */ #endif diff --git a/magick/resize.c b/magick/resize.c index 0ace0c3f8..4f64ceb27 100644 --- a/magick/resize.c +++ b/magick/resize.c @@ -762,47 +762,25 @@ MagickExport ResizeFilter *AcquireResizeFilter(const Image *image, */ filter_type=mapping[filter].filter; window_type=mapping[filter].window; - /* - Filter blur -- scaling both filter and support window. - */ - resize_filter->blur=blur; - artifact=GetImageArtifact(image,"filter:blur"); - if (artifact != (const char *) NULL) - resize_filter->blur=StringToDouble(artifact); - if (resize_filter->blur < MagickEpsilon) - resize_filter->blur=(MagickRealType) MagickEpsilon; - /* - Cylindrical Filters should use Bessel instead of Sinc, unless a - Sinc filter was specifically requested. - Result may be overridden by expert settings later. - */ + /* Cylindrical Filters should use Bessel instead of Sinc */ if (cylindrical != MagickFalse) switch (filter_type) { case SincFilter: - { - /* - Promote 1D Sinc Filter to a 2D Bessel filter, as long as the - user did not directly request a 'Sinc' filter. - */ + /* Promote 1D Sinc Filter to a 2D Bessel filter. */ if ( filter != SincFilter ) filter_type=BesselFilter; break; - } case SincFastFilter: - { /* Ditto for SincFast variant */ if ( filter != SincFastFilter ) filter_type=BesselFilter; break; - } case LanczosFilter: - { - /* Promote Lanczos (Sinc-Sinc) to Lanczos (Bessel-Bessel). */ + /* Promote Lanczos from a Sinc-Sinc to a Bessel-Bessel */ filter_type=BesselFilter; window_type=BesselFilter; break; - } default: /* What about other filters to make them 'cylindrical @@ -866,6 +844,31 @@ MagickExport ResizeFilter *AcquireResizeFilter(const Image *image, resize_filter->window=filters[window_type].function; resize_filter->scale=filters[window_type].scale; resize_filter->signature=MagickSignature; + /* Filter blur -- scaling both filter and support window. */ + resize_filter->blur=blur; + artifact=GetImageArtifact(image,"filter:blur"); + if (artifact != (const char *) NULL) + resize_filter->blur=StringToDouble(artifact); + if (resize_filter->blur < MagickEpsilon) + resize_filter->blur=(MagickRealType) MagickEpsilon; + + if (cylindrical != MagickFalse) + switch (filter_type) + { + case PointFilter: + case BoxFilter: + /* Support for Cylindrical Box should be sqrt(2)/2 */ + resize_filter->support=MagickSQ1_2; + break; + case GaussianFilter: + /* Cylindrical Gaussian should have a sigma of sqrt(2)/2 + * and not the default sigma of 1/2 - so use blur to enlarge + * and adjust support so actual practical support = 2.0 by default + */ + resize_filter->blur *= MagickSQ2; + resize_filter->support = MagickSQ2; /* which times blur => 2.0 */ + break; + } /* Filter support overrides. */ artifact=GetImageArtifact(image,"filter:lobes"); if (artifact != (const char *) NULL) -- 2.50.1