#include "MagickCore/splay-tree.h"
#include "MagickCore/statistic.h"
#include "MagickCore/string_.h"
+#include "MagickCore/threshold.h"
#include "MagickCore/token.h"
#include "MagickCore/utility.h"
\f
{ "Transparent", TransparentAlphaChannel, UndefinedOptionFlag, MagickFalse },
{ (char *) NULL, UndefinedAlphaChannel, UndefinedOptionFlag, MagickFalse }
},
+ AutoThresholdOptions[] =
+ {
+ { "Undefined", UndefinedThresholdMethod, UndefinedOptionFlag, MagickTrue },
+ { "Kapur", KapurThresholdMethod, UndefinedOptionFlag, MagickFalse },
+ { "OTSU", OTSUThresholdMethod, UndefinedOptionFlag, MagickFalse },
+ { "Triangle", TriangleThresholdMethod, UndefinedOptionFlag, MagickFalse },
+ { (char *) NULL, UndefinedThresholdMethod, UndefinedOptionFlag, MagickFalse }
+ },
BooleanOptions[] =
{
{ "False", MagickFalse, UndefinedOptionFlag, MagickFalse },
{ "-auto-level", 0L, SimpleOperatorFlag, MagickFalse },
{ "+auto-orient", 0L, DeprecateOptionFlag, MagickTrue },
{ "-auto-orient", 0L, SimpleOperatorFlag, MagickFalse },
+ { "+auto-threshold", 1L, DeprecateOptionFlag, MagickTrue },
+ { "-auto-threshold", 1L, SimpleOperatorFlag, MagickFalse },
{ "+average", 0L, DeprecateOptionFlag, MagickTrue },
{ "-average", 0L, ReplacedOptionFlag | ListOperatorFlag | FireOptionFlag, MagickTrue },
{ "+backdrop", 0L, NonMagickOptionFlag | NeverInterpretArgsFlag, MagickFalse },
{
{ "Align", MagickAlignOptions, UndefinedOptionFlag, MagickFalse },
{ "Alpha", MagickAlphaChannelOptions, UndefinedOptionFlag, MagickFalse },
+ { "AutoThreshold", MagickAutoThresholdOptions, UndefinedOptionFlag, MagickFalse },
{ "Boolean", MagickBooleanOptions, UndefinedOptionFlag, MagickFalse },
{ "Cache", MagickCacheOptions, UndefinedOptionFlag, MagickFalse },
{ "Channel", MagickChannelOptions, UndefinedOptionFlag, MagickFalse },
{
case MagickAlignOptions: return(AlignOptions);
case MagickAlphaChannelOptions: return(AlphaChannelOptions);
+ case MagickAutoThresholdOptions: return(AutoThresholdOptions);
case MagickBooleanOptions: return(BooleanOptions);
case MagickCacheOptions: return(CacheOptions);
case MagickChannelOptions: return(ChannelOptions);
MagickTypeOptions,
MagickValidateOptions,
MagickVirtualPixelOptions,
- MagickWeightOptions
+ MagickWeightOptions,
+ MagickAutoThresholdOptions
} CommandOption;
typedef enum
% %
% %
% %
+% A u t o T h r e s o l d I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AutoThresholdImage() ...
+%
+% The format of the AutoThresholdImage method is:
+%
+% MagickBooleanType AutoThresholdImage(Image *image,
+% const AutoThresholdMethod threshold_type,ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o image: The image to auto-threshold.
+%
+% o threshold_type: choose from Kapur, OTSU, or Triangle.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+MagickExport MagickBooleanType AutoThresholdImage(Image *image,
+ const AutoThresholdMethod threshold_type,ExceptionInfo *exception)
+{
+ return(MagickTrue);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
% B i l e v e l I m a g e %
% %
% %
extern "C" {
#endif
+typedef enum
+{
+ UndefinedThresholdMethod,
+ KapurThresholdMethod,
+ OTSUThresholdMethod,
+ TriangleThresholdMethod
+} AutoThresholdMethod;
+
typedef struct _ThresholdMap
ThresholdMap;
*GetThresholdMap(const char *,ExceptionInfo *);
extern MagickExport MagickBooleanType
+ AutoThresholdImage(Image *,const AutoThresholdMethod,ExceptionInfo *),
BilevelImage(Image *,const double,ExceptionInfo *),
BlackThresholdImage(Image *,const char *,ExceptionInfo *),
ClampImage(Image *,ExceptionInfo *),
"-auto-gamma automagically adjust gamma level of image",
"-auto-level automagically adjust color levels of image",
"-auto-orient automagically orient (rotate) image",
+ "-auto-threshold method",
+ " automatically perform image thresholding",
"-bench iterations measure performance",
"-black-threshold value",
" force all pixels below the threshold into black",
break;
if (LocaleCompare("auto-orient",option+1) == 0)
break;
+ if (LocaleCompare("auto-threshold",option+1) == 0)
+ {
+ ssize_t
+ method;
+
+ if (*option == '+')
+ break;
+ i++;
+ if (i == (ssize_t) argc)
+ ThrowMogrifyException(OptionError,"MissingArgument",option);
+ method=ParseCommandOption(MagickAutoThresholdOptions,MagickFalse,
+ argv[i]);
+ if (method < 0)
+ ThrowMogrifyException(OptionError,"UnrecognizedThresholdMethod",
+ argv[i]);
+ break;
+ }
if (LocaleCompare("average",option+1) == 0)
break;
ThrowConvertException(OptionError,"UnrecognizedOption",option)
exception);
break;
}
+ if (LocaleCompare("auto-threshold",option+1) == 0)
+ {
+ AutoThresholdMethod
+ method;
+
+ (void) SyncImageSettings(mogrify_info,*image,exception);
+ method=(AutoThresholdMethod) ParseCommandOption(
+ MagickAutoThresholdOptions,MagickFalse,argv[i+1]);
+ (void) AutoThresholdImage(*image,method,exception);
+ break;
+ }
break;
}
case 'b':
"-auto-gamma automagically adjust gamma level of image",
"-auto-level automagically adjust color levels of image",
"-auto-orient automagically orient (rotate) image",
+ "-auto-threshold method",
+ " automatically perform image thresholding",
"-bench iterations measure performance",
"-black-threshold value",
" force all pixels below the threshold into black",
break;
if (LocaleCompare("auto-orient",option+1) == 0)
break;
+ if (LocaleCompare("auto-threshold",option+1) == 0)
+ {
+ ssize_t
+ method;
+
+ if (*option == '+')
+ break;
+ i++;
+ if (i == (ssize_t) argc)
+ ThrowMogrifyException(OptionError,"MissingArgument",option);
+ method=ParseCommandOption(MagickAutoThresholdOptions,MagickFalse,
+ argv[i]);
+ if (method < 0)
+ ThrowMogrifyException(OptionError,"UnrecognizedThresholdMethod",
+ argv[i]);
+ break;
+ }
if (LocaleCompare("average",option+1) == 0)
break;
ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
new_image=AutoOrientImage(_image,_image->orientation,_exception);
break;
}
+ if (LocaleCompare("auto-threshold",option+1) == 0)
+ {
+ AutoThresholdMethod
+ method;
+
+ method=(AutoThresholdMethod) ParseCommandOption(
+ MagickAutoThresholdOptions,MagickFalse,argv[i+1]);
+ (void) AutoThresholdImage(_image,method,_exception);
+ break;
+ }
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'b':
\-auto-gamma automagically adjust gamma level of image
\-auto-level automagically adjust color levels of image
\-auto-orient automatically orient image
+ \-auto-threshold method
+ automatically perform image thresholding
\-bench iterations measure performance
\-black-threshold value
force all pixels below the threshold into black
\-auto-gamma automagically adjust gamma level of image
\-auto-level automagically adjust color levels of image
\-auto-orient automatically orient image
+ \-auto-threshold method
+ automatically perform image thresholding
\-bench iterations measure performance
\-black-threshold value
force all pixels below the threshold into black