kernel_info->values[i]=(-1.0);
kernel_info->values[i/2]=(double) kernel_info->width*kernel_info->height-1.0;
edge_image=ConvolveImage(image,kernel_info,exception);
- if (edge_image != (Image *) NULL)
- (void) ClampImage(edge_image,exception);
kernel_info=DestroyKernelInfo(kernel_info);
return(edge_image);
}
MagickExport Image *ShadeImage(const Image *image,const MagickBooleanType gray,
const double azimuth,const double elevation,ExceptionInfo *exception)
{
+#define GetShadeIntensity(image,pixel) \
+ ClampPixel(GetPixelIntensity((image),(pixel)))
#define ShadeImageTag "Shade/Image"
CacheView
center=pre+(linear_image->columns+2)*GetPixelChannels(linear_image);
post=center+(linear_image->columns+2)*GetPixelChannels(linear_image);
normal.x=(double) (
- GetPixelIntensity(linear_image,pre-GetPixelChannels(linear_image))+
- GetPixelIntensity(linear_image,center-GetPixelChannels(linear_image))+
- GetPixelIntensity(linear_image,post-GetPixelChannels(linear_image))-
- GetPixelIntensity(linear_image,pre+GetPixelChannels(linear_image))-
- GetPixelIntensity(linear_image,center+GetPixelChannels(linear_image))-
- GetPixelIntensity(linear_image,post+GetPixelChannels(linear_image)));
+ GetShadeIntensity(linear_image,pre-GetPixelChannels(linear_image))+
+ GetShadeIntensity(linear_image,center-GetPixelChannels(linear_image))+
+ GetShadeIntensity(linear_image,post-GetPixelChannels(linear_image))-
+ GetShadeIntensity(linear_image,pre+GetPixelChannels(linear_image))-
+ GetShadeIntensity(linear_image,center+GetPixelChannels(linear_image))-
+ GetShadeIntensity(linear_image,post+GetPixelChannels(linear_image)));
normal.y=(double) (
- GetPixelIntensity(linear_image,post-GetPixelChannels(linear_image))+
- GetPixelIntensity(linear_image,post)+
- GetPixelIntensity(linear_image,post+GetPixelChannels(linear_image))-
- GetPixelIntensity(linear_image,pre-GetPixelChannels(linear_image))-
- GetPixelIntensity(linear_image,pre)-
- GetPixelIntensity(linear_image,pre+GetPixelChannels(linear_image)));
+ GetShadeIntensity(linear_image,post-GetPixelChannels(linear_image))+
+ GetShadeIntensity(linear_image,post)+
+ GetShadeIntensity(linear_image,post+GetPixelChannels(linear_image))-
+ GetShadeIntensity(linear_image,pre-GetPixelChannels(linear_image))-
+ GetShadeIntensity(linear_image,pre)-
+ GetShadeIntensity(linear_image,pre+GetPixelChannels(linear_image)));
if ((fabs(normal.x) <= MagickEpsilon) &&
(fabs(normal.y) <= MagickEpsilon))
shade=light.z;
{
Image
*charcoal_image,
- *clone_image,
*edge_image;
assert(image != (Image *) NULL);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
- clone_image=CloneImage(image,0,0,MagickTrue,exception);
- if (clone_image == (Image *) NULL)
- return((Image *) NULL);
- edge_image=EdgeImage(clone_image,radius,exception);
- clone_image=DestroyImage(clone_image);
+ edge_image=EdgeImage(image,radius,exception);
if (edge_image == (Image *) NULL)
return((Image *) NULL);
charcoal_image=BlurImage(edge_image,radius,sigma,exception);