Main Page | Data Structures | File List | Data Fields | Globals

lsd.h

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 
00003   LSD - Line Segment Detector on digital images
00004 
00005   Copyright 2007-2010 rafael grompone von gioi (grompone@gmail.com)
00006 
00007   This program is free software: you can redistribute it and/or modify
00008   it under the terms of the GNU Affero General Public License as
00009   published by the Free Software Foundation, either version 3 of the
00010   License, or (at your option) any later version.
00011 
00012   This program is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015   GNU Affero General Public License for more details.
00016 
00017   You should have received a copy of the GNU Affero General Public License
00018   along with this program. If not, see <http://www.gnu.org/licenses/>.
00019 
00020   ----------------------------------------------------------------------------*/
00021 
00022 /*----------------------------------------------------------------------------*/
00023 /** @file lsd.h
00024     LSD module header
00025     @author rafael grompone von gioi (grompone@gmail.com)
00026  */
00027 /*----------------------------------------------------------------------------*/
00028 #ifndef LSD_HEADER
00029 #define LSD_HEADER
00030 
00031 
00032 /*----------------------------------------------------------------------------*/
00033 /*----------------------- 'list of n-tuple' data type ------------------------*/
00034 /*----------------------------------------------------------------------------*/
00035 /** 'list of n-tuple' data type
00036 
00037     The i component, of the n-tuple number j, of an n-tuple list 'ntl'
00038     is accessed with:
00039 
00040       ntl->values[ i + j * ntl->dim ]
00041 
00042     The dimension of the n-tuple (n) is:
00043 
00044       ntl->dim
00045 
00046     The number of number of n-tuples in the list is:
00047 
00048       ntl->size
00049 
00050     The maximum number of n-tuples that can be stored in the
00051     list with the allocated memory at a given time is given by:
00052 
00053       ntl->max_size
00054  */
00055 typedef struct ntuple_list_s
00056 {
00057   unsigned int size;
00058   unsigned int max_size;
00059   unsigned int dim;
00060   double * values;
00061 } * ntuple_list;
00062 
00063 void free_ntuple_list(ntuple_list in);
00064 ntuple_list new_ntuple_list(unsigned int dim);
00065 
00066 
00067 /*----------------------------------------------------------------------------*/
00068 /*----------------------------- Image Data Types -----------------------------*/
00069 /*----------------------------------------------------------------------------*/
00070 
00071 /*----------------------------------------------------------------------------*/
00072 /** char image data type
00073 
00074     The pixel value at (x,y) is accessed by:
00075 
00076       image->data[ x + y * image->xsize ]
00077 
00078     with x and y integer.
00079  */
00080 typedef struct image_char_s
00081 {
00082   unsigned char * data;
00083   unsigned int xsize,ysize;
00084 } * image_char;
00085 
00086 void free_image_char(image_char i);
00087 image_char new_image_char(unsigned int xsize, unsigned int ysize);
00088 image_char new_image_char_ini( unsigned int xsize, unsigned int ysize,
00089                                unsigned char fill_value );
00090 
00091 /*----------------------------------------------------------------------------*/
00092 /** int image data type
00093 
00094     The pixel value at (x,y) is accessed by:
00095 
00096       image->data[ x + y * image->xsize ]
00097 
00098     with x and y integer.
00099  */
00100 typedef struct image_int_s
00101 {
00102   int * data;
00103   unsigned int xsize,ysize;
00104 } * image_int;
00105 
00106 void free_image_int(image_int i);
00107 image_int new_image_int(unsigned int xsize, unsigned int ysize);
00108 image_int new_image_int_ini( unsigned int xsize, unsigned int ysize,
00109                              int fill_value );
00110 
00111 /*----------------------------------------------------------------------------*/
00112 /** double image data type
00113 
00114     The pixel value at (x,y) is accessed by:
00115 
00116       image->data[ x + y * image->xsize ]
00117 
00118     with x and y integer.
00119  */
00120 typedef struct image_double_s
00121 {
00122   double * data;
00123   unsigned int xsize,ysize;
00124 } * image_double;
00125 
00126 void free_image_double(image_double i);
00127 image_double new_image_double(unsigned int xsize, unsigned int ysize);
00128 image_double new_image_double_ini( unsigned int xsize, unsigned int ysize,
00129                                    double fill_value );
00130 
00131 
00132 /*----------------------------------------------------------------------------*/
00133 /*-------------------------- Line Segment Detector ---------------------------*/
00134 /*----------------------------------------------------------------------------*/
00135 
00136 /*----------------------------------------------------------------------------*/
00137 /* LSD Full Interface                                                         */
00138 /*----------------------------------------------------------------------------*/
00139 /** LSD Full Interface
00140 
00141     @param image       Input image.
00142 
00143     @param scale       When different than 1.0, LSD will scale the image by
00144                        Gaussian filtering.
00145                        Example: is scale=0.8, the input image will be subsampled
00146                        to 80% of its size, and then the line segment detector
00147                        will be applied.
00148                        Suggested value: 0.8
00149 
00150     @param sigma_scale When scale!=1.0, the sigma of the Gaussian filter is:
00151                        sigma = sigma_scale / scale,   if scale <  1.0
00152                        sigma = sigma_scale,           if scale >= 1.0
00153                        Suggested value: 0.6
00154 
00155     @param quant       Bound to the quantization error on the gradient norm.
00156                        Example: if gray level is quantized to integer steps,
00157                        the gradient (computed by finite differences) error
00158                        due to quantization will be bounded by 2.0, as the
00159                        worst case is when the error are 1 and -1, that
00160                        gives an error of 2.0.
00161                        Suggested value: 2.0
00162 
00163     @param ang_th      Gradient angle tolerance in the region growing
00164                        algorithm, in degrees.
00165                        Suggested value: 22.5
00166 
00167     @param eps         Detection threshold, -log10(NFA).
00168                        The bigger, the more strict the detector is,
00169                        and will result in less detections.
00170                        (Note that the 'minus sign' makes that this
00171                        behavior is opposite to the one of NFA.)
00172                        The value -log10(NFA) is equivalent but more
00173                        intuitive than NFA:
00174                        - -1.0 corresponds to 10 mean false alarms
00175                        -  0.0 corresponds to 1 mean false alarm
00176                        -  1.0 corresponds to 0.1 mean false alarms
00177                        -  2.0 corresponds to 0.01 mean false alarms
00178                        .
00179                        Suggested value: 0.0
00180 
00181     @param density_th  Minimal proportion of region points in a rectangle.
00182                        Suggested value: 0.7
00183 
00184     @param n_bins      Number of bins used in the pseudo-ordering of gradient
00185                        modulus.
00186                        Suggested value: 1024
00187 
00188     @param max_grad    Gradient modulus in the highest bin. For example,
00189                        for images with integer gray levels in [0,255],
00190                        the maximum possible gradient value is 255.0.
00191                        Suggested value: 255.0
00192 
00193     @param region      Optional output: an int image where the pixels used
00194                        in some line support region are marked. Unused pixels
00195                        have the value '0' while the used ones have the
00196                        number of the line segment, numbered 1,2,3,...
00197                        If desired, a non NULL pointer to an image_int should
00198                        be used. The resulting image has the size of the image
00199                        used for the processing, that is, the size of the input
00200                        image scaled by the given factor 'scale'.
00201                        Suggested value: NULL
00202 
00203     @return            A 5-tuple list, where each 5-tuple corresponds to a
00204                        detected line segment. The five values are:
00205                        - x1,y1,x2,y2,width
00206                        .
00207                        for a line segment from (x1,y1) to (x2,y2) and
00208                        a width 'width'.
00209  */
00210 ntuple_list LineSegmentDetection( image_double image, double scale,
00211                                   double sigma_scale, double quant,
00212                                   double ang_th, double eps, double density_th,
00213                                   int n_bins, double max_grad,
00214                                   image_int * region );
00215 
00216 /*----------------------------------------------------------------------------*/
00217 /* LSD Simple Interface with Scale                                            */
00218 /*----------------------------------------------------------------------------*/
00219 /** LSD Simple Interface with Scale
00220 
00221     @param image Input image.
00222 
00223     @param scale When different than 1.0, LSD will scale the image by
00224                  Gaussian filtering.
00225                  Example: is scale=0.8, the input image will be subsampled
00226                  to 80% of its size, and then the line segment detector
00227                  will be applied.
00228                  Suggested value: 0.8
00229 
00230     @return a 5-tuple list of detected line segments.
00231  */
00232 ntuple_list lsd_scale(image_double image, double scale);
00233 
00234 /*----------------------------------------------------------------------------*/
00235 /* LSD Simple Interface                                                       */
00236 /*----------------------------------------------------------------------------*/
00237 /** LSD Simple Interface
00238 
00239     @param image Input image.
00240 
00241     @return a 5-tuple list of detected line segments.
00242  */
00243 ntuple_list lsd(image_double image);
00244 
00245 #endif /* !LSD_HEADER */
00246 /*----------------------------------------------------------------------------*/

Generated on Fri Dec 3 10:18:18 2010 for LSD by doxygen 1.3.4