MagickExport Image *EdgeImage(const Image *image,const double radius,
ExceptionInfo *exception)
{
- Image
- *edge_image;
+ char
+ geometry[MaxTextExtent];
KernelInfo
*kernel_info;
- register ssize_t
- i;
-
- size_t
- width;
+ Image
+ *edge_image;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- width=GetOptimalKernelWidth1D(radius,0.5);
- kernel_info=AcquireKernelInfo((const char *) NULL);
+ (void) FormatLocaleString(geometry,MaxTextExtent,"square:%.20g",radius);
+ kernel_info=AcquireKernelInfo(geometry);
if (kernel_info == (KernelInfo *) NULL)
ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
- (void) ResetMagickMemory(kernel_info,0,sizeof(*kernel_info));
- kernel_info->width=width;
- kernel_info->height=width;
- kernel_info->x=(ssize_t) (width-1)/2;
- kernel_info->y=(ssize_t) (width-1)/2;
- kernel_info->signature=MagickSignature;
- kernel_info->values=(MagickRealType *) MagickAssumeAligned(
- AcquireAlignedMemory(kernel_info->width,kernel_info->height*
- sizeof(*kernel_info->values)));
- if (kernel_info->values == (MagickRealType *) NULL)
- {
- kernel_info=DestroyKernelInfo(kernel_info);
- ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
- }
- for (i=0; i < (ssize_t) (kernel_info->width*kernel_info->height); i++)
- kernel_info->values[i]=(-1.0);
- kernel_info->values[i/2]=(double) kernel_info->width*kernel_info->height-1.0;
- edge_image=MorphologyApply(image,ConvolveMorphology,1,kernel_info,
+ edge_image=MorphologyApply(image,EdgeInMorphology,1,kernel_info,
UndefinedCompositeOp,0.0,exception);
kernel_info=DestroyKernelInfo(kernel_info);
return(edge_image);