// bilateral.c (634, 1) // pixBilateralGrayExact(pixs, spatial_kel, range_kel) as Pix // pixBilateralGrayExact(PIX *, L_KERNEL *, L_KERNEL *) as PIX * /// <summary> /// (1) See pixBilateralExact(). /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixBilateralGrayExact/*"/> /// <param name="pixs">[in] - 8 bpp gray</param> /// <param name="spatial_kel">[in] - gaussian kernel</param> /// <param name="range_kel">[in][optional] - 256 x 1, monotonically decreasing</param> /// <returns>pixd 8 bpp bilateral filtered image</returns> public static Pix pixBilateralGrayExact( Pix pixs, L_Kernel spatial_kel, L_Kernel range_kel = null) { if (pixs == null) { throw new ArgumentNullException("pixs cannot be Nothing"); } if (spatial_kel == null) { throw new ArgumentNullException("spatial_kel cannot be Nothing"); } IntPtr range_kelPtr = IntPtr.Zero; if (range_kel != null) { range_kelPtr = range_kel.Pointer; } IntPtr _Result = Natives.pixBilateralGrayExact(pixs.Pointer, spatial_kel.Pointer, range_kelPtr); if (_Result == IntPtr.Zero) { return(null); } return(new Pix(_Result)); }
// kernel.c (1191, 1) // makeGaussianKernelSep(halfheight, halfwidth, stdev, max, pkelx, pkely) as int // makeGaussianKernelSep(l_int32, l_int32, l_float32, l_float32, L_KERNEL **, L_KERNEL **) as l_ok /// <summary> /// (1) See makeGaussianKernel() for description of input parameters.<para/> /// /// (2) These kernels are constructed so that the result of both /// normalized and un-normalized convolution will be the same /// as when convolving with pixConvolve() using the full kernel.<para/> /// /// (3) The trick for the un-normalized convolution is to have the /// product of the two kernel elemets at (cx,cy) be equal to max, /// not max2. That's why the max for kely is 1.0. If instead /// we use sqrt(max) for both, the results are slightly less /// accurate, when compared to using the full kernel in /// makeGaussianKernel(). /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/makeGaussianKernelSep/*"/> /// <param name="halfheight">[in] - sx = 2 halfwidth + 1, etc</param> /// <param name="halfwidth">[in] - sx = 2 halfwidth + 1, etc</param> /// <param name="stdev">[in] - standard deviation</param> /// <param name="max">[in] - value at (cx,cy)</param> /// <param name="pkelx">[out] - x part of kernel</param> /// <param name="pkely">[out] - y part of kernel</param> /// <returns>0 if OK, 1 on error</returns> public static int makeGaussianKernelSep( int halfheight, int halfwidth, Single stdev, Single max, out L_Kernel pkelx, out L_Kernel pkely) { IntPtr pkelxPtr = IntPtr.Zero; IntPtr pkelyPtr = IntPtr.Zero; int _Result = Natives.makeGaussianKernelSep(halfheight, halfwidth, stdev, max, out pkelxPtr, out pkelyPtr); if (pkelxPtr == IntPtr.Zero) { pkelx = null; } else { pkelx = new L_Kernel(pkelxPtr); }; if (pkelyPtr == IntPtr.Zero) { pkely = null; } else { pkely = new L_Kernel(pkelyPtr); }; return(_Result); }
// kernel.c (322, 1) // kernelGetSum(kel, psum) as int // kernelGetSum(L_KERNEL *, l_float32 *) as l_ok /// <summary> /// kernelGetSum() /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/kernelGetSum/*"/> /// <param name="kel">[in] - kernel</param> /// <param name="psum">[out] - sum of all kernel values</param> /// <returns>0 if OK, 1 on error</returns> public static int kernelGetSum( L_Kernel kel, out Single psum) { if (kel == null) { throw new ArgumentNullException("kel cannot be Nothing"); } int _Result = Natives.kernelGetSum(kel.Pointer, out psum); return(_Result); }
// kernel.c (300, 1) // kernelSetOrigin(kel, cy, cx) as int // kernelSetOrigin(L_KERNEL *, l_int32, l_int32) as l_ok /// <summary> /// kernelSetOrigin() /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/kernelSetOrigin/*"/> /// <param name="kel">[in] - kernel</param> /// <param name="cy">[in] - </param> /// <param name="cx">[in] - </param> /// <returns>0 if OK 1 on error</returns> public static int kernelSetOrigin( L_Kernel kel, int cy, int cx) { if (kel == null) { throw new ArgumentNullException("kel cannot be Nothing"); } int _Result = Natives.kernelSetOrigin(kel.Pointer, cy, cx); return(_Result); }
// kernel.c (243, 1) // kernelSetElement(kel, row, col, val) as int // kernelSetElement(L_KERNEL *, l_int32, l_int32, l_float32) as l_ok /// <summary> /// kernelSetElement() /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/kernelSetElement/*"/> /// <param name="kel">[in] - kernel</param> /// <param name="row">[in] - </param> /// <param name="col">[in] - </param> /// <param name="val">[in] - </param> /// <returns>0 if OK 1 on error</returns> public static int kernelSetElement( L_Kernel kel, int row, int col, Single val) { if (kel == null) { throw new ArgumentNullException("kel cannot be Nothing"); } int _Result = Natives.kernelSetElement(kel.Pointer, row, col, val); return(_Result); }
// kernel.c (270, 1) // kernelGetParameters(kel, psy, psx, pcy, pcx) as int // kernelGetParameters(L_KERNEL *, l_int32 *, l_int32 *, l_int32 *, l_int32 *) as l_ok /// <summary> /// kernelGetParameters() /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/kernelGetParameters/*"/> /// <param name="kel">[in] - kernel</param> /// <param name="psy">[out][optional] - each can be null</param> /// <param name="psx">[out][optional] - each can be null</param> /// <param name="pcy">[out][optional] - each can be null</param> /// <param name="pcx">[out][optional] - each can be null</param> /// <returns>0 if OK, 1 on error</returns> public static int kernelGetParameters( L_Kernel kel, out int psy, out int psx, out int pcy, out int pcx) { if (kel == null) { throw new ArgumentNullException("kel cannot be Nothing"); } int _Result = Natives.kernelGetParameters(kel.Pointer, out psy, out psx, out pcy, out pcx); return(_Result); }
// kernel.c (175, 1) // kernelCopy(kels) as L_Kernel // kernelCopy(L_KERNEL *) as L_KERNEL * /// <summary> /// kernelCopy() /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/kernelCopy/*"/> /// <param name="kels">[in] - source kernel</param> /// <returns>keld copy of kels, or NULL on error</returns> public static L_Kernel kernelCopy( L_Kernel kels) { if (kels == null) { throw new ArgumentNullException("kels cannot be Nothing"); } IntPtr _Result = Natives.kernelCopy(kels.Pointer); if (_Result == IntPtr.Zero) { return(null); } return(new L_Kernel(_Result)); }
// kernel.c (627, 1) // kernelWriteStream(fp, kel) as int // kernelWriteStream(FILE *, L_KERNEL *) as l_ok /// <summary> /// kernelWriteStream() /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/kernelWriteStream/*"/> /// <param name="fp">[in] - file stream</param> /// <param name="kel">[in] - </param> /// <returns>0 if OK, 1 on error</returns> public static int kernelWriteStream( FILE fp, L_Kernel kel) { if (fp == null) { throw new ArgumentNullException("fp cannot be Nothing"); } if (kel == null) { throw new ArgumentNullException("kel cannot be Nothing"); } int _Result = Natives.kernelWriteStream(fp.Pointer, kel.Pointer); return(_Result); }
// kernel.c (598, 1) // kernelWrite(fname, kel) as int // kernelWrite(const char *, L_KERNEL *) as l_ok /// <summary> /// kernelWrite() /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/kernelWrite/*"/> /// <param name="fname">[in] - output file</param> /// <param name="kel">[in] - kernel</param> /// <returns>0 if OK, 1 on error</returns> public static int kernelWrite( String fname, L_Kernel kel) { if (fname == null) { throw new ArgumentNullException("fname cannot be Nothing"); } if (kel == null) { throw new ArgumentNullException("kel cannot be Nothing"); } int _Result = Natives.kernelWrite(fname, kel.Pointer); return(_Result); }
// kernel.c (410, 1) // kernelNormalize(kels, normsum) as L_Kernel // kernelNormalize(L_KERNEL *, l_float32) as L_KERNEL * /// <summary> /// (1) If the sum of kernel elements is close to 0, do not /// try to calculate the normalized kernel. Instead, /// return a copy of the input kernel, with a warning. /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/kernelNormalize/*"/> /// <param name="kels">[in] - source kel, to be normalized</param> /// <param name="normsum">[in] - desired sum of elements in keld</param> /// <returns>keld normalized version of kels, or NULL on error or if sum of elements is very close to 0)</returns> public static L_Kernel kernelNormalize( L_Kernel kels, Single normsum) { if (kels == null) { throw new ArgumentNullException("kels cannot be Nothing"); } IntPtr _Result = Natives.kernelNormalize(kels.Pointer, normsum); if (_Result == IntPtr.Zero) { return(null); } return(new L_Kernel(_Result)); }
// kernel.c (926, 1) // kernelDisplayInPix(kel, size, gthick) as Pix // kernelDisplayInPix(L_KERNEL *, l_int32, l_int32) as PIX * /// <summary> /// (1) This gives a visual representation of a kernel.<para/> /// /// (2) There are two modes of display: /// (a) Grid lines of minimum width 2, surrounding regions /// representing kernel elements of minimum size 17, /// with a "plus" mark at the kernel origin, or /// (b) A pix without grid lines and using 1 pixel per kernel element.<para/> /// /// (3) For both cases, the kernel absolute value is displayed, /// normalized such that the maximum absolute value is 255.<para/> /// /// (4) Large 2D separable kernels should be used for convolution /// with two 1D kernels. However, for the bilateral filter, /// the computation time is independent of the size of the /// 2D content kernel. /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/kernelDisplayInPix/*"/> /// <param name="kel">[in] - kernel</param> /// <param name="size">[in] - of grid interiors odd either 1 or a minimum size of 17 is enforced</param> /// <param name="gthick">[in] - grid thickness either 0 or a minimum size of 2 is enforced</param> /// <returns>pix display of kernel, or NULL on error</returns> public static Pix kernelDisplayInPix( L_Kernel kel, int size, int gthick) { if (kel == null) { throw new ArgumentNullException("kel cannot be Nothing"); } IntPtr _Result = Natives.kernelDisplayInPix(kel.Pointer, size, gthick); if (_Result == IntPtr.Zero) { return(null); } return(new Pix(_Result)); }
// kernel.c (144, 1) // kernelDestroy(pkel) as Object // kernelDestroy(L_KERNEL **) as void /// <summary> /// kernelDestroy() /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/kernelDestroy/*"/> /// <param name="pkel">[in,out] - to be nulled</param> public static void kernelDestroy( ref L_Kernel pkel) { IntPtr pkelPtr = IntPtr.Zero; if (pkel != null) { pkelPtr = pkel.Pointer; } Natives.kernelDestroy(ref pkelPtr); if (pkelPtr == IntPtr.Zero) { pkel = null; } else { pkel = new L_Kernel(pkelPtr); }; }