/* Currently these are only internal to this module */
static void
CalcKernelMetaData(KernelInfo *),
- ExpandKernelInfo(KernelInfo *, const double),
+ ExpandMirrorKernelInfo(KernelInfo *),
+ ExpandRotateKernelInfo(KernelInfo *, const double),
RotateKernelInfo(KernelInfo *, double);
\f
%
% Input kernel defintion strings can consist of any of three types.
%
-% "name:args"
+% "name:args[[@><]"
% Select from one of the built in kernels, using the name and
% geometry arguments supplied. See AcquireKernelBuiltIn()
%
-% "WxH[+X+Y][^@]:num, num, num ..."
+% "WxH[+X+Y][@><]:num, num, num ..."
% a kernel of size W by H, with W*H floating point numbers following.
% the 'center' can be optionally be defined at +X+Y (such that +0+0
% is top left corner). If not defined the pixel in the center, for
% odd sizes, or to the immediate top or left of center for even sizes
% is automatically selected.
%
-% If a '^' is included the kernel expanded with 90-degree rotations,
-% While a '@' will allow you to expand a 3x3 kernel using 45-degree
-% circular rotates.
-%
% "num, num, num, num, ..."
% list of floating point numbers defining an 'old style' odd sized
% square kernel. At least 9 values should be provided for a 3x3
% Any extra ';' characters, at start, end or between kernel defintions are
% simply ignored.
%
+% The special flags will expand a single kernel, into a list of rotated
+% kernels. A '@' flag will expand a 3x3 kernel into a list of 45-degree
+% cyclic rotations, while a '>' will generate a list of 90-degree rotations.
+% The '<' also exands using 90-degree rotates, but giving a 180-degree
+% reflected kernel before the +/- 90-degree rotations, which can be important
+% for Thinning operations.
+%
% Note that 'name' kernels will start with an alphabetic character while the
% new kernel specification has a ':' character in its specification string.
% If neither is the case, it is assumed an old style of a simple list of
return(DestroyKernelInfo(kernel));
if ( (flags & AreaValue) != 0 ) /* '@' symbol in kernel size */
- ExpandKernelInfo(kernel, 45.0);
- else if ( (flags & MinimumValue) != 0 ) /* '^' symbol in kernel size */
- ExpandKernelInfo(kernel, 90.0);
+ ExpandRotateKernelInfo(kernel, 45.0); /* cyclic rotate 3x3 kernels */
+ else if ( (flags & GreaterValue) != 0 ) /* '>' symbol in kernel args */
+ ExpandRotateKernelInfo(kernel, 90.0); /* 90 degree rotate of kernel */
+ else if ( (flags & LessValue) != 0 ) /* '<' symbol in kernel args */
+ ExpandMirrorKernelInfo(kernel); /* 90 degree mirror rotate */
return(kernel);
}
args.xi = 1.0;
break;
case ChebyshevKernel:
- case ManhattenKernel:
+ case ManhattanKernel:
case EuclideanKernel:
if ( (flags & HeightValue) == 0 ) /* no distance scale */
args.sigma = 100.0; /* default distance scaling */
/* global expand to rotated kernel list - only for single kernels */
if ( kernel->next == (KernelInfo *) NULL ) {
if ( (flags & AreaValue) != 0 ) /* '@' symbol in kernel args */
- ExpandKernelInfo(kernel, 45.0);
- else if ( (flags & MinimumValue) != 0 ) /* '^' symbol in kernel args */
- ExpandKernelInfo(kernel, 90.0);
+ ExpandRotateKernelInfo(kernel, 45.0);
+ else if ( (flags & GreaterValue) != 0 ) /* '>' symbol in kernel args */
+ ExpandRotateKernelInfo(kernel, 90.0);
+ else if ( (flags & LessValue) != 0 ) /* '<' symbol in kernel args */
+ ExpandMirrorKernelInfo(kernel);
}
return(kernel);
/* Error handling -- this is not proper error handling! */
if ( new_kernel == (KernelInfo *) NULL ) {
- fprintf(stderr, "Failed to parse kernel number #%lu\n", kernel_number);
+ fprintf(stderr, "Failed to parse kernel number #%.20g\n",(double)
+ kernel_number);
if ( kernel != (KernelInfo *) NULL )
kernel=DestroyKernelInfo(kernel);
return((KernelInfo *) NULL);
% radius will be determined so as to produce the best minimal error
% result, which is usally much larger than is normally needed.
%
-% DOG:{radius},{sigma1},{sigma2}
+% LoG:{radius},{sigma}
+% "Laplacian of a Gaussian" or "Mexician Hat" Kernel.
+% The supposed ideal edge detection, zero-summing kernel.
+%
+% An alturnative to this kernel is to use a "DoG" with a sigma ratio of
+% approx 1.6 (according to wikipedia).
+%
+% DoG:{radius},{sigma1},{sigma2}
% "Difference of Gaussians" Kernel.
% As "Gaussian" but with a gaussian produced by 'sigma2' subtracted
% from the gaussian produced by 'sigma1'. Typically sigma2 > sigma1.
% The result is a zero-summing kernel.
%
-% LOG:{radius},{sigma}
-% "Laplacian of a Gaussian" or "Mexician Hat" Kernel.
-% The supposed ideal edge detection, zero-summing kernel.
-%
-% An alturnative to this kernel is to use a "DOG" with a sigma ratio of
-% approx 1.6, which can also be applied as a 2 pass "DOB" (see below).
-%
% Blur:{radius},{sigma}[,{angle}]
% Generates a 1 dimensional or linear gaussian blur, at the angle given
% (current restricted to orthogonal angles). If a 'radius' is given the
% same sigma value, However it is much faster to apply. This is how the
% "-blur" operator actually works.
%
-% DOB:{radius},{sigma1},{sigma2}[,{angle}]
-% "Difference of Blurs" Kernel.
-% As "Blur" but with the 1D gaussian produced by 'sigma2' subtracted
-% from thethe 1D gaussian produced by 'sigma1'.
-% The result is a zero-summing kernel.
-%
-% This can be used to generate a faster "DOG" convolution, in the same
-% way "Blur" can.
-%
% Comet:{width},{sigma},{angle}
% Blur in one direction only, much like how a bright object leaves
% a comet like trail. The Kernel is actually half a gaussian curve,
% Type 3 : 3x3 with center:4 edge:-2 corner:1
% Type 5 : 5x5 laplacian
% Type 7 : 7x7 laplacian
-% Type 15 : 5x5 LOG (sigma approx 1.4)
-% Type 19 : 9x9 LOG (sigma approx 1.4)
+% Type 15 : 5x5 LoG (sigma approx 1.4)
+% Type 19 : 9x9 LoG (sigma approx 1.4)
%
% Sobel:{angle}
% Sobel 'Edge' convolution kernel (3x3)
-% -1, 0, 1
-% -2, 0,-2
-% -1, 0, 1
+% | -1, 0, 1 |
+% | -2, 0,-2 |
+% | -1, 0, 1 |
+%
+% Sobel:{type},{angle}
+% Type 0: default un-nomalized version shown above.
+%
+% Type 1: As default but pre-normalized
+% | 1, 0, -1 |
+% | 2, 0, -2 | / 4
+% | 1, 0, -1 |
+%
+% Type 2: Diagonal version with same normalization as 1
+% | 1, 0, -1 |
+% | 2, 0, -2 | / 4
+% | 1, 0, -1 |
%
% Roberts:{angle}
% Roberts convolution kernel (3x3)
-% 0, 0, 0
-% -1, 1, 0
-% 0, 0, 0
+% | 0, 0, 0 |
+% | -1, 1, 0 |
+% | 0, 0, 0 |
+%
% Prewitt:{angle}
% Prewitt Edge convolution kernel (3x3)
-% -1, 0, 1
-% -1, 0, 1
-% -1, 0, 1
+% | -1, 0, 1 |
+% | -1, 0, 1 |
+% | -1, 0, 1 |
+%
% Compass:{angle}
% Prewitt's "Compass" convolution kernel (3x3)
-% -1, 1, 1
-% -1,-2, 1
-% -1, 1, 1
+% | -1, 1, 1 |
+% | -1,-2, 1 |
+% | -1, 1, 1 |
+%
% Kirsch:{angle}
% Kirsch's "Compass" convolution kernel (3x3)
-% -3,-3, 5
-% -3, 0, 5
-% -3,-3, 5
+% | -3,-3, 5 |
+% | -3, 0, 5 |
+% | -3,-3, 5 |
+%
+% FreiChen:{angle}
+% Frei-Chen Edge Detector is based on a kernel that is similar to
+% the Sobel Kernel, but is designed to be isotropic. That is it takes
+% into account the distance of the diagonal in the kernel.
+%
+% | 1, 0, -1 |
+% | sqrt(2), 0, -sqrt(2) |
+% | 1, 0, -1 |
%
% FreiChen:{type},{angle}
-% Frei-Chen Edge Detector is a set of 9 unique convolution kernels that
-% are specially weighted.
%
-% Type 0: | -1, 0, 1 |
-% | -sqrt(2), 0, sqrt(2) |
-% | -1, 0, 1 |
+% Frei-Chen Pre-weighted kernels...
+%
+% Type 0: default un-nomalized version shown above.
%
-% This is basically the unnormalized discrete kernel that can be used
-% instead ot a Sobel kernel.
+% Type 1: Orthogonal Kernel (same as type 11 below)
+% | 1, 0, -1 |
+% | sqrt(2), 0, -sqrt(2) | / 2*sqrt(2)
+% | 1, 0, -1 |
%
-% The next 9 kernel types are specially pre-weighted. They should not
-% be normalized. After applying each to the original image, the results
-% is then added together. The square root of the resulting image is
-% the cosine of the edge, and the direction of the feature detection.
+% Type 2: Diagonal form of Kernel...
+% | 1, sqrt(2), 0 |
+% | sqrt(2), 0, -sqrt(2) | / 2*sqrt(2)
+% | 0, -sqrt(2) -1 |
%
-% Type 1: | 1, sqrt(2), 1 |
-% | 0, 0, 0 | / 2*sqrt(2)
-% | -1, -sqrt(2), -1 |
+% However this kernel is als at the heart of the FreiChen Edge Detection
+% Process which uses a set of 9 specially weighted kernel. These 9
+% kernels not be normalized, but directly applied to the image. The
+% results is then added together, to produce the intensity of an edge in
+% a specific direction. The square root of the pixel value can then be
+% taken as the cosine of the edge, and at least 2 such runs at 90 degrees
+% from each other, both the direction and the strength of the edge can be
+% determined.
%
-% Type 2: | 1, 0, 1 |
-% | sqrt(2), 0, sqrt(2) | / 2*sqrt(2)
-% | 1, 0, 1 |
+% Type 10: All 9 of the following pre-weighted kernels...
%
-% Type 3: | 0, -1, sqrt(2) |
-% | 1, 0, -1 | / 2*sqrt(2)
-% | -sqrt(2), 1, 0 |
+% Type 11: | 1, 0, -1 |
+% | sqrt(2), 0, -sqrt(2) | / 2*sqrt(2)
+% | 1, 0, -1 |
%
-% Type 4: | sqrt(2), -1, 0 |
-% | -1, 0, 1 | / 2*sqrt(2)
-% | 0, 1, -sqrt(2) |
+% Type 12: | 1, sqrt(2), 1 |
+% | 0, 0, 0 | / 2*sqrt(2)
+% | 1, sqrt(2), 1 |
%
-% Type 5: | 0, 1, 0 |
-% | -1, 0, -1 | / 2
-% | 0, 1, 0 |
+% Type 13: | sqrt(2), -1, 0 |
+% | -1, 0, 1 | / 2*sqrt(2)
+% | 0, 1, -sqrt(2) |
%
-% Type 6: | -1, 0, 1 |
-% | 0, 0, 0 | / 2
-% | 1, 0, -1 |
+% Type 14: | 0, 1, -sqrt(2) |
+% | -1, 0, 1 | / 2*sqrt(2)
+% | sqrt(2), -1, 0 |
%
-% Type 7: | 1, -2, 1 |
-% | -2, 4, -2 | / 6
-% | 1, -2, 1 |
+% Type 15: | 0, -1, 0 |
+% | 1, 0, 1 | / 2
+% | 0, -1, 0 |
%
-% Type 8: | -2, 1, -2 |
-% | 1, 4, 1 | / 6
-% | -2, 1, -2 |
+% Type 16: | 1, 0, -1 |
+% | 0, 0, 0 | / 2
+% | -1, 0, 1 |
%
-% Type 9: | 1, 1, 1 |
-% | 1, 1, 1 | / 3
-% | 1, 1, 1 |
+% Type 17: | 1, -2, 1 |
+% | -2, 4, -2 | / 6
+% | -1, -2, 1 |
+%
+% Type 18: | -2, 1, -2 |
+% | 1, 4, 1 | / 6
+% | -2, 1, -2 |
+%
+% Type 19: | 1, 1, 1 |
+% | 1, 1, 1 | / 3
+% | 1, 1, 1 |
%
% The first 4 are for edge detection, the next 4 are for line detection
% and the last is to add a average component to the results.
% the default FreiChen (type 0) kernel. As such FreiChen:45 will look
% like a Sobel:45 but with 'sqrt(2)' instead of '2' values.
%
+% WARNING: The above was layed out as per
+% http://www.math.tau.ac.il/~turkel/notes/edge_detectors.pdf
+% But rotated 90 degrees so direction is from left rather than the top.
+% I have yet to find any secondary confirmation of the above. The only
+% other source found was actual source code at
+% http://ltswww.epfl.ch/~courstiv/exos_labos/sol3.pdf
+% Neigher paper defineds the kernels in a way that looks locical or
+% correct when taken as a whole.
%
% Boolean Kernels
%
% Find any peak larger than the pixels the fall between the two radii.
% The default ring of pixels is as per "Ring".
% Edges
-% Find edges of a binary shape
+% Find flat orthogonal edges of a binary shape
% Corners
-% Find corners of a binary shape
-% Ridges
-% Find single pixel ridges or thin lines
-% Ridges2
-% Find 2 pixel thick ridges or lines
-% Ridges3
-% Find 2 pixel thick diagonal ridges (experimental)
-% LineEnds
+% Find 90 degree corners of a binary shape
+% LineEnds:type
% Find end points of lines (for pruning a skeletion)
+% Two types of lines ends (default to both) can be searched for
+% Type 0: All line ends
+% Type 1: single kernel for 4-conneected line ends
+% Type 2: single kernel for simple line ends
% LineJunctions
% Find three line junctions (within a skeletion)
+% Type 0: all line junctions
+% Type 1: Y Junction kernel
+% Type 2: Diagonal T Junction kernel
+% Type 3: Orthogonal T Junction kernel
+% Type 4: Diagonal X Junction kernel
+% Type 5: Orthogonal + Junction kernel
+% Ridges:type
+% Find single pixel ridges or thin lines
+% Type 1: Fine single pixel thick lines and ridges
+% Type 2: Find two pixel thick lines and ridges
% ConvexHull
% Octagonal thicken kernel, to generate convex hulls of 45 degrees
-% Skeleton
-% Thinning kernel, which leaves behind a skeletion of a shape
+% Skeleton:type
+% Traditional skeleton generating kernels.
+% Type 1: Tradional Skeleton kernel (4 connected skeleton)
+% Type 2: HIPR2 Skeleton kernel (8 connected skeleton)
+% Type 3: Experimental Variation to try to present left-right symmetry
+% Type 4: Experimental Variation to preserve left-right symmetry
%
% Distance Measuring Kernels
%
% 'square' like distance function, but one where diagonals are closer
% than expected.
%
-% Manhatten:[{radius}][x{scale}[%!]]
-% Manhatten Distance (also known as Rectilinear Distance, or the Taxi
+% Manhattan:[{radius}][x{scale}[%!]]
+% Manhattan Distance (also known as Rectilinear Distance, or the Taxi
% Cab metric), is the distance needed when you can only travel in
% orthogonal (horizontal or vertical) only. It is the distance a 'Rook'
% in chess would travel. It results in a diamond like distances, where
% To allow the use of fractional distances that you get with diagonals
% the actual distance is scaled by a fixed value which the user can
% provide. This is not actually nessary for either ""Chebyshev" or
-% "Manhatten" distance kernels, but is done for all three distance
+% "Manhattan" distance kernels, but is done for all three distance
% kernels. If no scale is provided it is set to a value of 100,
% allowing for a maximum distance measurement of 655 pixels using a Q16
% version of IM, from any edge. However for small images this can
case CompassKernel:
case KirschKernel:
case FreiChenKernel:
- case CornersKernel: /* Hit and Miss kernels */
+ case EdgesKernel: /* Hit and Miss kernels */
+ case CornersKernel:
case LineEndsKernel:
case LineJunctionsKernel:
- case EdgesKernel:
case RidgesKernel:
- case Ridges2Kernel:
case ConvexHullKernel:
case SkeletonKernel:
- case MatKernel:
- /* A pre-generated kernel is not needed */
- break;
-#if 0 /* set to 1 to do a compile-time check that we haven't missed anything */
+ break; /* A pre-generated kernel is not needed */
+#if 0
+ /* set to 1 to do a compile-time check that we haven't missed anything */
case GaussianKernel:
- case DOGKernel:
- case LOGKernel:
+ case DoGKernel:
+ case LoGKernel:
case BlurKernel:
- case DOBKernel:
case CometKernel:
case DiamondKernel:
case SquareKernel:
case RingKernel:
case PeaksKernel:
case ChebyshevKernel:
- case ManhattenKernel:
+ case ManhattanKernel:
case EuclideanKernel:
#else
default:
switch(type) {
/* Convolution Kernels */
case GaussianKernel:
- case DOGKernel:
- case LOGKernel:
+ case DoGKernel:
+ case LoGKernel:
{ double
sigma = fabs(args->sigma),
sigma2 = fabs(args->xi),
if ( args->rho >= 1.0 )
kernel->width = (size_t)args->rho*2+1;
- else if ( (type != DOGKernel) || (sigma >= sigma2) )
+ else if ( (type != DoGKernel) || (sigma >= sigma2) )
kernel->width = GetOptimalKernelWidth2D(args->rho,sigma);
else
kernel->width = GetOptimalKernelWidth2D(args->rho,sigma2);
* basied on the Error Function 'erf()' (intergral of a gaussian)
*/
- if ( type == GaussianKernel || type == DOGKernel )
- { /* Calculate a Gaussian, OR positive half of a DOG */
+ if ( type == GaussianKernel || type == DoGKernel )
+ { /* Calculate a Gaussian, OR positive half of a DoG */
if ( sigma > MagickEpsilon )
{ A = 1.0/(2.0*sigma*sigma); /* simplify loop expressions */
B = 1.0/(Magick2PI*sigma*sigma);
}
}
- if ( type == DOGKernel )
+ if ( type == DoGKernel )
{ /* Subtract a Negative Gaussian for "Difference of Gaussian" */
if ( sigma2 > MagickEpsilon )
{ sigma = sigma2; /* simplify loop expressions */
kernel->values[kernel->x+kernel->y*kernel->width] -= 1.0;
}
- if ( type == LOGKernel )
+ if ( type == LoGKernel )
{ /* Calculate a Laplacian of a Gaussian - Or Mexician Hat */
if ( sigma > MagickEpsilon )
{ A = 1.0/(2.0*sigma*sigma); /* simplify loop expressions */
break;
}
case BlurKernel:
- case DOBKernel:
{ double
sigma = fabs(args->sigma),
- sigma2 = fabs(args->xi),
- A, B;
+ alpha, beta;
if ( args->rho >= 1.0 )
kernel->width = (size_t)args->rho*2+1;
- else if ( (type == BlurKernel) || (sigma >= sigma2) )
- kernel->width = GetOptimalKernelWidth1D(args->rho,sigma);
else
- kernel->width = GetOptimalKernelWidth1D(args->rho,sigma2);
+ kernel->width = GetOptimalKernelWidth1D(args->rho,sigma);
kernel->height = 1;
kernel->x = (ssize_t) (kernel->width-1)/2;
kernel->y = 0;
/* Calculate a Positive 1D Gaussian */
if ( sigma > MagickEpsilon )
{ sigma *= KernelRank; /* simplify loop expressions */
- A = 1.0/(2.0*sigma*sigma);
- B = 1.0/(MagickSQ2PI*sigma );
+ alpha = 1.0/(2.0*sigma*sigma);
+ beta= 1.0/(MagickSQ2PI*sigma );
for ( u=-v; u <= v; u++) {
- kernel->values[(u+v)/KernelRank] += exp(-((double)(u*u))*A)*B;
+ kernel->values[(u+v)/KernelRank] +=
+ exp(-((double)(u*u))*alpha)*beta;
}
}
else /* special case - generate a unity kernel */
kernel->values[kernel->x+kernel->y*kernel->width] = 1.0;
-
- /* Subtract a Second 1D Gaussian for "Difference of Blur" */
- if ( type == DOBKernel )
- {
- if ( sigma2 > MagickEpsilon )
- { sigma = sigma2*KernelRank; /* simplify loop expressions */
- A = 1.0/(2.0*sigma*sigma);
- B = 1.0/(MagickSQ2PI*sigma);
- for ( u=-v; u <= v; u++)
- kernel->values[(u+v)/KernelRank] -= exp(-((double)(u*u))*A)*B;
- }
- else /* limiting case - a unity (normalized Dirac) kernel */
- kernel->values[kernel->x+kernel->y*kernel->width] -= 1.0;
- }
#else
/* Direct calculation without curve averaging */
/* Calculate a Positive Gaussian */
if ( sigma > MagickEpsilon )
- { A = 1.0/(2.0*sigma*sigma); /* simplify loop expressions */
- B = 1.0/(MagickSQ2PI*sigma);
+ { alpha = 1.0/(2.0*sigma*sigma); /* simplify loop expressions */
+ beta = 1.0/(MagickSQ2PI*sigma);
for ( i=0, u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
- kernel->values[i] = exp(-((double)(u*u))*A)*B;
+ kernel->values[i] = exp(-((double)(u*u))*alpha)*beta;
}
else /* special case - generate a unity kernel */
{ (void) ResetMagickMemory(kernel->values,0, (size_t)
kernel->width*kernel->height*sizeof(double));
kernel->values[kernel->x+kernel->y*kernel->width] = 1.0;
}
-
- /* Subtract a Second 1D Gaussian for "Difference of Blur" */
- if ( type == DOBKernel )
- {
- if ( sigma2 > MagickEpsilon )
- { sigma = sigma2; /* simplify loop expressions */
- A = 1.0/(2.0*sigma*sigma);
- B = 1.0/(MagickSQ2PI*sigma);
- for ( i=0, u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
- kernel->values[i] -= exp(-((double)(u*u))*A)*B;
- }
- else /* limiting case - a unity (normalized Dirac) kernel */
- kernel->values[kernel->x+kernel->y*kernel->width] -= 1.0;
- }
#endif
/* Note the above kernel may have been 'clipped' by a user defined
** radius, producing a smaller (darker) kernel. Also for very small
ScaleKernelInfo(kernel, 1.0, CorrelateNormalizeValue);
/* rotate the 1D kernel by given angle */
- RotateKernelInfo(kernel, (type == BlurKernel) ? args->xi : args->psi );
+ RotateKernelInfo(kernel, args->xi );
break;
}
case CometKernel:
kernel=ParseKernelArray(
"7:-10,-5,-2,-1,-2,-5,-10 -5,0,3,4,3,0,-5 -2,3,6,7,6,3,-2 -1,4,7,8,7,4,-1 -2,3,6,7,6,3,-2 -5,0,3,4,3,0,-5 -10,-5,-2,-1,-2,-5,-10" );
break;
- case 15: /* a 5x5 LOG (sigma approx 1.4) */
+ case 15: /* a 5x5 LoG (sigma approx 1.4) */
kernel=ParseKernelArray(
"5: 0,0,-1,0,0 0,-1,-2,-1,0 -1,-2,16,-2,-1 0,-1,-2,-1,0 0,0,-1,0,0");
break;
- case 19: /* a 9x9 LOG (sigma approx 1.4) */
+ case 19: /* a 9x9 LoG (sigma approx 1.4) */
/* http://www.cscjournals.org/csc/manuscript/Journals/IJIP/volume3/Issue1/IJIP-15.pdf */
kernel=ParseKernelArray(
- "9: 0,-1,-1,-2,-2,-2,-1,-1,0 -1,-2,-4,-5,-5,-5,-4,-2,-1 -1,-4,-5,-3,-0,-3,-5,-4,-1 -2,-5,-3,@12,@24,@12,-3,-5,-2 -2,-5,-0,@24,@40,@24,-0,-5,-2 -2,-5,-3,@12,@24,@12,-3,-5,-2 -1,-4,-5,-3,-0,-3,-5,-4,-1 -1,-2,-4,-5,-5,-5,-4,-2,-1 0,-1,-1,-2,-2,-2,-1,-1,0");
+ "9: 0,-1,-1,-2,-2,-2,-1,-1,0 -1,-2,-4,-5,-5,-5,-4,-2,-1 -1,-4,-5,-3,-0,-3,-5,-4,-1 -2,-5,-3,12,24,12,-3,-5,-2 -2,-5,-0,24,40,24,-0,-5,-2 -2,-5,-3,12,24,12,-3,-5,-2 -1,-4,-5,-3,-0,-3,-5,-4,-1 -1,-2,-4,-5,-5,-5,-4,-2,-1 0,-1,-1,-2,-2,-2,-1,-1,0");
break;
}
if (kernel == (KernelInfo *) NULL)
break;
}
case SobelKernel:
- {
- kernel=ParseKernelArray("3: -1,0,1 -2,0,2 -1,0,1");
+#if 0
+ { /* Sobel with optional 'sub-types' */
+ switch ( (int) args->rho ) {
+ default:
+ case 0:
+ kernel=ParseKernelArray("3: 1,0,-1 2,0,-2 1,0,-1");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ break;
+ case 1:
+ kernel=ParseKernelArray("3: 1,0,-1 2,0,-2 1,0,-1");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ ScaleKernelInfo(kernel, 0.25, NoValue);
+ break;
+ case 2:
+ kernel=ParseKernelArray("3: 1,2,0 2,0,-2 0,-2,-1");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ ScaleKernelInfo(kernel, 0.25, NoValue);
+ break;
+ }
+ if ( fabs(args->sigma) > MagickEpsilon )
+ /* Rotate by correctly supplied 'angle' */
+ RotateKernelInfo(kernel, args->sigma);
+ else if ( args->rho > 30.0 || args->rho < -30.0 )
+ /* Rotate by out of bounds 'type' */
+ RotateKernelInfo(kernel, args->rho);
+ break;
+ }
+#else
+ { /* Simple Sobel Kernel */
+ kernel=ParseKernelArray("3: 1,0,-1 2,0,-2 1,0,-1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
- RotateKernelInfo(kernel, args->rho); /* Rotate by angle */
+ RotateKernelInfo(kernel, args->rho);
break;
}
+#endif
case RobertsKernel:
{
- kernel=ParseKernelArray("3: 0,0,0 -1,1,0 0,0,0");
+ kernel=ParseKernelArray("3: 0,0,0 1,-1,0 0,0,0");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
}
case PrewittKernel:
{
- kernel=ParseKernelArray("3: -1,1,1 0,0,0 -1,1,1");
+ kernel=ParseKernelArray("3: 1,0,-1 1,0,-1 1,0,-1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
}
case CompassKernel:
{
- kernel=ParseKernelArray("3: -1,1,1 -1,-2,1 -1,1,1");
+ kernel=ParseKernelArray("3: 1,1,-1 1,-2,-1 1,1,-1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
}
case KirschKernel:
{
- kernel=ParseKernelArray("3: -3,-3,5 -3,0,5 -3,-3,5");
+ kernel=ParseKernelArray("3: 5,-3,-3 5,0,-3 5,-3,-3");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
break;
}
case FreiChenKernel:
- /* http://www.math.tau.ac.il/~turkel/notes/edge_detectors.pdf */
- /* http://ltswww.epfl.ch/~courstiv/exos_labos/sol3.pdf */
+ /* Direction is set to be left to right positive */
+ /* http://www.math.tau.ac.il/~turkel/notes/edge_detectors.pdf -- RIGHT? */
+ /* http://ltswww.epfl.ch/~courstiv/exos_labos/sol3.pdf -- WRONG? */
{ switch ( (int) args->rho ) {
default:
case 0:
- kernel=ParseKernelArray("3: -1,0,1 -2,0,2 -1,0,1");
+ kernel=ParseKernelArray("3: 1,0,-1 2,0,-2 1,0,-1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
- kernel->values[3] = -MagickSQ2;
- kernel->values[5] = +MagickSQ2;
+ kernel->type = type;
+ kernel->values[3] = +MagickSQ2;
+ kernel->values[5] = -MagickSQ2;
CalcKernelMetaData(kernel); /* recalculate meta-data */
break;
- case 1:
- kernel=ParseKernelArray("3: 1,2,1 0,0,0 -1,2,-1");
+ case 2:
+ kernel=ParseKernelArray("3: 1,2,0 2,0,-2 0,-2,-1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
- kernel->values[1] = +MagickSQ2;
- kernel->values[7] = -MagickSQ2;
+ kernel->values[1] = kernel->values[3] = +MagickSQ2;
+ kernel->values[5] = kernel->values[7] = -MagickSQ2;
CalcKernelMetaData(kernel); /* recalculate meta-data */
ScaleKernelInfo(kernel, 1.0/2.0*MagickSQ2, NoValue);
break;
- case 2:
- kernel=ParseKernelArray("3: 1,0,1 2,0,2 1,0,1");
+ case 10:
+ kernel=AcquireKernelInfo("FreiChen:11;FreiChen:12;FreiChen:13;FreiChen:14;FreiChen:15;FreiChen:16;FreiChen:17;FreiChen:18;FreiChen:19");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ break;
+ case 1:
+ case 11:
+ kernel=ParseKernelArray("3: 1,0,-1 2,0,-2 1,0,-1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
kernel->values[3] = +MagickSQ2;
- kernel->values[5] = +MagickSQ2;
- CalcKernelMetaData(kernel);
+ kernel->values[5] = -MagickSQ2;
+ CalcKernelMetaData(kernel); /* recalculate meta-data */
ScaleKernelInfo(kernel, 1.0/2.0*MagickSQ2, NoValue);
break;
- case 3:
- kernel=ParseKernelArray("3: 0,-1,2 1,0,-1 -2,1,0");
+ case 12:
+ kernel=ParseKernelArray("3: 1,2,1 0,0,0 1,2,1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
- kernel->values[2] = +MagickSQ2;
- kernel->values[6] = -MagickSQ2;
+ kernel->values[1] = +MagickSQ2;
+ kernel->values[7] = +MagickSQ2;
CalcKernelMetaData(kernel);
ScaleKernelInfo(kernel, 1.0/2.0*MagickSQ2, NoValue);
break;
- case 4:
+ case 13:
kernel=ParseKernelArray("3: 2,-1,0 -1,0,1 0,1,-2");
if (kernel == (KernelInfo *) NULL)
return(kernel);
CalcKernelMetaData(kernel);
ScaleKernelInfo(kernel, 1.0/2.0*MagickSQ2, NoValue);
break;
- case 5:
- kernel=ParseKernelArray("3: 0,1,0 -1,0,-1 0,1,0");
+ case 14:
+ kernel=ParseKernelArray("3: 0,1,-2 -1,0,1 2,-1,0");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ kernel->values[2] = -MagickSQ2;
+ kernel->values[6] = +MagickSQ2;
+ CalcKernelMetaData(kernel);
+ ScaleKernelInfo(kernel, 1.0/2.0*MagickSQ2, NoValue);
+ break;
+ case 15:
+ kernel=ParseKernelArray("3: 0,-1,0 1,0,1 0,-1,0");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
ScaleKernelInfo(kernel, 1.0/2.0, NoValue);
break;
- case 6:
- kernel=ParseKernelArray("3: -1,0,1 0,0,0 1,0,-1");
+ case 16:
+ kernel=ParseKernelArray("3: 1,0,-1 0,0,0 -1,0,1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
ScaleKernelInfo(kernel, 1.0/2.0, NoValue);
break;
- case 7:
- kernel=ParseKernelArray("3: 1,-2,1 -2,4,-2 1,-2,1");
+ case 17:
+ kernel=ParseKernelArray("3: 1,-2,1 -2,4,-2 -1,-2,1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
ScaleKernelInfo(kernel, 1.0/6.0, NoValue);
break;
- case 8:
+ case 18:
kernel=ParseKernelArray("3: -2,1,-2 1,4,1 -2,1,-2");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
ScaleKernelInfo(kernel, 1.0/6.0, NoValue);
break;
- case 9:
+ case 19:
kernel=ParseKernelArray("3: 1,1,1 1,1,1 1,1,1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
ScaleKernelInfo(kernel, 1.0/3.0, NoValue);
break;
- case -1:
- kernel=AcquireKernelInfo("FreiChen:1;FreiChen:2;FreiChen:3;FreiChen:4;FreiChen:5;FreiChen:6;FreiChen:7;FreiChen:8;FreiChen:9");
- if (kernel == (KernelInfo *) NULL)
- return(kernel);
- break;
}
if ( fabs(args->sigma) > MagickEpsilon )
/* Rotate by correctly supplied 'angle' */
/* set all kernel values within diamond area to scale given */
for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
- if ((labs(u)+labs(v)) <= (ssize_t)kernel->x)
+ if ( (labs((long) u)+labs((long) v)) <= (long) kernel->x)
kernel->positive_range += kernel->values[i] = args->sigma;
else
kernel->values[i] = nan;
return(DestroyKernelInfo(kernel));
/* set all kernel values to scale given */
- u=(ssize_t) kernel->width*kernel->height;
+ u=(ssize_t) (kernel->width*kernel->height);
for ( i=0; i < u; i++)
kernel->values[i] = scale;
kernel->minimum = kernel->maximum = scale; /* a flat shape */
}
case DiskKernel:
{
- ssize_t limit = (ssize_t)(args->rho*args->rho);
- if (args->rho < 0.1) /* default radius approx 3.5 */
+ ssize_t
+ limit = (ssize_t)(args->rho*args->rho);
+
+ if (args->rho < 0.4) /* default radius approx 3.5 */
kernel->width = kernel->height = 7L, limit = 10L;
else
- kernel->width = kernel->height = ((size_t)args->rho)*2+1;
+ kernel->width = kernel->height = (size_t)fabs(args->rho)*2+1;
kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
kernel->values=(double *) AcquireQuantumMemory(kernel->width,
if (args->rho < args->sigma)
{
kernel->width = ((size_t)args->sigma)*2+1;
- limit1 = (ssize_t)args->rho*args->rho;
- limit2 = (ssize_t)args->sigma*args->sigma;
+ limit1 = (ssize_t)(args->rho*args->rho);
+ limit2 = (ssize_t)(args->sigma*args->sigma);
}
else
{
kernel->width = ((size_t)args->rho)*2+1;
- limit1 = (ssize_t)args->sigma*args->sigma;
- limit2 = (ssize_t)args->rho*args->rho;
+ limit1 = (ssize_t)(args->sigma*args->sigma);
+ limit2 = (ssize_t)(args->rho*args->rho);
}
if ( limit2 <= 0 )
kernel->width = 7L, limit1 = 7L, limit2 = 11L;
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
- ExpandKernelInfo(kernel, 90.0); /* Create a list of 4 rotated kernels */
+ ExpandMirrorKernelInfo(kernel); /* mirror expansion of other kernels */
break;
}
case CornersKernel:
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
- ExpandKernelInfo(kernel, 90.0); /* Create a list of 4 rotated kernels */
- break;
- }
- case RidgesKernel:
- {
- kernel=ParseKernelArray("3x1:0,1,0");
- if (kernel == (KernelInfo *) NULL)
- return(kernel);
- kernel->type = type;
- ExpandKernelInfo(kernel, 90.0); /* 2 rotated kernels (symmetrical) */
- break;
- }
- case Ridges2Kernel:
- {
- KernelInfo
- *new_kernel;
- kernel=ParseKernelArray("4x1:0,1,1,0");
- if (kernel == (KernelInfo *) NULL)
- return(kernel);
- kernel->type = type;
- ExpandKernelInfo(kernel, 90.0); /* 4 rotated kernels */
-#if 0
- /* 2 pixel diagonaly thick - 4 rotates - not needed? */
- new_kernel=ParseKernelArray("4x4^:0,-,-,- -,1,-,- -,-,1,- -,-,-,0'");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- ExpandKernelInfo(new_kernel, 90.0); /* 4 rotated kernels */
- LastKernelInfo(kernel)->next = new_kernel;
-#endif
- /* kernels to find a stepped 'thick' line - 4 rotates * mirror */
- /* Unfortunatally we can not yet rotate a non-square kernel */
- /* But then we can't flip a non-symetrical kernel either */
- new_kernel=ParseKernelArray("4x3+1+1:0,1,1,- -,1,1,- -,1,1,0");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- LastKernelInfo(kernel)->next = new_kernel;
- new_kernel=ParseKernelArray("4x3+2+1:0,1,1,- -,1,1,- -,1,1,0");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- LastKernelInfo(kernel)->next = new_kernel;
- new_kernel=ParseKernelArray("4x3+1+1:-,1,1,0 -,1,1,- 0,1,1,-");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- LastKernelInfo(kernel)->next = new_kernel;
- new_kernel=ParseKernelArray("4x3+2+1:-,1,1,0 -,1,1,- 0,1,1,-");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- LastKernelInfo(kernel)->next = new_kernel;
- new_kernel=ParseKernelArray("3x4+1+1:0,-,- 1,1,1 1,1,1 -,-,0");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- LastKernelInfo(kernel)->next = new_kernel;
- new_kernel=ParseKernelArray("3x4+1+2:0,-,- 1,1,1 1,1,1 -,-,0");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- LastKernelInfo(kernel)->next = new_kernel;
- new_kernel=ParseKernelArray("3x4+1+1:-,-,0 1,1,1 1,1,1 0,-,-");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- LastKernelInfo(kernel)->next = new_kernel;
- new_kernel=ParseKernelArray("3x4+1+2:-,-,0 1,1,1 1,1,1 0,-,-");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- LastKernelInfo(kernel)->next = new_kernel;
+ ExpandRotateKernelInfo(kernel, 90.0); /* Expand 90 degree rotations */
break;
}
case LineEndsKernel:
- {
- KernelInfo
- *new_kernel;
- kernel=ParseKernelArray("3: 0,0,0 0,1,0 -,1,-");
- if (kernel == (KernelInfo *) NULL)
- return(kernel);
- kernel->type = type;
- ExpandKernelInfo(kernel, 90.0);
- /* append second set of 4 kernels */
- new_kernel=ParseKernelArray("3: 0,0,0 0,1,0 0,0,1");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- ExpandKernelInfo(new_kernel, 90.0);
- LastKernelInfo(kernel)->next = new_kernel;
+ { /* Kernels for finding the end of thin lines */
+ switch ( (int) args->rho ) {
+ case 0:
+ default:
+ /* set of kernels to find all end of lines */
+ kernel=AcquireKernelInfo("LineEnds:1>;LineEnds:2>");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ break;
+ case 1:
+ /* kernel for 4-connected line ends - no rotation */
+ kernel=ParseKernelArray("3: 0,0,0 0,1,0 -,1,-");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ break;
+ case 2:
+ /* kernel to add for 8-connected lines - no rotation */
+ kernel=ParseKernelArray("3: 0,0,0 0,1,0 0,0,1");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ break;
+ }
break;
}
case LineJunctionsKernel:
- {
+ { /* kernels for finding the junctions of multiple lines */
+ switch ( (int) args->rho ) {
+ case 0:
+ default:
+ /* set of kernels to find all line junctions */
+ kernel=AcquireKernelInfo("LineJunctions:1@;LineJunctions:2>");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ break;
+ case 1:
+ /* Y Junction */
+ kernel=ParseKernelArray("3: 1,-,1 -,1,- -,1,-");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ break;
+ case 2:
+ /* Diagonal T Junctions */
+ kernel=ParseKernelArray("3: 1,-,- -,1,- 1,-,1");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ break;
+ case 3:
+ /* Orthogonal T Junctions */
+ kernel=ParseKernelArray("3: -,-,- 1,1,1 -,1,-");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ break;
+ case 4:
+ /* Diagonal X Junctions */
+ kernel=ParseKernelArray("3: 1,-,1 -,1,- 1,-,1");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ break;
+ case 5:
+ /* Orthogonal X Junctions - minimal diamond kernel */
+ kernel=ParseKernelArray("3: -,1,- 1,1,1 -,1,-");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ break;
+ }
+ break;
+ }
+ case RidgesKernel:
+ { /* Ridges - Ridge finding kernels */
KernelInfo
*new_kernel;
- /* first set of 4 kernels */
- kernel=ParseKernelArray("3: -,1,- -,1,- 1,-,1");
- if (kernel == (KernelInfo *) NULL)
- return(kernel);
- kernel->type = type;
- ExpandKernelInfo(kernel, 45.0);
- /* append second set of 4 kernels */
- new_kernel=ParseKernelArray("3: 1,-,- -,1,- 1,-,1");
- if (new_kernel == (KernelInfo *) NULL)
- return(DestroyKernelInfo(kernel));
- new_kernel->type = type;
- ExpandKernelInfo(new_kernel, 90.0);
- LastKernelInfo(kernel)->next = new_kernel;
+ switch ( (int) args->rho ) {
+ case 1:
+ default:
+ kernel=ParseKernelArray("3x1:0,1,0");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ ExpandRotateKernelInfo(kernel, 90.0); /* 2 rotated kernels (symmetrical) */
+ break;
+ case 2:
+ kernel=ParseKernelArray("4x1:0,1,1,0");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ ExpandRotateKernelInfo(kernel, 90.0); /* 4 rotated kernels */
+
+ /* Kernels to find a stepped 'thick' line, 4 rotates + mirrors */
+ /* Unfortunatally we can not yet rotate a non-square kernel */
+ /* But then we can't flip a non-symetrical kernel either */
+ new_kernel=ParseKernelArray("4x3+1+1:0,1,1,- -,1,1,- -,1,1,0");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("4x3+2+1:0,1,1,- -,1,1,- -,1,1,0");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("4x3+1+1:-,1,1,0 -,1,1,- 0,1,1,-");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("4x3+2+1:-,1,1,0 -,1,1,- 0,1,1,-");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("3x4+1+1:0,-,- 1,1,1 1,1,1 -,-,0");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("3x4+1+2:0,-,- 1,1,1 1,1,1 -,-,0");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("3x4+1+1:-,-,0 1,1,1 1,1,1 0,-,-");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("3x4+1+2:-,-,0 1,1,1 1,1,1 0,-,-");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ break;
+ }
break;
}
case ConvexHullKernel:
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = type;
- ExpandKernelInfo(kernel, 45.0);
- /* append the mirror versions too */
+ ExpandRotateKernelInfo(kernel, 90.0);
+ /* append the mirror versions too - no flip function yet */
new_kernel=ParseKernelArray("3: 1,1,1 1,0,- -,-,0");
if (new_kernel == (KernelInfo *) NULL)
return(DestroyKernelInfo(kernel));
new_kernel->type = type;
- ExpandKernelInfo(new_kernel, 45.0);
+ ExpandRotateKernelInfo(new_kernel, 90.0);
LastKernelInfo(kernel)->next = new_kernel;
break;
}
case SkeletonKernel:
- { /* what is the best form for skeletonization by thinning? */
-#if 0
-# if 0
- kernel=AcquireKernelInfo("Corners;Edges");
-# else
- kernel=AcquireKernelInfo("Edges;Corners");
-# endif
-#else
- kernel=ParseKernelArray("3: 0,0,- 0,1,1 -,1,1");
- if (kernel == (KernelInfo *) NULL)
- return(kernel);
- kernel->type = type;
- ExpandKernelInfo(kernel, 45);
- break;
-#endif
- break;
- }
- case MatKernel: /* experimental - MAT from a Distance Gradient */
{
KernelInfo
*new_kernel;
- /* Ridge Kernel but without the diagonal */
- kernel=ParseKernelArray("3x1: 0,1,0");
- if (kernel == (KernelInfo *) NULL)
- return(kernel);
- kernel->type = RidgesKernel;
- ExpandKernelInfo(kernel, 90.0); /* 2 rotated kernels (symmetrical) */
- /* Plus the 2 pixel ridges kernel - no diagonal */
- new_kernel=AcquireKernelBuiltIn(Ridges2Kernel,args);
- if (new_kernel == (KernelInfo *) NULL)
- return(kernel);
- LastKernelInfo(kernel)->next = new_kernel;
+ switch ( (int) args->rho ) {
+ case 1:
+ default:
+ /* Traditional Skeleton...
+ ** A cyclically rotated single kernel
+ */
+ kernel=ParseKernelArray("3: 0,0,0 -,1,- 1,1,1");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ ExpandRotateKernelInfo(kernel, 45.0); /* 8 rotations */
+ break;
+ case 2:
+ /* HIPR Variation of the cyclic skeleton
+ ** Corners of the traditional method made more forgiving,
+ ** but the retain the same cyclic order.
+ */
+ kernel=ParseKernelArray("3: 0,0,0 -,1,- 1,1,1");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ new_kernel=ParseKernelArray("3: -,0,0 1,1,0 -,1,-");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(new_kernel);
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ ExpandRotateKernelInfo(kernel, 90.0); /* 4 rotations of the 2 kernels */
+ break;
+ case 3:
+ /* Jittered Skeleton: do top, then bottom, then each sides */
+ /* Do top edge */
+ kernel=ParseKernelArray("3: 0,0,0 -,1,- 1,1,1");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ new_kernel=ParseKernelArray("3: 0,0,- 0,1,1 -,1,-");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(new_kernel);
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("3: -,0,0 1,1,0 -,1,-");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(new_kernel);
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ /* Do Bottom edge */
+ new_kernel=ParseKernelArray("3: 1,1,1 -,1,- 0,0,0");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(new_kernel);
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("3: -,1,- 1,1,0 -,0,0");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(new_kernel);
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("3: -,1,- 0,1,1 0,0,-");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(new_kernel);
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ /* Last the two sides */
+ new_kernel=ParseKernelArray("3: 0,-,1 0,1,1 0,-,1");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(new_kernel);
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("3: 1,-,0 1,1,0 1,-,0");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(new_kernel);
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ break;
+ case 4:
+ /* Just a simple 'Edge' kernel, but with a extra two kernels
+ ** to finish off diagonal lines, top then bottom then sides.
+ ** Works well for test case but fails for general case.
+ */
+ kernel=ParseKernelArray("3: 0,0,0 -,1,- 1,1,1");
+ if (kernel == (KernelInfo *) NULL)
+ return(kernel);
+ kernel->type = type;
+ new_kernel=ParseKernelArray("3: 0,0,0 0,1,1 1,1,-");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ new_kernel=ParseKernelArray("3: 0,0,0 1,1,0 -,1,1");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ LastKernelInfo(kernel)->next = new_kernel;
+ ExpandMirrorKernelInfo(kernel);
+ /* Append a set of corner kernels */
+ new_kernel=ParseKernelArray("3: 0,0,- 0,1,1 -,1,-");
+ if (new_kernel == (KernelInfo *) NULL)
+ return(DestroyKernelInfo(kernel));
+ new_kernel->type = type;
+ ExpandRotateKernelInfo(new_kernel, 90.0);
+ LastKernelInfo(kernel)->next = new_kernel;
+ break;
+ }
break;
}
/* Distance Measuring Kernels */
for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
kernel->positive_range += ( kernel->values[i] =
- args->sigma*((labs(u)>labs(v)) ? labs(u) : labs(v)) );
+ args->sigma*((labs((long) u)>labs((long) v)) ? labs((long) u) : labs((long) v)) );
kernel->maximum = kernel->values[0];
break;
}
- case ManhattenKernel:
+ case ManhattanKernel:
{
if (args->rho < 1.0)
kernel->width = kernel->height = 3; /* default radius = 1 */
for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
kernel->positive_range += ( kernel->values[i] =
- args->sigma*(labs(u)+labs(v)) );
+ args->sigma*(labs((long) u)+labs((long) v)) );
kernel->maximum = kernel->values[0];
break;
}
case UnityKernel:
default:
{
- /* Unity or No-Op Kernel - 3x3 with 1 in center */
- kernel=ParseKernelArray("3:0,0,0,0,1,0,0,0,0");
+ /* Unity or No-Op Kernel - Basically just a single pixel on its own */
+ kernel=ParseKernelArray("1:1");
if (kernel == (KernelInfo *) NULL)
return(kernel);
kernel->type = ( type == UnityKernel ) ? UnityKernel : UndefinedKernel;
% o kernel: the Morphology/Convolution kernel to be destroyed
%
*/
-
MagickExport KernelInfo *DestroyKernelInfo(KernelInfo *kernel)
{
assert(kernel != (KernelInfo *) NULL);
% %
% %
% %
-% E x p a n d K e r n e l I n f o %
+% E x p a n d M i r r o r K e r n e l I n f o %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% ExpandMirrorKernelInfo() takes a single kernel, and expands it into a
+% sequence of 90-degree rotated kernels but providing a reflected 180
+% rotatation, before the -/+ 90-degree rotations.
+%
+% This special rotation order produces a better, more symetrical thinning of
+% objects.
+%
+% The format of the ExpandMirrorKernelInfo method is:
+%
+% void ExpandMirrorKernelInfo(KernelInfo *kernel)
+%
+% A description of each parameter follows:
+%
+% o kernel: the Morphology/Convolution kernel
+%
+% This function is only internel to this module, as it is not finalized,
+% especially with regard to non-orthogonal angles, and rotation of larger
+% 2D kernels.
+*/
+
+#if 0
+static void FlopKernelInfo(KernelInfo *kernel)
+ { /* Do a Flop by reversing each row. */
+ size_t
+ y;
+ register ssize_t
+ x,r;
+ register double
+ *k,t;
+
+ for ( y=0, k=kernel->values; y < kernel->height; y++, k+=kernel->width)
+ for ( x=0, r=kernel->width-1; x<kernel->width/2; x++, r--)
+ t=k[x], k[x]=k[r], k[r]=t;
+
+ kernel->x = kernel->width - kernel->x - 1;
+ angle = fmod(angle+180.0, 360.0);
+ }
+#endif
+
+static void ExpandMirrorKernelInfo(KernelInfo *kernel)
+{
+ KernelInfo
+ *clone,
+ *last;
+
+ last = kernel;
+
+ clone = CloneKernelInfo(last);
+ RotateKernelInfo(clone, 180); /* flip */
+ LastKernelInfo(last)->next = clone;
+ last = clone;
+
+ clone = CloneKernelInfo(last);
+ RotateKernelInfo(clone, 90); /* transpose */
+ LastKernelInfo(last)->next = clone;
+ last = clone;
+
+ clone = CloneKernelInfo(last);
+ RotateKernelInfo(clone, 180); /* flop */
+ LastKernelInfo(last)->next = clone;
+
+ return;
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% E x p a n d R o t a t e K e r n e l I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% ExpandKernelInfo() takes a single kernel, and expands it into a list
-% of kernels each incrementally rotated the angle given.
+% ExpandRotateKernelInfo() takes a kernel list, and expands it by rotating
+% incrementally by the angle given, until the first kernel repeats.
%
% WARNING: 45 degree rotations only works for 3x3 kernels.
% While 90 degree roatations only works for linear and square kernels
%
-% The format of the RotateKernelInfo method is:
+% The format of the ExpandRotateKernelInfo method is:
%
-% void ExpandKernelInfo(KernelInfo *kernel, double angle)
+% void ExpandRotateKernelInfo(KernelInfo *kernel, double angle)
%
% A description of each parameter follows:
%
return MagickTrue;
}
-static void ExpandKernelInfo(KernelInfo *kernel, const double angle)
+static void ExpandRotateKernelInfo(KernelInfo *kernel, const double angle)
{
KernelInfo
*clone,
RotateKernelInfo(clone, angle);
if ( SameKernelInfo(kernel, clone) == MagickTrue )
break;
- last->next = clone;
+ LastKernelInfo(last)->next = clone;
last = clone;
}
- clone = DestroyKernelInfo(clone); /* This was the same as the first - junk */
+ clone = DestroyKernelInfo(clone); /* kernel has repeated - junk the clone */
return;
}
\f
% a list of multiple kernels.
%
% It is basically equivelent to as MorphologyImageChannel() (see below) but
-% without user controls, that that function extracts and applies to kernels
-% and morphology methods.
+% without any user controls. This allows internel programs to use this
+% function, to actually perform a specific task without posible interference
+% by any API user supplied settings.
+%
+% It is MorphologyImageChannel() task to extract any such user controls, and
+% pass them to this function for processing.
%
% More specifically kernels are not normalized/scaled/blended by the
-% 'convolve:scale' Image Artifact (-set setting), and the convolve bias
-% (-bias setting or image->bias) is passed directly to this function,
-% and not extracted from an image.
+% 'convolve:scale' Image Artifact (setting), nor is the convolve bias
+% (-bias setting or image->bias) loooked at, but must be supplied from the
+% function arguments.
%
% The format of the MorphologyApply method is:
%
MagickOffsetType
progress;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
+ assert(result_image != (Image *) NULL);
+ assert(result_image->signature == MagickSignature);
+ assert(kernel != (KernelInfo *) NULL);
+ assert(kernel->signature == MagickSignature);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+
status=MagickTrue;
changed=0;
progress=0;
case HitAndMissMorphology:
case ThinningMorphology:
case ThickenMorphology:
- /* kernel is user as is, without reflection */
+ /* kernel is used as is, without reflection */
break;
default:
assert("Not a Primitive Morphology Method" != (char *) NULL);
** neighbourhoods, 0.0 for background, and 1.0 for foreground
** with either Nan or 0.5 values for don't care.
**
- ** Note that this can produce negative results, though really
- ** only a positive match has any real value.
+ ** Note that this will never produce a meaningless negative
+ ** result. Such results can cause Thinning/Thicken to not work
+ ** correctly when used against a greyscale image.
*/
k = kernel->values;
k_pixels = p;
k_pixels += image->columns+kernel->width;
k_indexes += image->columns+kernel->width;
}
- /* Pattern Match only if min fg larger than min bg pixels */
+ /* Pattern Match if difference is positive */
min.red -= max.red; Maximize( min.red, 0.0 );
min.green -= max.green; Maximize( min.green, 0.0 );
min.blue -= max.blue; Maximize( min.blue, 0.0 );
result.index -= min.index;
break;
case ThickenMorphology:
- /* Union with original image (maximize) - or should this be + */
- Maximize( result.red, min.red );
- Maximize( result.green, min.green );
- Maximize( result.blue, min.blue );
- Maximize( result.opacity, min.opacity );
- Maximize( result.index, min.index );
+ /* Add the pattern matchs to the original */
+ result.red += min.red;
+ result.green += min.green;
+ result.blue += min.blue;
+ result.opacity += min.opacity;
+ result.index += min.index;
break;
default:
/* result directly calculated or assigned */
stage_limit = 2;
break;
case HitAndMissMorphology:
- kernel_limit = 1; /* no method or kernel iteration */
rslt_compose = LightenCompositeOp; /* Union of multi-kernel results */
- break;
+ /* FALL THUR */
case ThinningMorphology:
case ThickenMorphology:
- case DistanceMorphology:
- method_limit = kernel_limit; /* iterate method with each kernel */
+ method_limit = kernel_limit; /* iterate the whole method */
kernel_limit = 1; /* do not do kernel iteration */
- rslt_compose = NoCompositeOp; /* Re-iterate with multiple kernels */
break;
default:
break;
/* Loop 2: iterate over each kernel in a multi-kernel list */
norm_kernel = (KernelInfo *) kernel;
+ this_kernel = (KernelInfo *) kernel;
rflt_kernel = reflected_kernel;
+
kernel_number = 0;
while ( norm_kernel != NULL ) {
primative = ErodeIntensityMorphology;
if ( stage_loop == 2 )
primative = DilateIntensityMorphology;
+ break;
case CloseMorphology: /* dilate, then erode */
case BottomHatMorphology: /* close and image difference */
this_kernel = rflt_kernel; /* use the reflected kernel */
default:
break;
}
+ assert( this_kernel != (KernelInfo *) NULL );
/* Extra information for debugging compound operations */
if ( verbose == MagickTrue ) {
if ( stage_limit > 1 )
- (void) FormatMagickString(v_info, MaxTextExtent, "%s:%lu.%lu -> ",
- MagickOptionToMnemonic(MagickMorphologyOptions, method),
- method_loop, stage_loop );
+ (void) FormatMagickString(v_info,MaxTextExtent,"%s:%.20g.%.20g -> ",
+ MagickOptionToMnemonic(MagickMorphologyOptions,method),(double)
+ method_loop,(double) stage_loop);
else if ( primative != method )
- (void) FormatMagickString(v_info, MaxTextExtent, "%s:%lu -> ",
- MagickOptionToMnemonic(MagickMorphologyOptions, method),
- method_loop );
+ (void) FormatMagickString(v_info, MaxTextExtent, "%s:%.20g -> ",
+ MagickOptionToMnemonic(MagickMorphologyOptions, method),(double)
+ method_loop);
else
v_info[0] = '\0';
}
if ( verbose == MagickTrue ) {
if ( kernel_loop > 1 )
fprintf(stderr, "\n"); /* add end-of-line from previous */
- fprintf(stderr, "%s%s%s:%lu.%lu #%lu => Changed %lu", v_info,
- MagickOptionToMnemonic(MagickMorphologyOptions, primative),
- ( this_kernel == rflt_kernel ) ? "*" : "",
- method_loop+kernel_loop-1, kernel_number, count, changed);
+ (void) fprintf(stderr, "%s%s%s:%.20g.%.20g #%.20g => Changed %.20g",
+ v_info,MagickOptionToMnemonic(MagickMorphologyOptions,
+ primative),(this_kernel == rflt_kernel ) ? "*" : "",
+ (double) (method_loop+kernel_loop-1),(double) kernel_number,
+ (double) count,(double) changed);
}
/* prepare next loop */
{ Image *tmp = work_image; /* swap images for iteration */
} /* End Loop 4: Iterate the kernel with primative */
if ( verbose == MagickTrue && kernel_changed != changed )
- fprintf(stderr, " Total %lu", kernel_changed);
+ fprintf(stderr, " Total %.20g",(double) kernel_changed);
if ( verbose == MagickTrue && stage_loop < stage_limit )
fprintf(stderr, "\n"); /* add end-of-line before looping */
#if 0
- fprintf(stderr, "--E-- image=0x%lx\n", (size_t)image);
- fprintf(stderr, " curr =0x%lx\n", (size_t)curr_image);
- fprintf(stderr, " work =0x%lx\n", (size_t)work_image);
- fprintf(stderr, " save =0x%lx\n", (size_t)save_image);
- fprintf(stderr, " union=0x%lx\n", (size_t)rslt_image);
+ fprintf(stderr, "--E-- image=0x%lx\n", (unsigned long)image);
+ fprintf(stderr, " curr =0x%lx\n", (unsigned long)curr_image);
+ fprintf(stderr, " work =0x%lx\n", (unsigned long)work_image);
+ fprintf(stderr, " save =0x%lx\n", (unsigned long)save_image);
+ fprintf(stderr, " union=0x%lx\n", (unsigned long)rslt_image);
#endif
} /* End Loop 3: Primative (staging) Loop for Coumpound Methods */
** below ensures the methematical compose method is applied in a
** purely mathematical way, and only to the selected channels.
** Turn off SVG composition 'alpha blending'.
+ **
+ ** The compose image order is specifically so that the new image can
+ ** be subtarcted 'Minus' from the collected result, to allow you to
+ ** convert a HitAndMiss methd into a Thinning method.
*/
if ( verbose == MagickTrue )
fprintf(stderr, " (compose \"%s\")",
MagickOptionToMnemonic(MagickComposeOptions, rslt_compose) );
- (void) CompositeImageChannel(rslt_image,
+ (void) CompositeImageChannel(curr_image,
(ChannelType) (channel & ~SyncChannels), rslt_compose,
- curr_image, 0, 0);
+ rslt_image, 0, 0);
+ rslt_image = DestroyImage(rslt_image);
+ rslt_image = curr_image;
curr_image = (Image *) image; /* continue with original image */
}
if ( verbose == MagickTrue )
if ( method == ConvolveMorphology || method == CorrelateMorphology )
{
artifact = GetImageArtifact(image,"convolve:scale");
- if ( artifact != (char *)NULL ) {
+ if ( artifact != (const char *)NULL ) {
if ( curr_kernel == kernel )
curr_kernel = CloneKernelInfo(kernel);
if (curr_kernel == (KernelInfo *) NULL) {
if ( artifact != (const char *) NULL)
ShowKernelInfo(curr_kernel);
- /* override the default handling of multi-kernel morphology results
- * if 'Undefined' use the default method
- * if 'None' (default for 'Convolve') re-iterate previous result
- * otherwise merge resulting images using compose method given
+ /* Override the default handling of multi-kernel morphology results
+ * If 'Undefined' use the default method
+ * If 'None' (default for 'Convolve') re-iterate previous result
+ * Otherwise merge resulting images using compose method given.
+ * Default for 'HitAndMiss' is 'Lighten'.
*/
compose = UndefinedCompositeOp; /* use default for method */
artifact = GetImageArtifact(image,"morphology:compose");
switch (kernel->type) {
/* These built-in kernels are cylindrical kernels, rotating is useless */
case GaussianKernel:
- case DOGKernel:
+ case DoGKernel:
+ case LoGKernel:
case DiskKernel:
case PeaksKernel:
case LaplacianKernel:
case ChebyshevKernel:
- case ManhattenKernel:
+ case ManhattanKernel:
case EuclideanKernel:
return;
else if ( x == 0 ) x = -y;
else if ( x == -y ) y = 0;
else if ( y == 0 ) y = x;
- kernel->x = (size_t) x+1;
- kernel->y = (size_t) y+1;
+ kernel->x = (ssize_t) x+1;
+ kernel->y = (ssize_t) y+1;
}
angle = fmod(angle+315.0, 360.0); /* angle reduced 45 degrees */
kernel->angle = fmod(kernel->angle+45.0, 360.0);
if ( 45.0 < fmod(angle, 180.0) && fmod(angle,180.0) <= 135.0 )
{
if ( kernel->width == 1 || kernel->height == 1 )
- { /* Do a transpose of the image, which results in a 90
- ** degree rotation of a 1 dimentional kernel
+ { /* Do a transpose of a 1 dimentional kernel,
+ ** which results in a fast 90 degree rotation of some type.
*/
ssize_t
t;
}
/* rotate the origin - relative to center of array */
{ register ssize_t x,y;
- x = (ssize_t) kernel->x*2-kernel->width+1;
- y = (ssize_t) kernel->y*2-kernel->height+1;
- kernel->x = (size_t) ( -y +kernel->width-1)/2;
- kernel->y = (size_t) ( +x +kernel->height-1)/2;
+ x = (ssize_t) (kernel->x*2-kernel->width+1);
+ y = (ssize_t) (kernel->y*2-kernel->height+1);
+ kernel->x = (ssize_t) ( -y +(ssize_t) kernel->width-1)/2;
+ kernel->y = (ssize_t) ( +x +(ssize_t) kernel->height-1)/2;
}
angle = fmod(angle+270.0, 360.0); /* angle reduced 90 degrees */
kernel->angle = fmod(kernel->angle+90.0, 360.0);
* performed here, posibily with a linear kernel restriction.
*/
-#if 0
- { /* Do a Flop by reversing each row.
- */
- size_t
- y;
- register ssize_t
- x,r;
- register double
- *k,t;
-
- for ( y=0, k=kernel->values; y < kernel->height; y++, k+=kernel->width)
- for ( x=0, r=kernel->width-1; x<kernel->width/2; x++, r--)
- t=k[x], k[x]=k[r], k[r]=t;
-
- kernel->x = kernel->width - kernel->x - 1;
- angle = fmod(angle+180.0, 360.0);
- }
-#endif
return;
}
\f
fprintf(stderr, "Kernel");
if ( kernel->next != (KernelInfo *) NULL )
- fprintf(stderr, " #%lu", c );
+ fprintf(stderr, " #%lu", (unsigned long) c );
fprintf(stderr, " \"%s",
MagickOptionToMnemonic(MagickKernelOptions, k->type) );
if ( fabs(k->angle) > MagickEpsilon )
fprintf(stderr, "@%lg", k->angle);
- fprintf(stderr, "\" of size %lux%lu%+ld%+ld",
- k->width, k->height,
- k->x, k->y );
+ fprintf(stderr, "\" of size %lux%lu%+ld%+ld",(unsigned long) k->width,
+ (unsigned long) k->height,(long) k->x,(long) k->y);
fprintf(stderr,
" with values from %.*lg to %.*lg\n",
GetMagickPrecision(), k->minimum,
fprintf(stderr, " (Sum %.*lg)\n",
GetMagickPrecision(), k->positive_range+k->negative_range);
for (i=v=0; v < k->height; v++) {
- fprintf(stderr, "%2lu:", v );
+ fprintf(stderr, "%2lu:", (unsigned long) v );
for (u=0; u < k->width; u++, i++)
if ( IsNan(k->values[i]) )
fprintf(stderr," %*s", GetMagickPrecision()+3, "nan");
% value is usually provided by the user as a percentage value in the
% 'convolve:scale' setting.
%
-% The resulting effect is to either convert a 'zero-summing' edge detection
-% kernel (such as a "Laplacian", "DOG" or a "LOG") into a 'sharpening'
-% kernel.
-%
-% Alternativally by using a purely positive kernel, and using a negative
-% post-normalizing scaling factor, you can convert a 'blurring' kernel (such
-% as a "Gaussian") into a 'unsharp' kernel.
+% The resulting effect is to convert the defined kernels into blended
+% soft-blurs, unsharp kernels or into sharpening kernels.
%
% The format of the UnityAdditionKernelInfo method is:
%