19 #ifndef _MAGICKCORE_ACCELERATE_PRIVATE_H
20 #define _MAGICKCORE_ACCELERATE_PRIVATE_H
22 #if defined(__cplusplus) || defined(c_plusplus)
27 #if defined(MAGICKCORE_OPENCL_SUPPORT)
29 #define OPENCL_DEFINE(VAR,...) "\n #""define " #VAR " " #__VA_ARGS__ " \n"
30 #define OPENCL_ELIF(...) "\n #""elif " #__VA_ARGS__ " \n"
31 #define OPENCL_ELSE() "\n #""else " " \n"
32 #define OPENCL_ENDIF() "\n #""endif " " \n"
33 #define OPENCL_IF(...) "\n #""if " #__VA_ARGS__ " \n"
34 #define STRINGIFY(...) #__VA_ARGS__ "\n"
36 typedef struct _FloatPixelPacket
38 #ifdef MAGICK_PIXEL_RGBA
45 #ifdef MAGICK_PIXEL_BGRA
54 const char* accelerateKernels =
87 inline CLQuantum ScaleCharToQuantum(
const unsigned char value)
89 return((CLQuantum) value);
96 inline CLQuantum ScaleCharToQuantum(
const unsigned char value)
98 return((CLQuantum) (257.0f*value));
105 inline CLQuantum ScaleCharToQuantum(
const unsigned char value)
107 return((CLQuantum) (16843009.0*value));
115 inline
int ClampToCanvas(const
int offset,const
int range)
117 return clamp(offset, (
int)0, range-1);
122 inline int ClampToCanvasWithHalo(
const int offset,
const int range,
const int edge,
const int section)
124 return clamp(offset, section?(
int)(0-edge):(
int)0, section?(range-1):(range-1+edge));
131 return (CLQuantum) (clamp(value, 0.0f, (
float)
QuantumRange) + 0.5f);
136 inline uint ScaleQuantumToMap(CLQuantum value)
138 if (value >= (CLQuantum)
MaxMap)
141 return ((uint)value);
148 float sign = x < (float) 0.0 ? (
float) -1.0 : (float) 1.0;
214 return clamp(value,0.0f,1.0f);
220 inline CLQuantum getBlue(CLPixelType p) {
return p.x; }
221 inline void setBlue(CLPixelType* p, CLQuantum value) { (*p).x = value; }
222 inline float getBlueF4(float4 p) {
return p.x; }
223 inline void setBlueF4(float4* p,
float value) { (*p).x = value; }
225 inline CLQuantum getGreen(CLPixelType p) {
return p.y; }
226 inline void setGreen(CLPixelType* p, CLQuantum value) { (*p).y = value; }
227 inline float getGreenF4(float4 p) {
return p.y; }
228 inline void setGreenF4(float4* p,
float value) { (*p).y = value; }
230 inline CLQuantum getRed(CLPixelType p) {
return p.z; }
231 inline void setRed(CLPixelType* p, CLQuantum value) { (*p).z = value; }
232 inline float getRedF4(float4 p) {
return p.z; }
233 inline void setRedF4(float4* p,
float value) { (*p).z = value; }
235 inline CLQuantum getOpacity(CLPixelType p) {
return p.w; }
236 inline void setOpacity(CLPixelType* p, CLQuantum value) { (*p).w = value; }
237 inline float getOpacityF4(float4 p) {
return p.w; }
238 inline void setOpacityF4(float4* p,
float value) { (*p).w = value; }
240 inline void setGray(CLPixelType* p, CLQuantum value) { (*p).z = value; (*p).y = value; (*p).x = value; }
242 inline float GetPixelIntensity(
const int method,
const int colorspace, CLPixelType p)
244 float red = getRed(p);
245 float green = getGreen(p);
246 float blue = getBlue(p);
257 intensity=(red+green+blue)/3.0;
262 intensity=max(max(red,green),blue);
267 intensity=(min(min(red,green),blue)+
268 max(max(red,green),blue))/2.0;
273 intensity=(float) (((
float) red*red+green*green+blue*blue)/
287 intensity=0.298839*red+0.586811*green+0.114350*blue;
300 intensity=0.298839*red+0.586811*green+0.114350*blue;
314 intensity=0.212656*red+0.715158*green+0.072186*blue;
327 intensity=0.212656*red+0.715158*green+0.072186*blue;
332 intensity=(float) (sqrt((
float) red*red+green*green+blue*blue)/
345 void ConvolveOptimized(
const __global CLPixelType *input, __global CLPixelType *output,
346 const unsigned int imageWidth,
const unsigned int imageHeight,
347 __constant
float *filter,
const unsigned int filterWidth,
const unsigned int filterHeight,
348 const uint matte,
const ChannelType channel, __local CLPixelType *pixelLocalCache, __local
float* filterCache) {
351 blockID.x = get_group_id(0);
352 blockID.y = get_group_id(1);
356 imageAreaOrg.x = blockID.x * get_local_size(0);
357 imageAreaOrg.y = blockID.y * get_local_size(1);
360 midFilterDimen.x = (filterWidth-1)/2;
361 midFilterDimen.y = (filterHeight-1)/2;
363 int2 cachedAreaOrg = imageAreaOrg - midFilterDimen;
366 int2 cachedAreaDimen;
367 cachedAreaDimen.x = get_local_size(0) + filterWidth - 1;
368 cachedAreaDimen.y = get_local_size(1) + filterHeight - 1;
371 int localID = get_local_id(1)*get_local_size(0)+get_local_id(0);
372 int cachedAreaNumPixels = cachedAreaDimen.x * cachedAreaDimen.y;
373 int groupSize = get_local_size(0) * get_local_size(1);
374 for (
int i = localID; i < cachedAreaNumPixels; i+=groupSize) {
376 int2 cachedAreaIndex;
377 cachedAreaIndex.x = i % cachedAreaDimen.x;
378 cachedAreaIndex.y = i / cachedAreaDimen.x;
380 int2 imagePixelIndex;
381 imagePixelIndex = cachedAreaOrg + cachedAreaIndex;
385 imagePixelIndex.x = ClampToCanvas(imagePixelIndex.x, imageWidth);
386 imagePixelIndex.y = ClampToCanvas(imagePixelIndex.y, imageHeight);
388 pixelLocalCache[i] = input[imagePixelIndex.y * imageWidth + imagePixelIndex.x];
392 for (
int i = localID; i < filterHeight*filterWidth; i+=groupSize) {
393 filterCache[i] = filter[i];
395 barrier(CLK_LOCAL_MEM_FENCE);
399 imageIndex.x = imageAreaOrg.x + get_local_id(0);
400 imageIndex.y = imageAreaOrg.y + get_local_id(1);
403 if (imageIndex.x >= imageWidth
404 || imageIndex.y >= imageHeight) {
409 float4 sum = (float4)0.0f;
412 int cacheIndexY = get_local_id(1);
413 for (
int j = 0; j < filterHeight; j++) {
414 int cacheIndexX = get_local_id(0);
415 for (
int i = 0; i < filterWidth; i++) {
416 CLPixelType p = pixelLocalCache[cacheIndexY*cachedAreaDimen.x + cacheIndexX];
417 float f = filterCache[filterIndex];
432 int cacheIndexY = get_local_id(1);
433 for (
int j = 0; j < filterHeight; j++) {
434 int cacheIndexX = get_local_id(0);
435 for (
int i = 0; i < filterWidth; i++) {
437 CLPixelType p = pixelLocalCache[cacheIndexY*cachedAreaDimen.x + cacheIndexX];
439 float f = filterCache[filterIndex];
454 sum.xyz = gamma*sum.xyz;
456 CLPixelType outputPixel;
462 output[imageIndex.y * imageWidth + imageIndex.x] = outputPixel;
468 void Convolve(
const __global CLPixelType *input, __global CLPixelType *output,
469 const uint imageWidth,
const uint imageHeight,
470 __constant
float *filter,
const unsigned int filterWidth,
const unsigned int filterHeight,
474 imageIndex.x = get_global_id(0);
475 imageIndex.y = get_global_id(1);
481 if (imageIndex.x >= imageWidth
482 || imageIndex.y >= imageHeight)
486 midFilterDimen.x = (filterWidth-1)/2;
487 midFilterDimen.y = (filterHeight-1)/2;
490 float4 sum = (float4)0.0f;
492 if (((channel & OpacityChannel) == 0) || (matte == 0)) {
493 for (
int j = 0; j < filterHeight; j++) {
494 int2 inputPixelIndex;
495 inputPixelIndex.y = imageIndex.y - midFilterDimen.y + j;
496 inputPixelIndex.y = ClampToCanvas(inputPixelIndex.y, imageHeight);
497 for (
int i = 0; i < filterWidth; i++) {
498 inputPixelIndex.x = imageIndex.x - midFilterDimen.x + i;
499 inputPixelIndex.x = ClampToCanvas(inputPixelIndex.x, imageWidth);
501 CLPixelType p = input[inputPixelIndex.y * imageWidth + inputPixelIndex.x];
502 float f = filter[filterIndex];
517 for (
int j = 0; j < filterHeight; j++) {
518 int2 inputPixelIndex;
519 inputPixelIndex.y = imageIndex.y - midFilterDimen.y + j;
520 inputPixelIndex.y = ClampToCanvas(inputPixelIndex.y, imageHeight);
521 for (
int i = 0; i < filterWidth; i++) {
522 inputPixelIndex.x = imageIndex.x - midFilterDimen.x + i;
523 inputPixelIndex.x = ClampToCanvas(inputPixelIndex.x, imageWidth);
525 CLPixelType p = input[inputPixelIndex.y * imageWidth + inputPixelIndex.x];
527 float f = filter[filterIndex];
542 sum.xyz = gamma*sum.xyz;
545 CLPixelType outputPixel;
551 output[imageIndex.y * imageWidth + imageIndex.x] = outputPixel;
572 const unsigned int number_parameters,
573 __constant
float *parameters)
575 float4 result = (float4) 0.0f;
580 for (
unsigned int i=0; i < number_parameters; i++)
581 result = result*(float4)
QuantumScale*convert_float4(pixel) + parameters[i];
587 float freq,phase,ampl,bias;
588 freq = ( number_parameters >= 1 ) ? parameters[0] : 1.0f;
589 phase = ( number_parameters >= 2 ) ? parameters[1] : 0.0f;
590 ampl = ( number_parameters >= 3 ) ? parameters[2] : 0.5f;
591 bias = ( number_parameters >= 4 ) ? parameters[3] : 0.5f;
593 (freq*
QuantumScale*(
float)pixel.x + phase/360.0f)) + bias);
595 (freq*
QuantumScale*(
float)pixel.y + phase/360.0f)) + bias);
597 (freq*
QuantumScale*(
float)pixel.z + phase/360.0f)) + bias);
599 (freq*
QuantumScale*(
float)pixel.w + phase/360.0f)) + bias);
604 float width,range,center,bias;
605 width = ( number_parameters >= 1 ) ? parameters[0] : 1.0f;
606 center = ( number_parameters >= 2 ) ? parameters[1] : 0.5f;
607 range = ( number_parameters >= 3 ) ? parameters[2] : 1.0f;
608 bias = ( number_parameters >= 4 ) ? parameters[3] : 0.5f;
610 result.x = 2.0f/width*(
QuantumScale*(float)pixel.x - center);
611 result.x = range/
MagickPI*asin(result.x)+bias;
612 result.x = ( result.x <= -1.0f ) ? bias - range/2.0f : result.x;
613 result.x = ( result.x >= 1.0f ) ? bias + range/2.0f : result.x;
615 result.y = 2.0f/width*(
QuantumScale*(float)pixel.y - center);
616 result.y = range/
MagickPI*asin(result.y)+bias;
617 result.y = ( result.y <= -1.0f ) ? bias - range/2.0f : result.y;
618 result.y = ( result.y >= 1.0f ) ? bias + range/2.0f : result.y;
620 result.z = 2.0f/width*(
QuantumScale*(float)pixel.z - center);
621 result.z = range/
MagickPI*asin(result.z)+bias;
622 result.z = ( result.z <= -1.0f ) ? bias - range/2.0f : result.x;
623 result.z = ( result.z >= 1.0f ) ? bias + range/2.0f : result.x;
626 result.w = 2.0f/width*(
QuantumScale*(float)pixel.w - center);
627 result.w = range/
MagickPI*asin(result.w)+bias;
628 result.w = ( result.w <= -1.0f ) ? bias - range/2.0f : result.w;
629 result.w = ( result.w >= 1.0f ) ? bias + range/2.0f : result.w;
636 float slope,range,center,bias;
637 slope = ( number_parameters >= 1 ) ? parameters[0] : 1.0f;
638 center = ( number_parameters >= 2 ) ? parameters[1] : 0.5f;
639 range = ( number_parameters >= 3 ) ? parameters[2] : 1.0f;
640 bias = ( number_parameters >= 4 ) ? parameters[3] : 0.5f;
641 result = (float4)
MagickPI*(float4)slope*((float4)
QuantumScale*convert_float4(pixel)-(float4)center);
663 const unsigned int number_parameters, __constant
float *parameters)
665 const int x = get_global_id(0);
666 const int y = get_global_id(1);
667 const int columns = get_global_size(0);
668 const int c = x + y * columns;
669 im[c] =
ApplyFunction(im[c],
function, number_parameters, parameters);
676 __kernel
void Stretch(__global CLPixelType * restrict im,
678 __global CLPixelType * restrict stretch_map,
679 const float4 white,
const float4 black)
681 const int x = get_global_id(0);
682 const int y = get_global_id(1);
683 const int columns = get_global_size(0);
684 const int c = x + y * columns;
687 CLPixelType oValue, eValue;
688 CLQuantum red, green, blue, opacity;
695 if (getRedF4(white) != getRedF4(black))
697 ePos = ScaleQuantumToMap(getRed(oValue));
698 eValue = stretch_map[ePos];
699 red = getRed(eValue);
705 if (getGreenF4(white) != getGreenF4(black))
707 ePos = ScaleQuantumToMap(getGreen(oValue));
708 eValue = stretch_map[ePos];
709 green = getGreen(eValue);
715 if (getBlueF4(white) != getBlueF4(black))
717 ePos = ScaleQuantumToMap(getBlue(oValue));
718 eValue = stretch_map[ePos];
719 blue = getBlue(eValue);
723 if ((channel & OpacityChannel) != 0)
725 if (getOpacityF4(white) != getOpacityF4(black))
727 ePos = ScaleQuantumToMap(getOpacity(oValue));
728 eValue = stretch_map[ePos];
729 opacity = getOpacity(eValue);
734 im[c]=(CLPixelType)(blue, green, red, opacity);
743 __kernel
void Equalize(__global CLPixelType * restrict im,
745 __global CLPixelType * restrict equalize_map,
746 const float4 white,
const float4 black)
748 const int x = get_global_id(0);
749 const int y = get_global_id(1);
750 const int columns = get_global_size(0);
751 const int c = x + y * columns;
754 CLPixelType oValue, eValue;
755 CLQuantum red, green, blue, opacity;
762 if (getRedF4(white) != getRedF4(black))
764 ePos = ScaleQuantumToMap(getRed(oValue));
765 eValue = equalize_map[ePos];
766 red = getRed(eValue);
767 ePos = ScaleQuantumToMap(getGreen(oValue));
768 eValue = equalize_map[ePos];
769 green = getRed(eValue);
770 ePos = ScaleQuantumToMap(getBlue(oValue));
771 eValue = equalize_map[ePos];
772 blue = getRed(eValue);
773 ePos = ScaleQuantumToMap(getOpacity(oValue));
774 eValue = equalize_map[ePos];
775 opacity = getRed(eValue);
778 im[c]=(CLPixelType)(blue, green, red, opacity);
792 __kernel
void Histogram(__global CLPixelType * restrict im,
795 const int colorspace,
796 __global uint4 * restrict histogram)
798 const int x = get_global_id(0);
799 const int y = get_global_id(1);
800 const int columns = get_global_size(0);
801 const int c = x + y * columns;
802 if ((channel & SyncChannels) != 0)
806 atomic_inc((__global uint *)(&(histogram[pos]))+2);
824 __kernel
void BlurRow(__global CLPixelType *im, __global float4 *filtered_im,
825 const ChannelType channel, __constant
float *filter,
826 const unsigned int width,
827 const unsigned int imageColumns,
const unsigned int imageRows,
828 __local CLPixelType *temp)
830 const int x = get_global_id(0);
831 const int y = get_global_id(1);
833 const int columns = imageColumns;
835 const unsigned int radius = (width-1)/2;
836 const int wsize = get_local_size(0);
837 const unsigned int loadSize = wsize+width;
865 const int groupX=get_local_size(0)*get_group_id(0);
866 const int groupY=get_local_size(1)*get_group_id(1);
869 for (
int i=get_local_id(0); i < loadSize; i=i+get_local_size(0))
872 temp[i] = im[y * columns + ClampToCanvas(i+groupX-radius, columns)];
881 barrier(CLK_LOCAL_MEM_FENCE);
884 if (get_global_id(0) < columns)
887 float4 result = (float4) 0;
891 \n #ifndef UFACTOR \n
892 \n #define UFACTOR 8 \n
895 for ( ; i+UFACTOR < width; )
897 \n #pragma unroll UFACTOR\n
898 for (
int j=0; j < UFACTOR; j++, i++)
900 result+=filter[i]*convert_float4(temp[i+get_local_id(0)]);
904 for ( ; i < width; i++)
906 result+=filter[i]*convert_float4(temp[i+get_local_id(0)]);
915 filtered_im[y*columns+x] = result;
928 __kernel
void BlurRowSection(__global CLPixelType *im, __global float4 *filtered_im,
929 const ChannelType channel, __constant
float *filter,
930 const unsigned int width,
931 const unsigned int imageColumns,
const unsigned int imageRows,
932 __local CLPixelType *temp,
933 const unsigned int offsetRows,
const unsigned int section)
935 const int x = get_global_id(0);
936 const int y = get_global_id(1);
938 const int columns = imageColumns;
940 const unsigned int radius = (width-1)/2;
941 const int wsize = get_local_size(0);
942 const unsigned int loadSize = wsize+width;
945 const int groupX=get_local_size(0)*get_group_id(0);
946 const int groupY=get_local_size(1)*get_group_id(1);
949 im += imageColumns * (offsetRows - radius * section);
952 for (
int i=get_local_id(0); i < loadSize; i=i+get_local_size(0))
955 temp[i] = im[y * columns + ClampToCanvas(i+groupX-radius, columns)];
964 barrier(CLK_LOCAL_MEM_FENCE);
967 if (get_global_id(0) < columns)
970 float4 result = (float4) 0;
974 \n #ifndef UFACTOR \n
975 \n #define UFACTOR 8 \n
978 for ( ; i+UFACTOR < width; )
980 \n #pragma unroll UFACTOR\n
981 for (
int j=0; j < UFACTOR; j++, i++)
983 result+=filter[i]*convert_float4(temp[i+get_local_id(0)]);
987 for ( ; i < width; i++)
989 result+=filter[i]*convert_float4(temp[i+get_local_id(0)]);
998 filtered_im[y*columns+x] = result;
1012 __kernel
void BlurColumn(
const __global float4 *blurRowData, __global CLPixelType *filtered_im,
1013 const ChannelType channel, __constant
float *filter,
1014 const unsigned int width,
1015 const unsigned int imageColumns,
const unsigned int imageRows,
1016 __local float4 *temp)
1018 const int x = get_global_id(0);
1019 const int y = get_global_id(1);
1023 const int columns = imageColumns;
1024 const int rows = imageRows;
1026 unsigned int radius = (width-1)/2;
1027 const int wsize = get_local_size(1);
1028 const unsigned int loadSize = wsize+width;
1031 const int groupX=get_local_size(0)*get_group_id(0);
1032 const int groupY=get_local_size(1)*get_group_id(1);
1037 for (
int i = get_local_id(1); i < loadSize; i=i+get_local_size(1))
1039 temp[i] = blurRowData[ClampToCanvas(i+groupY-radius, rows) * columns + groupX];
1043 barrier(CLK_LOCAL_MEM_FENCE);
1046 if (get_global_id(1) < rows)
1049 float4 result = (float4) 0;
1053 \n #ifndef UFACTOR \n
1054 \n #define UFACTOR 8 \n
1057 for ( ; i+UFACTOR < width; )
1059 \n #pragma unroll UFACTOR \n
1060 for (
int j=0; j < UFACTOR; j++, i++)
1062 result+=filter[i]*temp[i+get_local_id(1)];
1066 for ( ; i < width; i++)
1068 result+=filter[i]*temp[i+get_local_id(1)];
1077 filtered_im[y*columns+x] = (CLPixelType) (result.x,result.y,result.z,result.w);
1092 __kernel
void BlurColumnSection(
const __global float4 *blurRowData, __global CLPixelType *filtered_im,
1093 const ChannelType channel, __constant
float *filter,
1094 const unsigned int width,
1095 const unsigned int imageColumns,
const unsigned int imageRows,
1096 __local float4 *temp,
1097 const unsigned int offsetRows,
const unsigned int section)
1099 const int x = get_global_id(0);
1100 const int y = get_global_id(1);
1104 const int columns = imageColumns;
1105 const int rows = imageRows;
1107 unsigned int radius = (width-1)/2;
1108 const int wsize = get_local_size(1);
1109 const unsigned int loadSize = wsize+width;
1112 const int groupX=get_local_size(0)*get_group_id(0);
1113 const int groupY=get_local_size(1)*get_group_id(1);
1118 blurRowData += imageColumns * radius * section;
1121 for (
int i = get_local_id(1); i < loadSize; i=i+get_local_size(1))
1123 int pos = ClampToCanvasWithHalo(i+groupY-radius, rows, radius, section) * columns + groupX;
1124 temp[i] = *(blurRowData+pos);
1128 barrier(CLK_LOCAL_MEM_FENCE);
1131 if (get_global_id(1) < rows)
1134 float4 result = (float4) 0;
1138 \n #ifndef UFACTOR \n
1139 \n #define UFACTOR 8 \n
1142 for ( ; i+UFACTOR < width; )
1144 \n #pragma unroll UFACTOR \n
1145 for (
int j=0; j < UFACTOR; j++, i++)
1147 result+=filter[i]*temp[i+get_local_id(1)];
1150 for ( ; i < width; i++)
1152 result+=filter[i]*temp[i+get_local_id(1)];
1161 filtered_im += imageColumns * offsetRows;
1164 filtered_im[y*columns+x] = (CLPixelType) (result.x,result.y,result.z,result.w);
1172 __kernel
void UnsharpMaskBlurColumn(
const __global CLPixelType* inputImage,
1173 const __global float4 *blurRowData, __global CLPixelType *filtered_im,
1174 const unsigned int imageColumns,
const unsigned int imageRows,
1175 __local float4* cachedData, __local
float* cachedFilter,
1176 const ChannelType channel,
const __global
float *filter,
const unsigned int width,
1177 const float gain,
const float threshold)
1179 const unsigned int radius = (width-1)/2;
1182 const int groupX = get_group_id(0);
1183 const int groupStartY = get_group_id(1)*get_local_size(1) - radius;
1184 const int groupStopY = (get_group_id(1)+1)*get_local_size(1) + radius;
1186 if (groupStartY >= 0
1187 && groupStopY < imageRows) {
1188 event_t e = async_work_group_strided_copy(cachedData
1189 ,blurRowData+groupStartY*imageColumns+groupX
1190 ,groupStopY-groupStartY,imageColumns,0);
1191 wait_group_events(1,&e);
1194 for (
int i = get_local_id(1); i < (groupStopY - groupStartY); i+=get_local_size(1)) {
1195 cachedData[i] = blurRowData[ClampToCanvas(groupStartY+i,imageRows)*imageColumns+ groupX];
1197 barrier(CLK_LOCAL_MEM_FENCE);
1200 event_t e = async_work_group_copy(cachedFilter,filter,width,0);
1201 wait_group_events(1,&e);
1205 const int cy = get_global_id(1);
1207 if (cy < imageRows) {
1208 float4 blurredPixel = (float4) 0.0f;
1212 \n #ifndef UFACTOR \n
1213 \n #define UFACTOR 8 \n
1216 for ( ; i+UFACTOR < width; )
1218 \n #pragma unroll UFACTOR \n
1219 for (
int j=0; j < UFACTOR; j++, i++)
1221 blurredPixel+=cachedFilter[i]*cachedData[i+get_local_id(1)];
1225 for ( ; i < width; i++)
1227 blurredPixel+=cachedFilter[i]*cachedData[i+get_local_id(1)];
1233 float4 inputImagePixel = convert_float4(inputImage[cy*imageColumns+groupX]);
1234 float4 outputPixel = inputImagePixel - blurredPixel;
1238 int4 mask = isless(fabs(2.0f*outputPixel), (float4)quantumThreshold);
1239 outputPixel = select(inputImagePixel + outputPixel * gain, inputImagePixel, mask);
1248 __kernel
void UnsharpMaskBlurColumnSection(
const __global CLPixelType* inputImage,
1249 const __global float4 *blurRowData, __global CLPixelType *filtered_im,
1250 const unsigned int imageColumns,
const unsigned int imageRows,
1251 __local float4* cachedData, __local
float* cachedFilter,
1252 const ChannelType channel,
const __global
float *filter,
const unsigned int width,
1253 const float gain,
const float threshold,
1254 const unsigned int offsetRows,
const unsigned int section)
1256 const unsigned int radius = (width-1)/2;
1259 const int groupX = get_group_id(0);
1260 const int groupStartY = get_group_id(1)*get_local_size(1) - radius;
1261 const int groupStopY = (get_group_id(1)+1)*get_local_size(1) + radius;
1264 blurRowData += imageColumns * radius * section;
1266 if (groupStartY >= 0
1267 && groupStopY < imageRows) {
1268 event_t e = async_work_group_strided_copy(cachedData
1269 ,blurRowData+groupStartY*imageColumns+groupX
1270 ,groupStopY-groupStartY,imageColumns,0);
1271 wait_group_events(1,&e);
1274 for (
int i = get_local_id(1); i < (groupStopY - groupStartY); i+=get_local_size(1)) {
1275 int pos = ClampToCanvasWithHalo(groupStartY+i,imageRows, radius, section)*imageColumns+ groupX;
1276 cachedData[i] = *(blurRowData + pos);
1278 barrier(CLK_LOCAL_MEM_FENCE);
1281 event_t e = async_work_group_copy(cachedFilter,filter,width,0);
1282 wait_group_events(1,&e);
1286 const int cy = get_global_id(1);
1288 if (cy < imageRows) {
1289 float4 blurredPixel = (float4) 0.0f;
1293 \n #ifndef UFACTOR \n
1294 \n #define UFACTOR 8 \n
1297 for ( ; i+UFACTOR < width; )
1299 \n #pragma unroll UFACTOR \n
1300 for (
int j=0; j < UFACTOR; j++, i++)
1302 blurredPixel+=cachedFilter[i]*cachedData[i+get_local_id(1)];
1306 for ( ; i < width; i++)
1308 blurredPixel+=cachedFilter[i]*cachedData[i+get_local_id(1)];
1315 inputImage += imageColumns * offsetRows;
1316 filtered_im += imageColumns * offsetRows;
1318 float4 inputImagePixel = convert_float4(inputImage[cy*imageColumns+groupX]);
1319 float4 outputPixel = inputImagePixel - blurredPixel;
1323 int4 mask = isless(fabs(2.0f*outputPixel), (float4)quantumThreshold);
1324 outputPixel = select(inputImagePixel + outputPixel * gain, inputImagePixel, mask);
1339 __kernel
void HullPass1(
const __global CLPixelType *inputImage, __global CLPixelType *outputImage
1340 ,
const unsigned int imageWidth,
const unsigned int imageHeight
1341 ,
const int2 offset,
const int polarity,
const int matte) {
1343 int x = get_global_id(0);
1344 int y = get_global_id(1);
1346 CLPixelType v = inputImage[y*imageWidth+x];
1349 neighbor.y = y + offset.y;
1350 neighbor.x = x + offset.x;
1352 int2 clampedNeighbor;
1353 clampedNeighbor.x = ClampToCanvas(neighbor.x, imageWidth);
1354 clampedNeighbor.y = ClampToCanvas(neighbor.y, imageHeight);
1356 CLPixelType r = (clampedNeighbor.x == neighbor.x
1357 && clampedNeighbor.y == neighbor.y)?inputImage[clampedNeighbor.y*imageWidth+clampedNeighbor.x]
1373 \n #pragma unroll 4\n
1374 for (
unsigned int i = 0; i < 4; i++) {
1375 sv[i] = (sr[i] >= (sv[i]+ScaleCharToQuantum(2)))?(sv[i]+ScaleCharToQuantum(1)):sv[i];
1379 \n #pragma unroll 4\n
1380 for (
unsigned int i = 0; i < 4; i++) {
1381 sv[i] = (sr[i] <= (sv[i]-ScaleCharToQuantum(2)))?(sv[i]-ScaleCharToQuantum(1)):sv[i];
1386 v.x = (CLQuantum)sv[0];
1387 v.y = (CLQuantum)sv[1];
1388 v.z = (CLQuantum)sv[2];
1391 v.w = (CLQuantum)sv[3];
1393 outputImage[y*imageWidth+x] = v;
1404 __kernel
void HullPass2(
const __global CLPixelType *inputImage, __global CLPixelType *outputImage
1405 ,
const unsigned int imageWidth,
const unsigned int imageHeight
1406 ,
const int2 offset,
const int polarity,
const int matte) {
1408 int x = get_global_id(0);
1409 int y = get_global_id(1);
1411 CLPixelType v = inputImage[y*imageWidth+x];
1413 int2 neighbor, clampedNeighbor;
1415 neighbor.y = y + offset.y;
1416 neighbor.x = x + offset.x;
1417 clampedNeighbor.x = ClampToCanvas(neighbor.x, imageWidth);
1418 clampedNeighbor.y = ClampToCanvas(neighbor.y, imageHeight);
1420 CLPixelType r = (clampedNeighbor.x == neighbor.x
1421 && clampedNeighbor.y == neighbor.y)?inputImage[clampedNeighbor.y*imageWidth+clampedNeighbor.x]
1425 neighbor.y = y - offset.y;
1426 neighbor.x = x - offset.x;
1427 clampedNeighbor.x = ClampToCanvas(neighbor.x, imageWidth);
1428 clampedNeighbor.y = ClampToCanvas(neighbor.y, imageHeight);
1430 CLPixelType s = (clampedNeighbor.x == neighbor.x
1431 && clampedNeighbor.y == neighbor.y)?inputImage[clampedNeighbor.y*imageWidth+clampedNeighbor.x]
1454 \n #pragma unroll 4\n
1455 for (
unsigned int i = 0; i < 4; i++) {
1460 sv[i] =(( (int)( ss[i] < (sv[i]+ScaleCharToQuantum(2))) + (int) ( sr[i] <= sv[i] ) ) !=0) ? sv[i]:(sv[i]+ScaleCharToQuantum(1));
1464 \n #pragma unroll 4\n
1465 for (
unsigned int i = 0; i < 4; i++) {
1469 sv[i] = (( (int)(ss[i] > (sv[i]-ScaleCharToQuantum(2))) + (int)( sr[i] >= sv[i] )) !=0) ? sv[i]:(sv[i]-ScaleCharToQuantum(1));
1473 v.x = (CLQuantum)sv[0];
1474 v.y = (CLQuantum)sv[1];
1475 v.z = (CLQuantum)sv[2];
1478 v.w = (CLQuantum)sv[3];
1480 outputImage[y*imageWidth+x] = v;
1489 __kernel
void RadialBlur(
const __global CLPixelType *im, __global CLPixelType *filtered_im,
1491 const unsigned int channel,
const unsigned int matte,
1492 const float2 blurCenter,
1493 __constant
float *cos_theta, __constant
float *sin_theta,
1494 const unsigned int cossin_theta_size)
1496 const int x = get_global_id(0);
1497 const int y = get_global_id(1);
1498 const int columns = get_global_size(0);
1499 const int rows = get_global_size(1);
1500 unsigned int step = 1;
1501 float center_x = (float) x - blurCenter.x;
1502 float center_y = (
float) y - blurCenter.y;
1503 float radius = hypot(center_x, center_y);
1506 float blur_radius = hypot(blurCenter.x, blurCenter.y);
1510 step = (
unsigned int) (blur_radius / radius);
1513 if (step >= cossin_theta_size)
1514 step = cossin_theta_size-1;
1518 result.x = (float)bias.x;
1519 result.y = (
float)bias.y;
1520 result.z = (float)bias.z;
1521 result.w = (
float)bias.w;
1522 float normalize = 0.0f;
1524 if (((channel & OpacityChannel) == 0) || (matte == 0)) {
1525 for (
unsigned int i=0; i<cossin_theta_size; i+=step)
1527 result += convert_float4(im[
1528 ClampToCanvas(blurCenter.x+center_x*cos_theta[i]-center_y*sin_theta[i]+0.5f,columns)+
1529 ClampToCanvas(blurCenter.y+center_x*sin_theta[i]+center_y*cos_theta[i]+0.5f, rows)*columns]);
1533 result = result * normalize;
1537 for (
unsigned int i=0; i<cossin_theta_size; i+=step)
1539 float4 p = convert_float4(im[
1540 ClampToCanvas(blurCenter.x+center_x*cos_theta[i]-center_y*sin_theta[i]+0.5f,columns)+
1541 ClampToCanvas(blurCenter.y+center_x*sin_theta[i]+center_y*cos_theta[i]+0.5f, rows)*columns]);
1544 result.x += alpha * p.x;
1545 result.y += alpha * p.y;
1546 result.z += alpha * p.z;
1553 result.x = gamma*result.x;
1554 result.y = gamma*result.y;
1555 result.z = gamma*result.z;
1556 result.w = normalize*result.w;
1566 float3 HueSaturationBrightness;
1567 HueSaturationBrightness.x = 0.0f;
1568 HueSaturationBrightness.y = 0.0f;
1569 HueSaturationBrightness.z = 0.0f;
1571 float r=(float) getRed(pixel);
1572 float g=(float) getGreen(pixel);
1573 float b=(float) getBlue(pixel);
1575 float tmin=min(min(r,g),b);
1576 float tmax=max(max(r,g),b);
1579 float delta=tmax-tmin;
1580 HueSaturationBrightness.y=delta/tmax;
1583 if (delta != 0.0f) {
1584 HueSaturationBrightness.x = ((r == tmax)?0.0f:((g == tmax)?2.0f:4.0f));
1585 HueSaturationBrightness.x += ((r == tmax)?(g-b):((g == tmax)?(b-r):(r-g)))/delta;
1586 HueSaturationBrightness.x/=6.0f;
1587 HueSaturationBrightness.x += (HueSaturationBrightness.x < 0.0f)?0.0f:1.0f;
1590 return HueSaturationBrightness;
1595 float hue = HueSaturationBrightness.x;
1596 float brightness = HueSaturationBrightness.z;
1597 float saturation = HueSaturationBrightness.y;
1601 if (saturation == 0.0f) {
1603 setGreen(&rgb,getRed(rgb));
1604 setBlue(&rgb,getRed(rgb));
1608 float h=6.0f*(hue-floor(hue));
1610 float p=brightness*(1.0f-saturation);
1611 float q=brightness*(1.0f-saturation*f);
1612 float t=brightness*(1.0f-(saturation*(1.0f-f)));
1619 setRed(&rgb, (ih == 1)?clamped_q:
1620 (ih == 2 || ih == 3)?clamped_p:
1621 (ih == 4)?clamped_t:
1624 setGreen(&rgb, (ih == 1 || ih == 2)?clampedBrightness:
1625 (ih == 3)?clamped_q:
1626 (ih == 4 || ih == 5)?clamped_p:
1629 setBlue(&rgb, (ih == 2)?clamped_t:
1630 (ih == 3 || ih == 4)?clampedBrightness:
1631 (ih == 5)?clamped_q:
1637 __kernel
void Contrast(__global CLPixelType *im,
const unsigned int sharpen)
1640 const int sign = sharpen!=0?1:-1;
1641 const int x = get_global_id(0);
1642 const int y = get_global_id(1);
1643 const int columns = get_global_size(0);
1644 const int c = x + y * columns;
1646 CLPixelType pixel = im[c];
1648 float brightness = HueSaturationBrightness.z;
1649 brightness+=0.5f*sign*(0.5f*(sinpi(brightness-0.5f)+1.0f)-brightness);
1650 brightness = clamp(brightness,0.0f,1.0f);
1651 HueSaturationBrightness.z = brightness;
1654 filteredPixel.w = pixel.w;
1655 im[c] = filteredPixel;
1663 inline void ConvertRGBToHSL(
const CLQuantum red,
const CLQuantum green,
const CLQuantum blue,
1664 float *hue,
float *saturation,
float *lightness)
1679 *lightness=(tmax+tmin)/2.0;
1700 if (*lightness <= 0.5)
1701 *saturation=c/(2.0*(*lightness));
1703 *saturation=c/(2.0-2.0*(*lightness));
1706 inline void ConvertHSLToRGB(
const float hue,
const float saturation,
const float lightness,
1707 CLQuantum *red,CLQuantum *green,CLQuantum *blue)
1722 if (lightness <= 0.5)
1723 c=2.0*lightness*saturation;
1725 c=(2.0-2.0*lightness)*saturation;
1726 tmin=lightness-0.5*c;
1727 h-=360.0*floor(h/360.0);
1729 x=c*(1.0-fabs(h-2.0*floor(h/2.0)-1.0));
1730 switch ((
int) floor(h))
1786 inline void ModulateHSL(
const float percent_hue,
const float percent_saturation,
const float percent_lightness,
1787 CLQuantum *red,CLQuantum *green,CLQuantum *blue)
1798 hue+=0.5*(0.01*percent_hue-1.0);
1803 saturation*=0.01*percent_saturation;
1804 lightness*=0.01*percent_lightness;
1808 __kernel
void Modulate(__global CLPixelType *im,
1809 const float percent_brightness,
1810 const float percent_hue,
1811 const float percent_saturation,
1812 const int colorspace)
1815 const int x = get_global_id(0);
1816 const int y = get_global_id(1);
1817 const int columns = get_global_size(0);
1818 const int c = x + y * columns;
1820 CLPixelType pixel = im[c];
1828 green=getGreen(pixel);
1829 blue=getBlue(pixel);
1836 ModulateHSL(percent_hue, percent_saturation, percent_brightness,
1837 &red, &green, &blue);
1842 CLPixelType filteredPixel;
1844 setRed(&filteredPixel, red);
1845 setGreen(&filteredPixel, green);
1846 setBlue(&filteredPixel, blue);
1847 filteredPixel.w = pixel.w;
1849 im[c] = filteredPixel;
1854 __kernel
void Negate(__global CLPixelType *im,
1858 const int x = get_global_id(0);
1859 const int y = get_global_id(1);
1860 const int columns = get_global_size(0);
1861 const int c = x + y * columns;
1863 CLPixelType pixel = im[c];
1871 green=getGreen(pixel);
1872 blue=getBlue(pixel);
1874 CLPixelType filteredPixel;
1876 if ((channel & RedChannel) !=0)
1878 if ((channel & GreenChannel) !=0)
1880 if ((channel & BlueChannel) !=0)
1883 filteredPixel.w = pixel.w;
1885 im[c] = filteredPixel;
1890 __kernel
void Grayscale(__global CLPixelType *im,
1891 const int method,
const int colorspace)
1894 const int x = get_global_id(0);
1895 const int y = get_global_id(1);
1896 const int columns = get_global_size(0);
1897 const int c = x + y * columns;
1899 CLPixelType pixel = im[c];
1907 red=(float)getRed(pixel);
1908 green=(float)getGreen(pixel);
1909 blue=(float)getBlue(pixel);
1913 CLPixelType filteredPixel;
1919 intensity=(red+green+blue)/3.0;
1924 intensity=max(max(red,green),blue);
1929 intensity=(min(min(red,green),blue)+
1930 max(max(red,green),blue))/2.0;
1935 intensity=(float) (((
float) red*red+green*green+
1949 intensity=0.298839*red+0.586811*green+0.114350*blue;
1962 intensity=0.298839*red+0.586811*green+0.114350*blue;
1976 intensity=0.212656*red+0.715158*green+0.072186*blue;
1989 intensity=0.212656*red+0.715158*green+0.072186*blue;
1994 intensity=(float) (sqrt((
float) red*red+green*green+
1995 blue*blue)/sqrt(3.0));
2003 filteredPixel.w = pixel.w;
2005 im[c] = filteredPixel;
2011 float BoxResizeFilter(
const float x)
2019 float CubicBC(
const float x,
const __global
float* resizeFilterCoefficients)
2051 return(resizeFilterCoefficients[0]+x*(x*
2052 (resizeFilterCoefficients[1]+x*resizeFilterCoefficients[2])));
2054 return(resizeFilterCoefficients[3]+x*(resizeFilterCoefficients[4]+x*
2055 (resizeFilterCoefficients[5]+x*resizeFilterCoefficients[6])));
2061 float Sinc(
const float x)
2065 const float alpha=(float) (
MagickPI*x);
2066 return sinpi(x)/alpha;
2080 return ((x<1.0f)?(1.0f-x):0.0f);
2092 const float cosine=cos((
MagickPI*x));
2093 return(0.5f+0.5f*cosine);
2104 const float cosine=cos((
MagickPI*x));
2105 return(0.54f+0.46f*cosine);
2119 const float cosine=cos((
MagickPI*x));
2120 return(0.34f+cosine*(0.5f+cosine*0.16f));
2147 inline float applyResizeFilter(
const float x,
const ResizeWeightingFunctionType filterType,
const __global
float* filterCoefficients)
2157 return CubicBC(x,filterCoefficients);
2159 return BoxResizeFilter(x);
2177 inline float getResizeFilterWeight(
const __global
float* resizeFilterCubicCoefficients,
const ResizeWeightingFunctionType resizeFilterType
2179 ,
const float resizeFilterScale,
const float resizeWindowSupport,
const float resizeFilterBlur,
const float x)
2182 float xBlur = fabs(x/resizeFilterBlur);
2190 scale = resizeFilterScale;
2191 scale = applyResizeFilter(xBlur*scale, resizeWindowType, resizeFilterCubicCoefficients);
2193 float weight = scale * applyResizeFilter(xBlur, resizeFilterType, resizeFilterCubicCoefficients);
2200 const char* accelerateKernels2 =
2204 inline unsigned int getNumWorkItemsPerPixel(
const unsigned int pixelPerWorkgroup,
const unsigned int numWorkItems) {
2205 return (numWorkItems/pixelPerWorkgroup);
2210 inline int pixelToCompute(
const unsigned itemID,
const unsigned int pixelPerWorkgroup,
const unsigned int numWorkItems) {
2211 const unsigned int numWorkItemsPerPixel = getNumWorkItemsPerPixel(pixelPerWorkgroup, numWorkItems);
2212 int pixelIndex = itemID/numWorkItemsPerPixel;
2213 pixelIndex = (pixelIndex<pixelPerWorkgroup)?pixelIndex:-1;
2220 __kernel __attribute__((reqd_work_group_size(256, 1, 1)))
2221 void ResizeHorizontalFilter(
const __global CLPixelType* inputImage,
const unsigned int inputColumns,
const unsigned int inputRows,
const unsigned int matte
2222 ,
const float xFactor, __global CLPixelType* filteredImage,
const unsigned int filteredColumns,
const unsigned int filteredRows
2223 ,
const int resizeFilterType,
const int resizeWindowType
2224 ,
const __global
float* resizeFilterCubicCoefficients
2225 ,
const float resizeFilterScale,
const float resizeFilterSupport,
const float resizeFilterWindowSupport,
const float resizeFilterBlur
2226 , __local CLPixelType* inputImageCache,
const int numCachedPixels,
const unsigned int pixelPerWorkgroup,
const unsigned int pixelChunkSize
2227 , __local float4* outputPixelCache, __local
float* densityCache, __local
float* gammaCache) {
2231 const unsigned int startX = get_group_id(0)*pixelPerWorkgroup;
2232 const unsigned int stopX = min(startX + pixelPerWorkgroup,filteredColumns);
2233 const unsigned int actualNumPixelToCompute = stopX - startX;
2237 const float support = max(scale*resizeFilterSupport,0.5f);
2240 const int cacheRangeStartX = max((
int)((startX+0.5f)/xFactor+
MagickEpsilon-support+0.5f),(
int)(0));
2241 const int cacheRangeEndX = min((
int)(cacheRangeStartX + numCachedPixels), (
int)inputColumns);
2244 const unsigned int y = get_global_id(1);
2245 event_t e = async_work_group_copy(inputImageCache,inputImage+y*inputColumns+cacheRangeStartX,cacheRangeEndX-cacheRangeStartX,0);
2246 wait_group_events(1,&e);
2248 unsigned int totalNumChunks = (actualNumPixelToCompute+pixelChunkSize-1)/pixelChunkSize;
2249 for (
unsigned int chunk = 0; chunk < totalNumChunks; chunk++)
2252 const unsigned int chunkStartX = startX + chunk*pixelChunkSize;
2253 const unsigned int chunkStopX = min(chunkStartX + pixelChunkSize, stopX);
2254 const unsigned int actualNumPixelInThisChunk = chunkStopX - chunkStartX;
2257 const unsigned int itemID = get_local_id(0);
2258 const unsigned int numItems = getNumWorkItemsPerPixel(actualNumPixelInThisChunk, get_local_size(0));
2260 const int pixelIndex = pixelToCompute(itemID, actualNumPixelInThisChunk, get_local_size(0));
2262 float4 filteredPixel = (float4)0.0f;
2263 float density = 0.0f;
2266 if (pixelIndex != -1) {
2269 const int x = chunkStartX + pixelIndex;
2273 const unsigned int start = (
unsigned int)max(bisect-support+0.5f,0.0f);
2274 const unsigned int stop = (
unsigned int)min(bisect+support+0.5f,(
float)inputColumns);
2275 const unsigned int n = stop - start;
2278 unsigned int numStepsPerWorkItem = n / numItems;
2279 numStepsPerWorkItem += ((numItems*numStepsPerWorkItem)==n?0:1);
2281 const unsigned int startStep = (itemID%numItems)*numStepsPerWorkItem;
2282 if (startStep < n) {
2283 const unsigned int stopStep = min(startStep+numStepsPerWorkItem, n);
2285 unsigned int cacheIndex = start+startStep-cacheRangeStartX;
2288 for (
unsigned int i = startStep; i < stopStep; i++,cacheIndex++) {
2289 float4 cp = convert_float4(inputImageCache[cacheIndex]);
2293 , resizeFilterScale, resizeFilterWindowSupport, resizeFilterBlur,scale*(start+i-bisect+0.5));
2295 filteredPixel += ((float4)weight)*cp;
2302 for (
unsigned int i = startStep; i < stopStep; i++,cacheIndex++) {
2303 CLPixelType p = inputImageCache[cacheIndex];
2307 , resizeFilterScale, resizeFilterWindowSupport, resizeFilterBlur,scale*(start+i-bisect+0.5));
2310 float4 cp = convert_float4(p);
2312 filteredPixel.x += alpha * cp.x;
2313 filteredPixel.y += alpha * cp.y;
2314 filteredPixel.z += alpha * cp.z;
2315 filteredPixel.w += weight * cp.w;
2325 if (itemID < actualNumPixelInThisChunk) {
2326 outputPixelCache[itemID] = (float4)0.0f;
2327 densityCache[itemID] = 0.0f;
2329 gammaCache[itemID] = 0.0f;
2331 barrier(CLK_LOCAL_MEM_FENCE);
2334 for (
unsigned int i = 0; i < numItems; i++) {
2335 if (pixelIndex != -1) {
2336 if (itemID%numItems == i) {
2337 outputPixelCache[pixelIndex]+=filteredPixel;
2338 densityCache[pixelIndex]+=density;
2340 gammaCache[pixelIndex]+=gamma;
2344 barrier(CLK_LOCAL_MEM_FENCE);
2347 if (itemID < actualNumPixelInThisChunk) {
2349 float density = densityCache[itemID];
2350 float4 filteredPixel = outputPixelCache[itemID];
2351 if (density!= 0.0f && density != 1.0)
2354 filteredPixel *= (float4)density;
2356 filteredImage[y*filteredColumns+chunkStartX+itemID] = (CLPixelType) (
ClampToQuantum(filteredPixel.x)
2362 float density = densityCache[itemID];
2363 float gamma = gammaCache[itemID];
2364 float4 filteredPixel = outputPixelCache[itemID];
2366 if (density!= 0.0f && density != 1.0) {
2368 filteredPixel *= (float4)density;
2379 filteredImage[y*filteredColumns+chunkStartX+itemID] = fp;
2391 __kernel __attribute__((reqd_work_group_size(256, 1, 1)))
2392 void ResizeHorizontalFilterSinc(
const __global CLPixelType* inputImage,
const unsigned int inputColumns,
const unsigned int inputRows,
const unsigned int matte
2393 ,
const float xFactor, __global CLPixelType* filteredImage,
const unsigned int filteredColumns,
const unsigned int filteredRows
2394 ,
const int resizeFilterType,
const int resizeWindowType
2395 ,
const __global
float* resizeFilterCubicCoefficients
2396 ,
const float resizeFilterScale,
const float resizeFilterSupport,
const float resizeFilterWindowSupport,
const float resizeFilterBlur
2397 , __local CLPixelType* inputImageCache,
const int numCachedPixels,
const unsigned int pixelPerWorkgroup,
const unsigned int pixelChunkSize
2398 , __local float4* outputPixelCache, __local
float* densityCache, __local
float* gammaCache) {
2400 ResizeHorizontalFilter(inputImage,inputColumns,inputRows,matte
2401 ,xFactor, filteredImage, filteredColumns, filteredRows
2403 ,resizeFilterCubicCoefficients
2404 ,resizeFilterScale, resizeFilterSupport, resizeFilterWindowSupport, resizeFilterBlur
2405 ,inputImageCache, numCachedPixels, pixelPerWorkgroup, pixelChunkSize
2406 ,outputPixelCache, densityCache, gammaCache);
2413 __kernel __attribute__((reqd_work_group_size(1, 256, 1)))
2414 void ResizeVerticalFilter(const __global CLPixelType* inputImage, const
unsigned int inputColumns, const
unsigned int inputRows, const
unsigned int matte
2415 , const
float yFactor, __global CLPixelType* filteredImage, const
unsigned int filteredColumns, const
unsigned int filteredRows
2416 , const
int resizeFilterType, const
int resizeWindowType
2417 , const __global
float* resizeFilterCubicCoefficients
2418 , const
float resizeFilterScale, const
float resizeFilterSupport, const
float resizeFilterWindowSupport, const
float resizeFilterBlur
2419 , __local CLPixelType* inputImageCache, const
int numCachedPixels, const
unsigned int pixelPerWorkgroup, const
unsigned int pixelChunkSize
2420 , __local float4* outputPixelCache, __local
float* densityCache, __local
float* gammaCache) {
2424 const unsigned int startY = get_group_id(1)*pixelPerWorkgroup;
2425 const unsigned int stopY = min(startY + pixelPerWorkgroup,filteredRows);
2426 const unsigned int actualNumPixelToCompute = stopY - startY;
2429 float scale = max(1.0f/yFactor+MagickEpsilon ,1.0f);
2430 const float support = max(scale*resizeFilterSupport,0.5f);
2433 const int cacheRangeStartY = max((
int)((startY+0.5f)/yFactor+MagickEpsilon-support+0.5f),(
int)(0));
2434 const int cacheRangeEndY = min((
int)(cacheRangeStartY + numCachedPixels), (
int)inputRows);
2437 const unsigned int x = get_global_id(0);
2438 event_t e = async_work_group_strided_copy(inputImageCache, inputImage+cacheRangeStartY*inputColumns+x, cacheRangeEndY-cacheRangeStartY, inputColumns, 0);
2439 wait_group_events(1,&e);
2441 unsigned int totalNumChunks = (actualNumPixelToCompute+pixelChunkSize-1)/pixelChunkSize;
2442 for (
unsigned int chunk = 0; chunk < totalNumChunks; chunk++)
2445 const unsigned int chunkStartY = startY + chunk*pixelChunkSize;
2446 const unsigned int chunkStopY = min(chunkStartY + pixelChunkSize, stopY);
2447 const unsigned int actualNumPixelInThisChunk = chunkStopY - chunkStartY;
2450 const unsigned int itemID = get_local_id(1);
2451 const unsigned int numItems = getNumWorkItemsPerPixel(actualNumPixelInThisChunk, get_local_size(1));
2453 const int pixelIndex = pixelToCompute(itemID, actualNumPixelInThisChunk, get_local_size(1));
2455 float4 filteredPixel = (float4)0.0f;
2456 float density = 0.0f;
2459 if (pixelIndex != -1) {
2462 const int y = chunkStartY + pixelIndex;
2466 const unsigned int start = (
unsigned int)max(bisect-support+0.5f,0.0f);
2467 const unsigned int stop = (
unsigned int)min(bisect+support+0.5f,(
float)inputRows);
2468 const unsigned int n = stop - start;
2471 unsigned int numStepsPerWorkItem = n / numItems;
2472 numStepsPerWorkItem += ((numItems*numStepsPerWorkItem)==n?0:1);
2474 const unsigned int startStep = (itemID%numItems)*numStepsPerWorkItem;
2475 if (startStep < n) {
2476 const unsigned int stopStep = min(startStep+numStepsPerWorkItem, n);
2478 unsigned int cacheIndex = start+startStep-cacheRangeStartY;
2481 for (
unsigned int i = startStep; i < stopStep; i++,cacheIndex++) {
2482 float4 cp = convert_float4(inputImageCache[cacheIndex]);
2486 , resizeFilterScale, resizeFilterWindowSupport, resizeFilterBlur,scale*(start+i-bisect+0.5));
2488 filteredPixel += ((float4)weight)*cp;
2495 for (
unsigned int i = startStep; i < stopStep; i++,cacheIndex++) {
2496 CLPixelType p = inputImageCache[cacheIndex];
2500 , resizeFilterScale, resizeFilterWindowSupport, resizeFilterBlur,scale*(start+i-bisect+0.5));
2503 float4 cp = convert_float4(p);
2505 filteredPixel.x += alpha * cp.x;
2506 filteredPixel.y += alpha * cp.y;
2507 filteredPixel.z += alpha * cp.z;
2508 filteredPixel.w += weight * cp.w;
2518 if (itemID < actualNumPixelInThisChunk) {
2519 outputPixelCache[itemID] = (float4)0.0f;
2520 densityCache[itemID] = 0.0f;
2522 gammaCache[itemID] = 0.0f;
2524 barrier(CLK_LOCAL_MEM_FENCE);
2527 for (
unsigned int i = 0; i < numItems; i++) {
2528 if (pixelIndex != -1) {
2529 if (itemID%numItems == i) {
2530 outputPixelCache[pixelIndex]+=filteredPixel;
2531 densityCache[pixelIndex]+=density;
2533 gammaCache[pixelIndex]+=gamma;
2537 barrier(CLK_LOCAL_MEM_FENCE);
2540 if (itemID < actualNumPixelInThisChunk) {
2542 float density = densityCache[itemID];
2543 float4 filteredPixel = outputPixelCache[itemID];
2544 if (density!= 0.0f && density != 1.0)
2547 filteredPixel *= (float4)density;
2549 filteredImage[(chunkStartY+itemID)*filteredColumns+x] = (CLPixelType) (
ClampToQuantum(filteredPixel.x)
2555 float density = densityCache[itemID];
2556 float gamma = gammaCache[itemID];
2557 float4 filteredPixel = outputPixelCache[itemID];
2559 if (density!= 0.0f && density != 1.0) {
2561 filteredPixel *= (float4)density;
2572 filteredImage[(chunkStartY+itemID)*filteredColumns+x] = fp;
2584 __kernel __attribute__((reqd_work_group_size(1, 256, 1)))
2585 void ResizeVerticalFilterSinc(const __global CLPixelType* inputImage, const
unsigned int inputColumns, const
unsigned int inputRows, const
unsigned int matte
2586 , const
float yFactor, __global CLPixelType* filteredImage, const
unsigned int filteredColumns, const
unsigned int filteredRows
2587 , const
int resizeFilterType, const
int resizeWindowType
2588 , const __global
float* resizeFilterCubicCoefficients
2589 , const
float resizeFilterScale, const
float resizeFilterSupport, const
float resizeFilterWindowSupport, const
float resizeFilterBlur
2590 , __local CLPixelType* inputImageCache, const
int numCachedPixels, const
unsigned int pixelPerWorkgroup, const
unsigned int pixelChunkSize
2591 , __local float4* outputPixelCache, __local
float* densityCache, __local
float* gammaCache) {
2592 ResizeVerticalFilter(inputImage,inputColumns,inputRows,matte
2593 ,yFactor,filteredImage,filteredColumns,filteredRows
2595 ,resizeFilterCubicCoefficients
2596 ,resizeFilterScale,resizeFilterSupport,resizeFilterWindowSupport,resizeFilterBlur
2597 ,inputImageCache,numCachedPixels,pixelPerWorkgroup,pixelChunkSize
2598 ,outputPixelCache,densityCache,gammaCache);
2607 unsigned int alpha = (
unsigned int) (s.y ^ (s.y << 11));
2611 s.x = (s.x ^ (s.x >> 19)) ^ (alpha ^ (alpha >> 8));
2612 }
while (s.x == ~0UL);
2614 return (normalizeRand*s.x);
2617 __kernel
void randomNumberGeneratorKernel(__global uint* seeds,
const float normalizeRand
2618 , __global
float* randomNumbers,
const uint init
2619 ,
const uint numRandomNumbers) {
2621 unsigned int id = get_global_id(0);
2622 unsigned int seed[4];
2625 seed[0] = seeds[
id*4];
2626 seed[1] = 0x50a7f451;
2627 seed[2] = 0x5365417e;
2628 seed[3] = 0xc3a4171a;
2631 seed[0] = seeds[
id*4];
2632 seed[1] = seeds[
id*4+1];
2633 seed[2] = seeds[
id*4+2];
2634 seed[3] = seeds[
id*4+3];
2637 unsigned int numRandomNumbersPerItem = (numRandomNumbers+get_global_size(0)-1)/get_global_size(0);
2638 for (
unsigned int i = 0; i < numRandomNumbersPerItem; i++) {
2641 unsigned int alpha=(
unsigned int) (seed[1] ^ (seed[1] << 11));
2645 seed[0]=(seed[0] ^ (seed[0] >> 19)) ^ (alpha ^ (alpha >> 8));
2646 }
while (seed[0] == ~0UL);
2647 unsigned int pos = (get_group_id(0)*get_local_size(0)*numRandomNumbersPerItem)
2648 + get_local_size(0) * i + get_local_id(0);
2650 if (pos >= numRandomNumbers)
2652 randomNumbers[pos] = normalizeRand*seed[0];
2656 seeds[
id*4] = seed[0];
2657 seeds[
id*4+1] = seed[1];
2658 seeds[
id*4+2] = seed[2];
2659 seeds[
id*4+3] = seed[3];
2680 const global
float* rns;
2684 float ReadPseudoRandomValue(RandomNumbers* r) {
2710 alpha=ReadPseudoRandomValue(r);
2711 switch(noise_type) {
2726 beta=ReadPseudoRandomValue(r);
2727 gamma=sqrt(-2.0f*log(alpha));
2728 sigma=gamma*cospi((2.0f*beta));
2729 tau=gamma*sinpi((2.0f*beta));
2730 noise=(float)(pixel+sqrt((
float) pixel)*
SigmaGaussian*sigma+
2751 if (alpha <= MagickEpsilon)
2759 if (beta <= (0.5f*MagickEpsilon))
2768 if (alpha > MagickEpsilon)
2769 sigma=sqrt(-2.0f*log(alpha));
2770 beta=ReadPseudoRandomValue(r);
2772 cospi((
float) (2.0f*beta))/2.0f);
2781 for (i=0; alpha > poisson; i++)
2783 beta=ReadPseudoRandomValue(r);
2800 void AddNoiseImage(
const __global CLPixelType* inputImage, __global CLPixelType* filteredImage
2801 ,
const unsigned int inputColumns,
const unsigned int inputRows
2803 ,
const NoiseType noise_type,
const float attenuate
2804 ,
const __global
float* randomNumbers,
const unsigned int numRandomNumbersPerPixel
2805 ,
const unsigned int rowOffset) {
2807 unsigned int x = get_global_id(0);
2808 unsigned int y = get_global_id(1) + rowOffset;
2810 r.rns = randomNumbers + (get_global_id(1) * inputColumns + get_global_id(0))*numRandomNumbersPerPixel;
2812 CLPixelType p = inputImage[y*inputColumns+x];
2813 CLPixelType q = filteredImage[y*inputColumns+x];
2815 if ((channel&RedChannel)!=0) {
2819 if ((channel&GreenChannel)!=0) {
2823 if ((channel&BlueChannel)!=0) {
2827 if ((channel & OpacityChannel) != 0) {
2831 filteredImage[y*inputColumns+x] = q;
2838 void RandomImage(__global CLPixelType* inputImage,
2839 const uint imageColumns,
const uint imageRows,
2840 __global uint* seeds,
2841 const float randNormNumerator,
2842 const uint randNormDenominator) {
2844 unsigned int numGenerators = get_global_size(0);
2845 unsigned numRandPixelsPerWorkItem = ((imageColumns*imageRows) + (numGenerators-1))
2849 s.x = seeds[get_global_id(0)*4];
2850 s.y = seeds[get_global_id(0)*4+1];
2851 s.z = seeds[get_global_id(0)*4+2];
2852 s.w = seeds[get_global_id(0)*4+3];
2854 unsigned int offset = get_group_id(0) * get_local_size(0) * numRandPixelsPerWorkItem;
2855 for (
unsigned int n = 0; n < numRandPixelsPerWorkItem; n++)
2857 int i = offset + n*get_local_size(0) + get_local_id(0);
2858 if (i >= imageColumns*imageRows)
2873 seeds[get_global_id(0)*4] = s.x;
2874 seeds[get_global_id(0)*4+1] = s.y;
2875 seeds[get_global_id(0)*4+2] = s.z;
2876 seeds[get_global_id(0)*4+3] = s.w;
2882 void MotionBlur(
const __global CLPixelType *input, __global CLPixelType *output,
2883 const unsigned int imageWidth,
const unsigned int imageHeight,
2884 const __global
float *filter,
const unsigned int width,
const __global int2* offset,
2886 const ChannelType channel,
const unsigned int matte) {
2889 currentPixel.x = get_global_id(0);
2890 currentPixel.y = get_global_id(1);
2892 if (currentPixel.x >= imageWidth
2893 || currentPixel.y >= imageHeight)
2897 pixel.x = (float)bias.x;
2898 pixel.y = (
float)bias.y;
2899 pixel.z = (float)bias.z;
2900 pixel.w = (
float)bias.w;
2902 if (((channel & OpacityChannel) == 0) || (matte == 0)) {
2904 for (
int i = 0; i < width; i++) {
2907 int2 samplePixel = currentPixel + offset[i];
2908 samplePixel.x = ClampToCanvas(samplePixel.x, imageWidth);
2909 samplePixel.y = ClampToCanvas(samplePixel.y, imageHeight);
2910 CLPixelType samplePixelValue = input[ samplePixel.y * imageWidth + samplePixel.x];
2912 pixel.x += (filter[i] * (float)samplePixelValue.x);
2913 pixel.y += (filter[i] * (float)samplePixelValue.y);
2914 pixel.z += (filter[i] * (float)samplePixelValue.z);
2915 pixel.w += (filter[i] * (float)samplePixelValue.w);
2918 CLPixelType outputPixel;
2923 output[currentPixel.y * imageWidth + currentPixel.x] = outputPixel;
2928 for (
int i = 0; i < width; i++) {
2931 int2 samplePixel = currentPixel + offset[i];
2932 samplePixel.x = ClampToCanvas(samplePixel.x, imageWidth);
2933 samplePixel.y = ClampToCanvas(samplePixel.y, imageHeight);
2935 CLPixelType samplePixelValue = input[ samplePixel.y * imageWidth + samplePixel.x];
2938 float k = filter[i];
2939 pixel.x = pixel.x + k * alpha * samplePixelValue.x;
2940 pixel.y = pixel.y + k * alpha * samplePixelValue.y;
2941 pixel.z = pixel.z + k * alpha * samplePixelValue.z;
2943 pixel.w += k * alpha * samplePixelValue.w;
2948 pixel.xyz = gamma*pixel.xyz;
2950 CLPixelType outputPixel;
2955 output[currentPixel.y * imageWidth + currentPixel.x] = outputPixel;
3040 const float Sa,
const float Dca,
const float Da)
3045 if ((Sca*Da+Dca*Sa) >= Sa*Da)
3046 return(Sa*Da+Sca*(1.0-Da)+Dca*(1.0-Sa));
3047 return(Dca*Sa*Sa/(Sa-Sca)+Sca*(1.0-Da)+Dca*(1.0-Sa));
3081 const float4 *q,float4 *composite) {
3092 gamma=
QuantumRange/(fabs(gamma) < MagickEpsilon ? MagickEpsilon : gamma);
3094 getRedF4(*q)*Da,Da));
3096 getGreenF4(*q)*Da,Da));
3098 getBlueF4(*q)*Da,Da));
3104 const float alpha,
const float4 *q,
3105 const float beta,float4 *composite)
3119 setOpacityF4(composite,(
float)
QuantumRange*(1.0-gamma));
3121 setRedF4(composite,gamma*(Sa*getRedF4(*p)+Da*getRedF4(*q)));
3122 setGreenF4(composite,gamma*(Sa*getGreenF4(*p)+Da*getGreenF4(*q)));
3123 setBlueF4(composite,gamma*(Sa*getBlueF4(*p)+Da*getBlueF4(*q)));
3129 const float alpha,
const float4 *q,
3130 const float beta,float4 *composite)
3140 void Composite(__global CLPixelType *image,
3141 const unsigned int imageWidth,
3142 const unsigned int imageHeight,
3143 const __global CLPixelType *compositeImage,
3144 const unsigned int compositeWidth,
3145 const unsigned int compositeHeight,
3146 const unsigned int compose,
3148 const unsigned int matte,
3149 const float destination_dissolve,
3150 const float source_dissolve) {
3153 index.x = get_global_id(0);
3154 index.y = get_global_id(1);
3157 if (index.x >= imageWidth
3158 || index.y >= imageHeight) {
3161 const CLPixelType inputPixel = image[index.y*imageWidth+index.x];
3163 setRedF4(&destination,getRed(inputPixel));
3164 setGreenF4(&destination,getGreen(inputPixel));
3165 setBlueF4(&destination,getBlue(inputPixel));
3168 const CLPixelType compositePixel
3169 = compositeImage[index.y*imageWidth+index.x];
3171 setRedF4(&source,getRed(compositePixel));
3172 setGreenF4(&source,getGreen(compositePixel));
3173 setBlueF4(&source,getBlue(compositePixel));
3176 setOpacityF4(&destination,getOpacity(inputPixel));
3177 setOpacityF4(&source,getOpacity(compositePixel));
3180 setOpacityF4(&destination,0.0f);
3181 setOpacityF4(&source,0.0f);
3184 float4 composite=destination;
3193 destination_dissolve,&composite);
3200 CLPixelType outputPixel;
3204 setOpacity(&outputPixel,
ClampToQuantum(getOpacityF4(composite)));
3205 image[index.y*imageWidth+index.x] = outputPixel;
3211 #endif // MAGICKCORE_OPENCL_SUPPORT
3213 #if defined(__cplusplus) || defined(c_plusplus)
3217 #endif // _MAGICKCORE_ACCELERATE_PRIVATE_H
Definition: composite.h:91
Definition: composite.h:94
Definition: composite.h:65
Definition: colorspace.h:44
Definition: resize-private.h:31
Definition: colorspace.h:36
Definition: resize-private.h:37
Definition: statistic.h:110
Definition: resize-private.h:33
Definition: magick-type.h:198
Definition: composite.h:75
Definition: colorspace.h:40
static void MagickPixelCompositeBlend(const MagickPixelPacket *p, const MagickRealType alpha, const MagickPixelPacket *q, const MagickRealType beta, MagickPixelPacket *composite)
Definition: composite-private.h:137
Definition: composite.h:31
Definition: composite.h:93
MagickExport MagickBooleanType FunctionImage(Image *image, const MagickFunction function, const size_t number_parameters, const double *parameters, ExceptionInfo *exception)
Definition: statistic.c:997
Definition: colorspace.h:45
Definition: colorspace.h:33
Definition: composite.h:80
Definition: composite.h:33
Definition: resize-private.h:40
Definition: composite.h:90
Definition: resize-private.h:29
static MagickRealType ColorDodge(const MagickRealType Sca, const MagickRealType Sa, const MagickRealType Dca, const MagickRealType Da)
Definition: composite.c:306
PixelIntensityMethod
Definition: pixel.h:67
Definition: magick-type.h:187
Definition: composite.h:95
Definition: colorspace.h:59
Definition: magick-type.h:193
Definition: composite.h:59
Definition: composite.h:89
Definition: magick-type.h:182
Definition: composite.h:27
Definition: colorspace.h:41
Definition: colorspace.h:37
static MagickRealType RoundToUnity(const MagickRealType value)
Definition: composite-private.h:33
Definition: composite.h:35
Definition: composite.h:87
#define MagickPI
Definition: image-private.h:26
Definition: colorspace.h:58
Definition: colorspace.h:50
static MagickRealType Hanning(const MagickRealType x, const ResizeFilter *magick_unused(resize_filter))
Definition: resize.c:287
Definition: colorspace.h:47
float MagickRealType
Definition: magick-type.h:76
Definition: statistic.h:109
Definition: colorspace.h:31
#define MAGICKCORE_QUANTUM_DEPTH
Definition: magick-type.h:28
Definition: composite.h:53
Definition: colorspace.h:35
Definition: resize-private.h:38
#define MagickEpsilon
Definition: magick-type.h:139
MagickExport void ConvertRGBToHSL(const Quantum red, const Quantum green, const Quantum blue, double *hue, double *saturation, double *lightness)
Definition: gem.c:1142
Definition: magick-type.h:188
Definition: colorspace.h:48
Definition: statistic.h:111
Definition: magick-type.h:200
NoiseType
Definition: fx.h:27
Definition: colorspace.h:52
Definition: composite.h:47
static MagickRealType Hamming(const MagickRealType x, const ResizeFilter *magick_unused(resize_filter))
Definition: resize.c:301
Definition: resize-private.h:41
Definition: composite.h:73
Definition: composite.h:29
Definition: composite.h:72
Definition: composite.h:42
Definition: colorspace.h:43
Definition: composite.h:97
static void ModulateHSL(const double percent_hue, const double percent_saturation, const double percent_lightness, Quantum *red, Quantum *green, Quantum *blue)
Definition: enhance.c:3568
Definition: colorspace.h:34
Definition: colorspace.h:57
Definition: resize-private.h:30
Definition: composite.h:54
#define GetPixelAlpha(pixel)
Definition: pixel-accessor.h:36
Definition: composite.h:38
Definition: composite.h:68
Definition: composite.h:96
Definition: magick-type.h:184
Definition: composite.h:71
Definition: resize-private.h:32
Definition: composite.h:55
Definition: composite.h:56
Definition: composite.h:69
static Quantum ApplyFunction(Quantum pixel, const MagickFunction function, const size_t number_parameters, const double *parameters, ExceptionInfo *exception)
Definition: statistic.c:915
Definition: colorspace.h:38
Definition: composite.h:86
Definition: resize-private.h:36
Definition: colorspace.h:30
#define SigmaMultiplicativeGaussian
Definition: composite.h:49
Definition: composite.h:44
MagickExport void ConvertRGBToHSB(const Quantum red, const Quantum green, const Quantum blue, double *hue, double *saturation, double *brightness)
Definition: gem.c:1009
Definition: magick-type.h:186
static void Contrast(const int sign, Quantum *red, Quantum *green, Quantum *blue)
Definition: enhance.c:913
Definition: magick-type.h:201
Definition: composite.h:46
Definition: statistic.h:107
Definition: composite.h:28
Definition: magick-type.h:181
Definition: magick-type.h:190
Definition: colorspace.h:54
Definition: magick-type.h:189
Definition: resize-private.h:39
Definition: composite.h:78
Definition: resize-private.h:34
#define QuantumScale
Definition: magick-type.h:142
Definition: colorspace.h:55
MagickExport double GetPseudoRandomValue(RandomInfo *random_info)
Definition: random.c:612
Definition: composite.h:62
MagickExport MagickRealType GetPixelIntensity(const Image *image, const PixelPacket *restrict pixel)
Definition: pixel.c:2106
Definition: colorspace.h:39
#define MaxMap
Definition: magick-type.h:70
Definition: magick-type.h:197
Definition: composite.h:98
Definition: composite.h:39
static void CompositeColorDodge(const MagickPixelPacket *p, const MagickPixelPacket *q, MagickPixelPacket *composite)
Definition: composite.c:343
MagickExport void ConvertHSBToRGB(const double hue, const double saturation, const double brightness, Quantum *red, Quantum *green, Quantum *blue)
Definition: gem.c:284
Definition: composite.h:45
ChannelType
Definition: magick-type.h:177
Definition: composite.h:70
Definition: colorspace.h:46
Definition: resize-private.h:28
Definition: composite.h:81
Definition: composite.h:41
Definition: composite.h:52
Definition: colorspace.h:49
MagickExport void ConvertHSLToRGB(const double hue, const double saturation, const double lightness, Quantum *red, Quantum *green, Quantum *blue)
Definition: gem.c:460
Definition: composite.h:77
static Quantum ClampToQuantum(const MagickRealType value)
Definition: quantum.h:87
Definition: colorspace.h:53
Definition: composite.h:61
Definition: magick-type.h:183
static void MagickPixelCompositePlus(const MagickPixelPacket *p, const MagickRealType alpha, const MagickPixelPacket *q, const MagickRealType beta, MagickPixelPacket *composite)
Definition: composite-private.h:108
Definition: composite.h:76
Definition: magick-type.h:179
Definition: colorspace.h:28
Definition: resize-private.h:42
Definition: composite.h:50
Definition: composite.h:36
Definition: composite.h:43
Definition: composite.h:37
static MagickRealType Sinc(const MagickRealType, const ResizeFilter *)
Definition: composite.h:60
Definition: statistic.h:108
ResizeWeightingFunctionType
Definition: resize-private.h:25
MagickExport Image * AddNoiseImage(const Image *image, const NoiseType noise_type, ExceptionInfo *exception)
Definition: fx.c:262
static MagickRealType Blackman(const MagickRealType x, const ResizeFilter *magick_unused(resize_filter))
Definition: resize.c:148
Definition: colorspace.h:56
ColorspaceType
Definition: colorspace.h:25
Definition: composite.h:32
Definition: colorspace.h:29
Definition: composite.h:88
Definition: colorspace.h:42
MagickExport double GenerateDifferentialNoise(RandomInfo *random_info, const Quantum pixel, const NoiseType noise_type, const MagickRealType attenuate)
Definition: gem.c:1502
Definition: composite.h:48
Definition: composite.h:64
Definition: magick-type.h:185
Definition: colorspace.h:51
CompositeOperator
Definition: composite.h:25
Definition: composite.h:79
Definition: magick-type.h:192
Definition: colorspace.h:32
Definition: composite.h:66
Definition: composite.h:30
Definition: colorspace.h:60
Definition: magick-type.h:180
Definition: composite.h:63
Definition: composite.h:58
Definition: composite.h:92
Definition: magick-type.h:199
Definition: composite.h:34
static double PerceptibleReciprocal(const double x)
Definition: pixel-private.h:78
static MagickRealType CubicBC(const MagickRealType x, const ResizeFilter *resize_filter)
Definition: resize.c:210
Definition: resize-private.h:27
Definition: composite.h:74
Definition: colorspace.h:27
MagickFunction
Definition: statistic.h:105
Definition: composite.h:40
Definition: composite.h:67
Definition: resize-private.h:35
#define QuantumRange
Definition: magick-type.h:94
static MagickRealType Triangle(const MagickRealType x, const ResizeFilter *magick_unused(resize_filter))
Definition: resize.c:514
Definition: composite.h:51
Definition: magick-type.h:191
Definition: composite.h:57