00001 /** \file 00002 * \brief Image Processing - Global Operations 00003 * 00004 * See Copyright Notice in im_lib.h 00005 */ 00006 00007 #ifndef __IM_PROCESS_GLO_H 00008 #define __IM_PROCESS_GLO_H 00009 00010 #include "im_image.h" 00011 00012 #if defined(__cplusplus) 00013 extern "C" { 00014 #endif 00015 00016 00017 00018 /** \defgroup transform Other Domain Transform Operations 00019 * \par 00020 * Hough, Distance. 00021 * 00022 * See \ref im_process_glo.h 00023 * \ingroup process */ 00024 00025 /** Hough Lines Transform. \n 00026 * It will detect white lines in a black background. So the source image must be a IM_BINARY image 00027 * with the white lines of interest enhanced. The better the threshold with the white lines the better 00028 * the line detection. \n 00029 * The destiny image must have IM_GRAY, IM_INT, hg_width=180, hg_height=2*rmax+1, 00030 * where rmax is the image diagonal/2 (rmax = srqrt(width*width + height*height)). \n 00031 * The hough transform defines "cos(theta) * X + sin(theta) * Y = rho" and the parameters are in the interval: \n 00032 * theta = "0 .. 179", rho = "-hg_height/2 .. hg_height/2" .\n 00033 * Where rho is the perpendicular distance from the center of the image and theta the angle with the normal. 00034 * So do not confuse theta with the line angle, they are perpendicular. \n 00035 * Returns zero if the counter aborted. \n 00036 * Inspired from ideas in XITE, Copyright 1991, Blab, UiO \n 00037 * http://www.ifi.uio.no/~blab/Software/Xite/ 00038 * 00039 * \verbatim im.ProcessHoughLines(src_image: imImage, dst_image: imImage) -> counter: boolean [in Lua 5] \endverbatim 00040 * \verbatim im.ProcessHoughLinesNew(image: imImage) -> counter: boolean, new_image: imImage [in Lua 5] \endverbatim 00041 * \ingroup transform */ 00042 int imProcessHoughLines(const imImage* src_image, imImage* dst_image); 00043 00044 /** Draw detected hough lines. \n 00045 * The source image must be IM_GRAY and IM_BYTE. The destiny image can be a clone of the source image or 00046 * it can be the source image for in place processing. \n 00047 * If the hough transform is not NULL, then the hough points are filtered to include only lines 00048 * that are significally different from each other. \n 00049 * The hough image is the hough transform image, but it is optional and can be NULL. 00050 * If not NULL then it will be used to filter lines that are very similar. \n 00051 * The hough points image is a hough transform image that was thresholded to a IM_BINARY image, 00052 * usually using a Local Max threshold operation (see \ref imProcessLocalMaxThreshold). Again the better the threshold the better the results. \n 00053 * The destiny image will be set to IM_MAP, and the detected lines will be drawn using a red color. \n 00054 * Returns the number of detected lines. 00055 * 00056 * \verbatim im.ProcessHoughLinesDraw(src_image: imImage, hough: imImage, hough_points: imImage, dst_image: imImage) -> lines: number [in Lua 5] \endverbatim 00057 * \verbatim im.ProcessHoughLinesDrawNew(image: imImage, hough: imImage, hough_points: imImage) -> lines: number, new_image: imImage [in Lua 5] \endverbatim 00058 * \ingroup transform */ 00059 int imProcessHoughLinesDraw(const imImage* src_image, const imImage* hough, const imImage* hough_points, imImage* dst_image); 00060 00061 /** Calculates the Cross Correlation in the frequency domain. \n 00062 * CrossCorr(a,b) = IFFT(Conj(FFT(a))*FFT(b)) \n 00063 * Images must be of the same size and only destiny image must be of type complex. 00064 * 00065 * \verbatim im.ProcessCrossCorrelation(src_image1: imImage, src_image2: imImage, dst_image: imImage) [in Lua 5] \endverbatim 00066 * \verbatim im.ProcessCrossCorrelationNew(image1: imImage, image2: imImage) -> new_image: imImage [in Lua 5] \endverbatim 00067 * \ingroup transform */ 00068 void imProcessCrossCorrelation(const imImage* src_image1, const imImage* src_image2, imImage* dst_image); 00069 00070 /** Calculates the Auto Correlation in the frequency domain. \n 00071 * Uses the cross correlation. 00072 * Images must be of the same size and only destiny image must be of type complex. 00073 * 00074 * \verbatim im.ProcessAutoCorrelation(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim 00075 * \verbatim im.ProcessAutoCorrelationNew(image: imImage) -> new_image: imImage [in Lua 5] \endverbatim 00076 * \ingroup transform */ 00077 void imProcessAutoCorrelation(const imImage* src_image, imImage* dst_image); 00078 00079 /** Calculates the Distance Transform of a binary image 00080 * using an aproximation of the euclidian distance.\n 00081 * Each white pixel in the binary image is 00082 * assigned a value equal to its distance from the nearest 00083 * black pixel. \n 00084 * Uses a two-pass algorithm incrementally calculating the distance. \n 00085 * Source image must be IM_BINARY, destiny must be IM_FLOAT. 00086 * 00087 * \verbatim im.ProcessDistanceTransform(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim 00088 * \verbatim im.ProcessDistanceTransformNew(image: imImage) -> new_image: imImage [in Lua 5] \endverbatim 00089 * \ingroup transform */ 00090 void imProcessDistanceTransform(const imImage* src_image, imImage* dst_image); 00091 00092 /** Marks all the regional maximum of the distance transform. \n 00093 * source is IMGRAY/IM_FLOAT destiny in IM_BINARY. \n 00094 * We consider maximum all connected pixel values that have smaller pixel values around it. 00095 * 00096 * \verbatim im.ProcessRegionalMaximum(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim 00097 * \verbatim im.ProcessRegionalMaximumNew(image: imImage) -> new_image: imImage [in Lua 5] \endverbatim 00098 * \ingroup transform */ 00099 void imProcessRegionalMaximum(const imImage* src_image, imImage* dst_image); 00100 00101 00102 00103 /** \defgroup fourier Fourier Transform Operations 00104 * \par 00105 * All Fourier transforms use FFTW library. \n 00106 * The pre-compiled binaries for FFTW version 2.1.5 includes all the necessary files. 00107 * The pre-compiled binaries for FFTW version 3.x depends on an external library, not provided. 00108 * To build the code that uses FFTW version 3 you must define USE_FFTW3. 00109 * \par 00110 * FFTW Copyright Matteo Frigo, Steven G. Johnson and the MIT. \n 00111 * http://www.fftw.org \n 00112 * See "fftw.h" 00113 * \par 00114 * Must link with "im_fftw" library. \n 00115 * \par 00116 * IMPORTANT: The FFTW lib has a GPL license. The license of the "im_fftw" library is automatically the GPL. 00117 * So you cannot use it for commercial applications without contacting the authors. 00118 * \par 00119 * See \ref im_process_glo.h 00120 * \ingroup process */ 00121 00122 /** Forward FFT. \n 00123 * The result has its lowest frequency at the center of the image. \n 00124 * This is an unnormalized fft. \n 00125 * Images must be of the same size. Destiny image must be of type complex. 00126 * 00127 * \verbatim im.ProcessFFT(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim 00128 * \verbatim im.ProcessFFTNew(image: imImage) -> new_image: imImage [in Lua 5] \endverbatim 00129 * \ingroup fourier */ 00130 void imProcessFFT(const imImage* src_image, imImage* dst_image); 00131 00132 /** Inverse FFT. \n 00133 * The image has its lowest frequency restored to the origin before the transform. \n 00134 * The result is normalized by (width*height). \n 00135 * Images must be of the same size and both must be of type complex. 00136 * 00137 * \verbatim im.ProcessIFFT(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim 00138 * \verbatim im.ProcessIFFTNew(image: imImage) -> new_image: imImage [in Lua 5] \endverbatim 00139 * \ingroup fourier */ 00140 void imProcessIFFT(const imImage* src_image, imImage* dst_image); 00141 00142 /** Raw in-place FFT (forward or inverse). \n 00143 * The lowest frequency can be centered after forward, or 00144 * can be restored to the origin before inverse. \n 00145 * The result can be normalized after the transform by sqrt(w*h) [1] or by (w*h) [2], 00146 * or left unnormalized [0]. \n 00147 * Images must be of the same size and both must be of type complex. 00148 * 00149 * \verbatim im.ProcessFFTraw(image: imImage, inverse: number, center: number, normalize: number) [in Lua 5] \endverbatim 00150 * \ingroup fourier */ 00151 void imProcessFFTraw(imImage* image, int inverse, int center, int normalize); 00152 00153 /** Auxiliary function for the raw FFT. \n 00154 * This is the function used internally to change the lowest frequency position in the image. \n 00155 * If the image size has even dimensions the flag "center2origin" is useless. But if it is odd, 00156 * you must specify if its from center to origin (usually used before inverse) or 00157 * from origin to center (usually used after forward). \n 00158 * Notice that this function is used for images in the the frequency domain. \n 00159 * Image type must be complex. 00160 * 00161 * \verbatim im.ProcessSwapQuadrants(image: imImage, center2origin: number) [in Lua 5] \endverbatim 00162 * \ingroup fourier */ 00163 void imProcessSwapQuadrants(imImage* image, int center2origin); 00164 00165 00166 #if defined(__cplusplus) 00167 } 00168 #endif 00169 00170 #endif