channel to exist, to add transparency.
*/
if (image->matte == MagickFalse)
- (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
+ {
+ (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
+ image->matte=MagickFalse;
+ }
break;
}
case BlurCompositeOp:
blur;
/*
+ Blur Image by resampling.
+
Blur Image dictated by an overlay gradient map: X = red_channel;
Y = green_channel; compose:args = x_scale[,y_scale[,angle]].
*/
if (destination_image == (Image *) NULL)
return(MagickFalse);
/*
- Determine the horizontal and vertical maximim blur.
+ Gather the maximum blur sigma values from user.
*/
SetGeometryInfo(&geometry_info);
flags=NoValue;
value=GetImageArtifact(composite_image,"compose:args");
if (value != (char *) NULL)
flags=ParseGeometry(value,&geometry_info);
- if ((flags & WidthValue) == 0 )
- {
+ if ((flags & WidthValue) == 0 ) {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ OptionWarning,"InvalidSetting","'%s' '%s'",
+ "compose:args",value);
destination_image=DestroyImage(destination_image);
return(MagickFalse);
}
- width=geometry_info.rho;
- height=geometry_info.sigma;
- blur.x1=geometry_info.rho;
+ /*
+ Users input sigma now needs to be converted to the EWA ellipse size.
+ The filter defaults to a sigma of 0.5 so to make this match the
+ users input the ellipse size needs to be doubled.
+ */
+ width=height=geometry_info.rho*2.0;
+ if ((flags & HeightValue) != 0 )
+ height=geometry_info.sigma*2.0;
+
+ /* default the unrotated ellipse width and height axis vectors */
+ blur.x1=width;
blur.x2=0.0;
blur.y1=0.0;
- blur.y2=geometry_info.sigma;
- angle_start=0.0;
- angle_range=0.0;
- if ((flags & HeightValue) == 0)
- blur.y2=blur.x1;
+ blur.y2=height;
+ /* rotate vectors if a rotation angle is given */
if ((flags & XValue) != 0 )
{
MagickRealType
blur.y1=(-height*sin(angle));
blur.y2=height*cos(angle);
}
+ /* Otherwise lets set a angle range and calculate in the loop */
+ angle_start=0.0;
+ angle_range=0.0;
if ((flags & YValue) != 0 )
{
angle_start=DegreesToRadians(geometry_info.xi);
angle_range=DegreesToRadians(geometry_info.psi)-angle_start;
}
/*
- Blur Image by resampling.
- FUTURE: this is currently broken, especially for small sigma blurs
- This needs to be fixed to use a non-user filter setup that provides
- far more control than currently available.
+ Set up a gaussian cylindrical filter for EWA Bluring.
+
+ As the minimum ellipse radius of support*1.0 the EWA algorithm
+ can only produce a minimum blur of 0.5 for Gaussian (support=2.0)
+ This means that even 'No Blur' will be still a little blurry!
+
+ The solution (as well as the problem of preventing any user
+ expert filter settings, is to set our own user settings, then
+ restore them afterwards.
*/
resample_filter=AcquireResampleFilter(image,exception);
- SetResampleFilter(resample_filter,GaussianFilter); /* was blur*2 */
+ SetResampleFilter(resample_filter,GaussianFilter);
+
+ /* do the variable blurring of each pixel in image */
+ GetPixelInfo(image,&pixel);
composite_view=AcquireVirtualCacheView(composite_image,exception);
destination_view=AcquireAuthenticCacheView(destination_image,exception);
for (y=0; y < (ssize_t) composite_image->rows; y++)
blur.y1=(-height*sin(angle));
blur.y2=height*cos(angle);
}
- ScaleResampleFilter(resample_filter,blur.x1*QuantumScale*
- GetPixelRed(composite_image,p),blur.y1*QuantumScale*
- GetPixelGreen(composite_image,p),blur.x2*QuantumScale*
- GetPixelRed(composite_image,p),blur.y2*QuantumScale*
- GetPixelGreen(composite_image,p));
+#if 0
+ if ( x == 10 && y == 60 ) {
+ fprintf(stderr, "blur.x=%lf,%lf, blur.y=%lf,%lf\n",
+ blur.x1, blur.x2, blur.y1, blur.y2);
+ fprintf(stderr, "scaled by=%lf,%lf\n",
+ QuantumScale*GetPixelRed(p), QuantumScale*GetPixelGreen(p));
+#endif
+ ScaleResampleFilter(resample_filter,
+ blur.x1*QuantumScale*GetPixelRed(composite_image,p),
+ blur.y1*QuantumScale*GetPixelGreen(composite_image,p),
+ blur.x2*QuantumScale*GetPixelRed(composite_image,p),
+ blur.y2*QuantumScale*GetPixelGreen(composite_image,p) );
(void) ResamplePixelColor(resample_filter,(double) x_offset+x,
(double) y_offset+y,&pixel,exception);
SetPixelInfoPixel(destination_image,&pixel,q);
destination_dissolve=geometry_info.sigma/100.0;
if ((destination_dissolve-MagickEpsilon) < 0.0)
destination_dissolve=0.0;
+ /* posible speed up? -- from IMv6 update
+ clip_to_self=MagickFalse;
+ if ((destination_dissolve+MagickEpsilon) > 1.0 )
+ {
+ destination_dissolve=1.0;
+ clip_to_self=MagickTrue;
+ }
+ */
}
break;
}