Changeset 8813
- Timestamp:
- 08/02/12 09:23:28 (10 months ago)
- Location:
- ImageMagick/trunk/MagickCore
- Files:
-
- 3 edited
-
morphology.c (modified) (4 diffs)
-
morphology.h (modified) (1 diff)
-
option.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ImageMagick/trunk/MagickCore/morphology.c
r8252 r8813 114 114 #define Minimize(assign,value) assign=MagickMin(assign,value) 115 115 #define Maximize(assign,value) assign=MagickMax(assign,value) 116 117 /* Integer Factorial Function - for a Binomial kernel */ 118 #if 1 119 static inline size_t fact(size_t n) 120 { 121 size_t l,f; 122 for(f=1, l=2; l <= n; f=f*l, l++); 123 return(f); 124 } 125 #elif 1 /* glibc floating point alternatives */ 126 #define fact(n) ((size_t)tgamma((double)n+1)) 127 #else 128 #define fact(n) ((size_t)lgamma((double)n+1)) 129 #endif 130 116 131 117 132 /* Currently these are only internal to this module */ … … 634 649 % radius of the kernel. 635 650 % 651 % Binomial:[{radius}] 652 % Generate a discrete kernel using a 2 dimentional Pascel's Triangle 653 % of values. 654 % 636 655 % # Still to be implemented... 637 656 % # … … 996 1015 case BlurKernel: 997 1016 case CometKernel: 1017 case BinomialKernel: 998 1018 case DiamondKernel: 999 1019 case SquareKernel: … … 1288 1308 ScaleKernelInfo(kernel, 1.0, NormalizeValue); /* Normalize */ 1289 1309 RotateKernelInfo(kernel, args->xi); /* Rotate by angle */ 1310 break; 1311 } 1312 case BinomialKernel: 1313 { 1314 size_t 1315 order_f; 1316 1317 if (args->rho < 1.0) 1318 kernel->width = kernel->height = 3; /* default radius = 1 */ 1319 else 1320 kernel->width = kernel->height = ((size_t)args->rho)*2+1; 1321 kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2; 1322 1323 order_f = fact(kernel->width-1); 1324 1325 kernel->values=(double *) AcquireAlignedMemory(kernel->width, 1326 kernel->height*sizeof(*kernel->values)); 1327 if (kernel->values == (double *) NULL) 1328 return(DestroyKernelInfo(kernel)); 1329 1330 /* set all kernel values within diamond area to scale given */ 1331 for ( i=0, v=0; v < (ssize_t)kernel->height; v++) 1332 { size_t 1333 alpha = order_f / ( fact(v) * fact(kernel->height-v-1) ); 1334 for ( u=0; u < (ssize_t)kernel->width; u++, i++) 1335 kernel->positive_range += kernel->values[i] = (double) 1336 (alpha * order_f / ( fact(u) * fact(kernel->height-u-1) )); 1337 } 1338 kernel->minimum = 1.0; 1339 kernel->maximum = kernel->values[kernel->x+kernel->y*kernel->width]; 1340 kernel->negative_range = 0.0; 1290 1341 break; 1291 1342 } -
ImageMagick/trunk/MagickCore/morphology.h
r7570 r8813 34 34 BlurKernel, 35 35 CometKernel, 36 BinomialKernel, 36 37 LaplacianKernel, /* Convolution Kernels, by Name */ 37 38 SobelKernel, -
ImageMagick/trunk/MagickCore/option.c
r8775 r8813 1118 1118 { "Blur", BlurKernel, UndefinedOptionFlag, MagickFalse }, 1119 1119 { "Comet", CometKernel, UndefinedOptionFlag, MagickFalse }, 1120 { "Binomial", BinomialKernel, UndefinedOptionFlag, MagickFalse }, 1120 1121 { "Laplacian", LaplacianKernel, UndefinedOptionFlag, MagickFalse }, 1121 1122 { "Sobel", SobelKernel, UndefinedOptionFlag, MagickFalse }, … … 1710 1711 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1711 1712 % 1712 % CloneImageOptions() clones one or more image options.1713 % CloneImageOptions() clones all global image options, to another image_info 1713 1714 % 1714 1715 % The format of the CloneImageOptions method is: … … 1719 1720 % A description of each parameter follows: 1720 1721 % 1721 % o image_info: the image info .1722 % 1723 % o clone_info: the clone image info.1722 % o image_info: the image info to recieve the cloned options. 1723 % 1724 % o clone_info: the source image info for options to clone. 1724 1725 % 1725 1726 */ … … 1752 1753 % 1753 1754 % DefineImageOption() associates an assignment string of the form 1754 % "key=value" with an image option. It is equivelent to SetImageOption(). 1755 % "key=value" with a global image option. It is equivelent to 1756 % SetImageOption(). 1755 1757 % 1756 1758 % The format of the DefineImageOption method is: … … 1800 1802 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1801 1803 % 1802 % DeleteImageOption() deletes an key from the image map.1804 % DeleteImageOption() deletes an key from the global image options. 1803 1805 % 1804 1806 % Returns MagickTrue is the option is found and deleted from the Options. … … 1840 1842 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1841 1843 % 1842 % DestroyImageOptions() releases memory associated with image option values. 1844 % DestroyImageOptions() destroys all global options and associated memory 1845 % attached to the given image_info image list. 1843 1846 % 1844 1847 % The format of the DestroyDefines method is: … … 1873 1876 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1874 1877 % 1875 % GetImageOption() gets a value associated with an image option. 1878 % GetImageOption() gets a value associated with the global image options. 1879 % 1880 % The returned string is a constant string in the tree and should NOT be 1881 % freed by the caller. 1876 1882 % 1877 1883 % The format of the GetImageOption method is: … … 2152 2158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2153 2159 % 2154 % GetNextImageOption() gets the next imageoption value.2160 % GetNextImageOption() gets the next global option value. 2155 2161 % 2156 2162 % The format of the GetNextImageOption method is: … … 2596 2602 % RemoveImageOption() removes an option from the image and returns its value. 2597 2603 % 2604 % In this case the ConstantString() value returned should be freed by the 2605 % caller when finished. 2606 % 2598 2607 % The format of the RemoveImageOption method is: 2599 2608 % … … 2636 2645 % 2637 2646 % ResetImageOptions() resets the image_info option. That is, it deletes 2638 % all options associated with the image_info structure.2647 % all global options associated with the image_info structure. 2639 2648 % 2640 2649 % The format of the ResetImageOptions method is: … … 2740 2749 RelinquishMagickMemory,RelinquishMagickMemory); 2741 2750 2742 /* Delete Option if NULL */2751 /* Delete Option if NULL -- empty string values are valid! */ 2743 2752 if (value == (const char *) NULL) 2744 2753 return(DeleteImageOption(image_info,option));
Note: See TracChangeset
for help on using the changeset viewer.
