Lens distortion correction division model 1p
 All Classes Files Functions Variables
utilities.h
1 /*
2  Copyright (c) 2010-2013, AMI RESEARCH GROUP <lalvarez@dis.ulpgc.es>
3  License : CC Creative Commons "Attribution-NonCommercial-ShareAlike"
4  see http://creativecommons.org/licenses/by-nc-sa/3.0/es/deed.en
5  */
6 
7 #ifndef UTILITIES_H
8 #define UTILITIES_H
9 
10 #include <vector>
11 #include "../ami_image/image.h"
12 #include "../ami_image_draw/image_draw.h"
13 #include "../ami_primitives/image_primitives.h"
14 #include <fstream>
15 
16 /* *
17  * \def ami_free1d(direccion)
18  * \brief Frees the memory of the array created by ami_calloc1d o ami_malloc1d.
19  * \author Luis Alvarez
20  */
21 #define ami_free1d(direccion) { if (direccion != NULL){\
22  free(direccion);direccion=NULL;}}
23 
24 /* *
25  * \def ami_free2d(direccion)
26  * \brief Frees the memory of the matrix created by ami_calloc2d or ami_malloc2d.
27  * \author Luis Alvarez
28  */
29 #define ami_free2d(direccion) { if (direccion != NULL){\
30  ami_free1d(direccion[0]); free(direccion); direccion = NULL;}}
31 
32 /* *
33  * \def ami_free3d(direccion)
34  * \brief Frees the memory of the matrix created by ami_calloc3d o ami_malloc3d.
35  * \author Luis Alvarez
36  */
37 #define ami_free3d(direccion) {if (direccion != NULL){\
38  ami_free2d(direccion[0]); free(direccion); direccion=NULL;}}
39 
40 /* *
41  * \def ami_calloc2d(direccion,tipo,height,width) \anchor <calloc2d>
42  * \brief Get memory for array direccion with type X, width and height certain.
43  Initialize to 0 the adress positions
44  * \author Luis Alvarez
45  */
46 #define ami_calloc2d(direccion,tipo,height,width) {int ml,mk; \
47  if ( width > 0 && height > 0){\
48  direccion=(tipo **) malloc(sizeof(tipo *)*(height)); \
49  if (direccion == NULL){\
50  printf("\nMemorila insuficiente.\n"); \
51  int val = scanf("%d",&ml); if(val==EOF) printf("Read error\n");}\
52  direccion[0]=(tipo *)malloc(sizeof(tipo)*(width)*(height)); \
53  if (direccion[0] == NULL){free(direccion); direccion = NULL;\
54  printf("\nMemoria insuficiente.\n"); \
55  int val = scanf("%d",&ml); if(val==EOF) printf("Read error\n");}\
56  for(ml=0;ml<(height);ml++) direccion[ml]=&(direccion[0][ml*(width)]);\
57  for(ml=0;ml<height;ml++) for(mk=0;mk<width;mk++) direccion[ml][mk]=0;\
58  }\
59  else direccion = NULL;}
60 
61 /* *
62  * \def ami_calloc3d(direccion,tipo,depth,height,width)
63  * \brief Get memory in three-dimensional variable direccion with the width and
64  height given. Initialize to 0 the adress positions
65  * \author Luis Alvarez
66  */
67 #define ami_calloc3d(direccion,tipo,depth,height,width) {int ml,mk,mu; \
68  if ( depth > 0 && width > 0 && height > 0){\
69  direccion=(tipo ***) malloc(sizeof(tipo **)*(depth)); \
70  if (direccion == NULL){\
71  printf("\nMemoria insuficiente.\n"); \
72  int val = scanf("%d",&ml); if(val==EOF) printf("Read error\n");}\
73  direccion[0]=(tipo **)malloc(sizeof(tipo *)*(depth)*(height)); \
74  if (direccion[0] == NULL){free(direccion); direccion = NULL;\
75  printf("\nMemoria insuficiente.\n"); \
76  int val = scanf("%d",&ml); if(val==EOF) printf("Read error\n");}\
77  direccion[0][0]=(tipo *)malloc(sizeof(tipo)*(depth)*(height)*(width));\
78  if (direccion[0][0] == NULL){free(direccion[0]); free(direccion);\
79  direccion = NULL; printf("\nMemoria insuficiente.\n");\
80  int val = scanf("%d",&ml); if(val==EOF) printf("Read error\n");}\
81  for(mu=0;mu<depth;mu++){ \
82  for(ml=0;ml<(height);ml++) \
83  direccion[0][ml+mu*(height)]=&(direccion[0][0][ml*(width)+\
84  mu*(width)*(height)]); \
85  direccion[mu]=&(direccion[0][mu*(height)]);}\
86  for(mu=0;mu<depth;mu++)\
87  for(ml=0;ml<height;ml++)\
88  for(mk=0;mk<width;mk++) direccion[mu][ml][mk]=0; \
89  }\
90  else direccion = NULL;}
91 
97 #ifdef _AMI_TIF_H_
98 #undef ami_malloc1d
99 #endif
100 #define ami_malloc1d(direccion,tipo,size) {\
101  if (size > 0){\
102  direccion=(tipo *) malloc(sizeof(tipo)*(size)); \
103  if (direccion == NULL)\
104  {int ml; printf("\nMemoria insuficiente.\n"); \
105  int val = scanf("%d",&ml); if(val==EOF) printf("Read error\n");}}\
106  else direccion = NULL;}
107 
108 std::vector < std::vector <unsigned int> >
109  boundary_neighborhood_9n(const unsigned int width, const unsigned int height);
110 
111 std::vector < std::vector <unsigned int> >
112  boundary_neighborhood_5n(const unsigned int width, const unsigned int height);
113 
121 void drawHoughLines(image_primitives ip ,
124 
131 void invert(ami::image<unsigned char> &input ,
132  ami::image<unsigned char> &output);
134 
140 void print_function_syntax_lens_distortion_correction_division_model_1p();
141 
147 int check_params_lens_distortion_correction_division_model_1p(char *argv[]);
148 
154 int count_points(image_primitives ip);
155 
161 void manage_failure(char *argv[]);
162 
163 #endif
class to store the image primitives (points, lines, ellipses and ditortion model) ...
Definition: image_primitives.h:35
Class to store multiChannel images and basic methods.
Definition: image.h:65