diff --git a/Magick++/lib/Image.cpp b/Magick++/lib/Image.cpp
index b27545b..d4ccc77 100644
--- a/Magick++/lib/Image.cpp
+++ b/Magick++/lib/Image.cpp
@@ -1318,7 +1318,8 @@
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
MagickCore::Image* newImage =
- StatisticImage ( image(), MedianStatistic, radius_, &exceptionInfo );
+ StatisticImage ( image(), MedianStatistic, (size_t) radius_, (size_t)
+ radius_,&exceptionInfo );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
@@ -1709,7 +1710,8 @@
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
MagickCore::Image* newImage =
- StatisticImage( image(), NonpeakStatistic, order_, &exceptionInfo );
+ StatisticImage( image(), NonpeakStatistic, (size_t) order_, (size_t) order_,
+ &exceptionInfo );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs
index ebf3598..ea03e1f 100644
--- a/PerlMagick/Magick.xs
+++ b/PerlMagick/Magick.xs
@@ -241,11 +241,13 @@
{ "Implode", { {"amount", RealReference},
{"interpolate", MagickInterpolateOptions} } },
{ "Magnify", },
- { "MedianFilter", { {"radius", RealReference}
- {"channel", MagickChannelOptions} } },
+ { "MedianFilter", { {"geometry", StringReference},
+ {"width", IntegerReference},{"height", IntegerReference},
+ {"channel", MagickChannelOptions} } },
{ "Minify", },
{ "OilPaint", { {"radius", RealReference} } },
- { "ReduceNoise", { {"radius", RealReference},
+ { "ReduceNoise", { {"geometry", StringReference},
+ {"width", IntegerReference},{"height", IntegerReference},
{"channel", MagickChannelOptions} } },
{ "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
{"y", IntegerReference} } },
@@ -534,9 +536,11 @@
{"iterations", IntegerReference} } },
{ "ColorMatrix", { {"matrix", ArrayReference} } },
{ "Color", { {"color", StringReference} } },
- { "Mode", { {"radius", RealReference},
+ { "Mode", { {"geometry", StringReference},
+ {"width", IntegerReference},{"height", IntegerReference},
{"channel", MagickChannelOptions} } },
- { "Statistic", { {"radius", RealReference},
+ { "Statistic", { {"geometry", StringReference},
+ {"width", IntegerReference},{"height", IntegerReference},
{"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
};
@@ -7794,12 +7798,21 @@
}
case 18: /* MedianFilter */
{
- if (attribute_flag[0] == 0)
- argument_list[0].real_reference=0.0;
+ if (attribute_flag[0] != 0)
+ {
+ flags=ParseGeometry(argument_list[0].string_reference,
+ &geometry_info);
+ if ((flags & SigmaValue) == 0)
+ geometry_info.sigma=1.0;
+ }
if (attribute_flag[1] != 0)
- channel=(ChannelType) argument_list[1].integer_reference;
- image=StatisticImage(image,channel,MedianStatistics,
- argument_list[0].real_reference,exception);
+ geometry_info.rho=argument_list[1].real_reference;
+ if (attribute_flag[2] != 0)
+ geometry_info.sigma=argument_list[2].real_reference;
+ if (attribute_flag[3] != 0)
+ channel=(ChannelType) argument_list[3].integer_reference;
+ image=StatisticImage(image,channel,MedianStatistic,
+ (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
break;
}
case 19: /* Minify */
@@ -7817,14 +7830,21 @@
}
case 21: /* ReduceNoise */
{
- if (attribute_flag[0] == 0)
- argument_list[0].real_reference=0.0;
- image=ReduceNoiseImage(image,argument_list[0].real_reference,
- exception);
+ if (attribute_flag[0] != 0)
+ {
+ flags=ParseGeometry(argument_list[0].string_reference,
+ &geometry_info);
+ if ((flags & SigmaValue) == 0)
+ geometry_info.sigma=1.0;
+ }
if (attribute_flag[1] != 0)
- channel=(ChannelType) argument_list[1].integer_reference;
+ geometry_info.rho=argument_list[1].real_reference;
+ if (attribute_flag[2] != 0)
+ geometry_info.sigma=argument_list[2].real_reference;
+ if (attribute_flag[3] != 0)
+ channel=(ChannelType) argument_list[3].integer_reference;
image=StatisticImage(image,channel,NonpeakStatistic,
- argument_list[0].real_reference,exception);
+ (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
break;
}
case 22: /* Roll */
@@ -10629,12 +10649,21 @@
}
case 136: /* Mode */
{
- if (attribute_flag[0] == 0)
- argument_list[0].real_reference=0.0;
+ if (attribute_flag[0] != 0)
+ {
+ flags=ParseGeometry(argument_list[0].string_reference,
+ &geometry_info);
+ if ((flags & SigmaValue) == 0)
+ geometry_info.sigma=1.0;
+ }
if (attribute_flag[1] != 0)
- channel=(ChannelType) argument_list[1].integer_reference;
+ geometry_info.rho=argument_list[1].real_reference;
+ if (attribute_flag[2] != 0)
+ geometry_info.sigma=argument_list[2].real_reference;
+ if (attribute_flag[3] != 0)
+ channel=(ChannelType) argument_list[3].integer_reference;
image=StatisticImage(image,channel,ModeStatistic,
- argument_list[0].real_reference,exception);
+ (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
break;
}
case 137: /* Statistic */
@@ -10643,14 +10672,23 @@
statistic;
statistic=UndefinedStatistic;
- if (attribute_flag[0] == 0)
- argument_list[0].real_reference=0.0;
+ if (attribute_flag[0] != 0)
+ {
+ flags=ParseGeometry(argument_list[0].string_reference,
+ &geometry_info);
+ if ((flags & SigmaValue) == 0)
+ geometry_info.sigma=1.0;
+ }
if (attribute_flag[1] != 0)
- channel=(ChannelType) argument_list[1].integer_reference;
+ geometry_info.rho=argument_list[1].real_reference;
if (attribute_flag[2] != 0)
- statistic=(StatisticType) argument_list[2].integer_reference;
+ geometry_info.sigma=argument_list[2].real_reference;
+ if (attribute_flag[3] != 0)
+ channel=(ChannelType) argument_list[3].integer_reference;
+ if (attribute_flag[4] != 0)
+ statistic=(StatisticType) argument_list[4].integer_reference;
image=StatisicImageChannel(image,channel,statistic,
- argument_list[0].real_reference,exception);
+ (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
break;
}
}
diff --git a/coders/msl.c b/coders/msl.c
index 9eeca01..addf644 100644
--- a/coders/msl.c
+++ b/coders/msl.c
@@ -3816,7 +3816,8 @@
}
}
median_image=StatisticImage(msl_info->image[n],MedianStatistic,
- geometry_info.rho,&msl_info->image[n]->exception);
+ (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
+ &msl_info->image[n]->exception);
if (median_image == (Image *) NULL)
break;
msl_info->image[n]=DestroyImage(msl_info->image[n]);
@@ -5040,7 +5041,8 @@
}
}
paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
- geometry_info.rho,&msl_info->image[n]->exception);
+ (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
+ &msl_info->image[n]->exception);
if (paint_image == (Image *) NULL)
break;
msl_info->image[n]=DestroyImage(msl_info->image[n]);
diff --git a/magick/deprecate.c b/magick/deprecate.c
index 9d30a58..9506e3c 100644
--- a/magick/deprecate.c
+++ b/magick/deprecate.c
@@ -4602,7 +4602,8 @@
Image
*median_image;
- median_image=StatisticImage(image,MedianStatistic,radius,exception);
+ median_image=StatisticImage(image,MedianStatistic,(size_t) radius,(size_t)
+ radius,exception);
return(median_image);
}
@@ -4640,7 +4641,8 @@
Image
*mode_image;
- mode_image=StatisticImage(image,ModeStatistic,radius,exception);
+ mode_image=StatisticImage(image,ModeStatistic,(size_t) radius,(size_t) radius,
+ exception);
return(mode_image);
}
@@ -5685,7 +5687,8 @@
Image
*reduce_image;
- reduce_image=StatisticImage(image,NonpeakStatistic,radius,exception);
+ reduce_image=StatisticImage(image,NonpeakStatistic,(size_t) radius,(size_t)
+ radius,exception);
return(reduce_image);
}
diff --git a/magick/display.c b/magick/display.c
index 221cf05..527d3e5 100644
--- a/magick/display.c
+++ b/magick/display.c
@@ -8073,8 +8073,8 @@
XSetCursorState(display,windows,MagickTrue);
XCheckRefreshWindows(display,windows);
flags=ParseGeometry(radius,&geometry_info);
- noise_image=StatisticImage(*image,NonpeakStatistic,geometry_info.rho,
- &(*image)->exception);
+ noise_image=StatisticImage(*image,NonpeakStatistic,(size_t)
+ geometry_info.rho,(size_t) geometry_info.rho,&(*image)->exception);
if (noise_image != (Image *) NULL)
{
*image=DestroyImage(*image);
diff --git a/magick/effect.c b/magick/effect.c
index 0bde3c2..80ff9df 100644
--- a/magick/effect.c
+++ b/magick/effect.c
@@ -3079,8 +3079,8 @@
}
case ReduceNoisePreview:
{
- preview_image=StatisticImage(thumbnail,NonpeakStatistic,radius,
- exception);
+ preview_image=StatisticImage(thumbnail,NonpeakStatistic,(size_t) radius,
+ (size_t) radius,exception);
(void) FormatMagickString(label,MaxTextExtent,"noise %g",radius);
break;
}
@@ -3124,7 +3124,7 @@
break;
}
}
- preview_image=StatisticImage(thumbnail,NonpeakStatistic,(double) i,
+ preview_image=StatisticImage(thumbnail,NonpeakStatistic,i,i,
exception);
(void) FormatMagickString(label,MaxTextExtent,"+noise %s",factor);
break;
@@ -4534,10 +4534,10 @@
% The format of the StatisticImage method is:
%
% Image *StatisticImage(const Image *image,const StatisticType type,
-% const double radius,ExceptionInfo *exception)
+% const size_t width,const size_t height,ExceptionInfo *exception)
% Image *StatisticImageChannel(const Image *image,
% const ChannelType channel,const StatisticType type,
-% const double radius,ExceptionInfo *exception)
+% const size_t width,const size_t height,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
@@ -4547,7 +4547,9 @@
%
% o type: the statistic type (median, mode, etc.).
%
-% o radius: the radius of the pixel neighborhood.
+% o width: the width of the pixel neighborhood.
+%
+% o height: the height of the pixel neighborhood.
%
% o exception: return any errors or warnings in this structure.
%
@@ -4949,14 +4951,19 @@
}
MagickExport Image *StatisticImage(const Image *image,const StatisticType type,
- const double radius,ExceptionInfo *exception)
+ const size_t width,const size_t height,ExceptionInfo *exception)
{
- return(StatisticImageChannel(image,DefaultChannels,type,radius,exception));
+ Image
+ *statistic_image;
+
+ statistic_image=StatisticImageChannel(image,DefaultChannels,type,width,
+ height,exception);
+ return(statistic_image);
}
MagickExport Image *StatisticImageChannel(const Image *image,
- const ChannelType channel,const StatisticType type,const double radius,
- ExceptionInfo *exception)
+ const ChannelType channel,const StatisticType type,const size_t width,
+ const size_t height,ExceptionInfo *exception)
{
#define StatisticImageTag "Statistic/Image"
@@ -4976,9 +4983,6 @@
PixelList
**restrict pixel_list;
- size_t
- width;
-
ssize_t
y;
@@ -4991,7 +4995,6 @@
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- width=GetOptimalKernelWidth2D(radius,0.5);
statistic_image=CloneImage(image,image->columns,image->rows,MagickTrue,
exception);
if (statistic_image == (Image *) NULL)
@@ -5041,7 +5044,7 @@
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t)
- (width/2L),image->columns+width,width,exception);
+ (height/2L),image->columns+width,height,exception);
q=QueueCacheViewAuthenticPixels(statistic_view,0,y,
statistic_image->columns,1,exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
@@ -5071,7 +5074,7 @@
ResetPixelList(pixel_list[id]);
for (v=0; v < (ssize_t) width; v++)
{
- for (u=0; u < (ssize_t) width; u++)
+ for (u=0; u < (ssize_t) height; u++)
InsertPixelList(image,r+u,s+u,pixel_list[id]);
r+=image->columns+width;
s+=image->columns+width;
diff --git a/magick/effect.h b/magick/effect.h
index 0c5f8f2..437eab5 100644
--- a/magick/effect.h
+++ b/magick/effect.h
@@ -110,9 +110,10 @@
*SharpenImageChannel(const Image *,const ChannelType,const double,
const double,ExceptionInfo *),
*SpreadImage(const Image *,const double,ExceptionInfo *),
- *StatisticImage(const Image *,const StatisticType,const double,ExceptionInfo *),
+ *StatisticImage(const Image *,const StatisticType,const size_t,const size_t,
+ ExceptionInfo *),
*StatisticImageChannel(const Image *,const ChannelType,const StatisticType,
- const double,ExceptionInfo *),
+ const size_t,const size_t,ExceptionInfo *),
*UnsharpMaskImage(const Image *,const double,const double,const double,
const double,ExceptionInfo *),
*UnsharpMaskImageChannel(const Image *,const ChannelType,const double,
diff --git a/magick/shear.c b/magick/shear.c
index abfe231..d5d96a1 100644
--- a/magick/shear.c
+++ b/magick/shear.c
@@ -968,7 +968,7 @@
clone_image=DestroyImage(clone_image);
if (deskew_image == (Image *) NULL)
return((Image *) NULL);
- median_image=StatisticImage(deskew_image,MedianStatistic,0.0,exception);
+ median_image=StatisticImage(deskew_image,MedianStatistic,3,3,exception);
if (median_image == (Image *) NULL)
{
deskew_image=DestroyImage(deskew_image);
diff --git a/utilities/convert.1.in b/utilities/convert.1.in
index 045b8c3..574aa74 100644
--- a/utilities/convert.1.in
+++ b/utilities/convert.1.in
@@ -76,7 +76,7 @@
\-scene value image scene number
\-seed value seed a new sequence of pseudo-random numbers
\-size geometry width and height of image
- \-statistic type radius
+ \-statistic type geometry
replace each pixel with corresponding statistic from the neighborhood
\-stretch type render text with this font stretch
\-stroke color graphic primitive stroke color
diff --git a/utilities/mogrify.1.in b/utilities/mogrify.1.in
index cbdba4d..418135e 100644
--- a/utilities/mogrify.1.in
+++ b/utilities/mogrify.1.in
@@ -206,7 +206,7 @@
\-solarize threshold negate all pixels above the threshold level
\-splice geometry splice the background color into the image
\-spread amount displace image pixels by a random amount
- \-statistic type radius
+ \-statistic type geometry
replace each pixel with corresponding statistic from the neighborhood
\-strip strip image of all profiles and comments
\-swirl degrees swirl image pixels about the center
diff --git a/wand/convert.c b/wand/convert.c
index 32f6815..de9d74e 100644
--- a/wand/convert.c
+++ b/wand/convert.c
@@ -269,7 +269,7 @@
" fill in a image based on a few color points",
"-splice geometry splice the background color into the image",
"-spread radius displace image pixels by a random amount",
- "-statistic type radius",
+ "-statistic type geometry",
" replace each pixel with corresponding statistic from the neighborhood",
"-strip strip image of all profiles and comments",
"-swirl degrees swirl image pixels about the center",
diff --git a/wand/magick-image.c b/wand/magick-image.c
index 6053f79..70bda09 100644
--- a/wand/magick-image.c
+++ b/wand/magick-image.c
@@ -11694,9 +11694,10 @@
% The format of the MagickStatisticImage method is:
%
% MagickBooleanType MagickStatisticImage(MagickWand *wand,
-% const StatisticType type,const double radius)
+% const StatisticType type,const double width,const size_t height)
% MagickBooleanType MagickStatisticImageChannel(MagickWand *wand,
-% const ChannelType channel,const StatisticType type,const double radius)
+% const ChannelType channel,const StatisticType type,const double width,
+% const size_t height)
%
% A description of each parameter follows:
%
@@ -11710,7 +11711,8 @@
%
*/
WandExport MagickBooleanType MagickStatisticImage(MagickWand *wand,
- const ChannelType channel,const StatisticType type,const double radius)
+ const ChannelType channel,const StatisticType type,const size_t width,
+ const size_t height)
{
Image
*statistic_image;
@@ -11721,7 +11723,7 @@
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->images == (Image *) NULL)
ThrowWandException(WandError,"ContainsNoImages",wand->name);
- statistic_image=StatisticImageChannel(wand->images,channel,type,radius,
+ statistic_image=StatisticImageChannel(wand->images,channel,type,width,height,
wand->exception);
if (statistic_image == (Image *) NULL)
return(MagickFalse);
diff --git a/wand/magick-image.h b/wand/magick-image.h
index 25eb083..0678844 100644
--- a/wand/magick-image.h
+++ b/wand/magick-image.h
@@ -339,8 +339,9 @@
const ssize_t),
MagickSpreadImage(MagickWand *,const double),
MagickStatisticImage(MagickWand *,const ChannelType,const StatisticType,
- const double),
- MagickStatisticImageChannel(MagickWand *,const StatisticType,const double),
+ const size_t,const size_t),
+ MagickStatisticImageChannel(MagickWand *,const StatisticType,const size_t,
+ const size_t),
MagickStripImage(MagickWand *),
MagickSwirlImage(MagickWand *,const double),
MagickTintImage(MagickWand *,const PixelWand *,const PixelWand *),
diff --git a/wand/mogrify.c b/wand/mogrify.c
index dbad01e..4e7e33c 100644
--- a/wand/mogrify.c
+++ b/wand/mogrify.c
@@ -2191,7 +2191,7 @@
(void) SyncImageSettings(mogrify_info,*image);
(void) ParseGeometry(argv[i+1],&geometry_info);
median_image=StatisticImageChannel(*image,channel,MedianStatistic,
- geometry_info.rho,exception);
+ (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception);
if (median_image == (Image *) NULL)
break;
*image=DestroyImage(*image);
@@ -2209,7 +2209,7 @@
(void) SyncImageSettings(mogrify_info,*image);
(void) ParseGeometry(argv[i+1],&geometry_info);
mode_image=StatisticImageChannel(*image,channel,ModeStatistic,
- geometry_info.rho,exception);
+ (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception);
if (mode_image == (Image *) NULL)
break;
*image=DestroyImage(*image);
@@ -2335,7 +2335,8 @@
{
(void) ParseGeometry(argv[i+1],&geometry_info);
noisy_image=StatisticImageChannel(*image,channel,
- NonpeakStatistic,geometry_info.rho,exception);
+ NonpeakStatistic,(size_t) geometry_info.rho,(size_t)
+ geometry_info.rho,exception);
}
else
{
@@ -3171,7 +3172,8 @@
MagickFalse,argv[i+1]);
(void) ParseGeometry(argv[i+2],&geometry_info);
statistic_image=StatisticImageChannel(*image,channel,type,
- geometry_info.rho,exception);
+ (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
+ exception);
if (statistic_image == (Image *) NULL)
break;
*image=DestroyImage(*image);