11 "Reads an image, computes HT, de-computes it \n\n";
29 int main(
int argc,
const char**argv) {
30 pgm_init(&argc, argv);
40 p.hsmp.linear_cell_size = 1;
42 options_int(ops,
"debug", &
p.debug, 0,
"Shows debug information");
54 sm_debug(
"Computing HT for image %s.\n",
p.file_input1);
60 if(!strcmp(
p.file_input2,
"")) {
61 p.file_input2 =
p.file_input1;
62 p.hsmp.debug_true_x_valid = 1;
63 p.hsmp.debug_true_x[0] = 20;
64 p.hsmp.debug_true_x[1] = 50;
65 p.hsmp.debug_true_x[2] = 0;
67 p.hsmp.debug_true_x_valid = 0;
71 sm_debug(
"Computing HT for image %s.\n",
p.file_input2);
72 double *base =
p.hsmp.debug_true_x_valid ?
p.hsmp.debug_true_x : 0;
83 char filename_ht1[256]; sprintf(filename_ht1,
"%s_ht1.pgm",
p.prefix);
84 char filename_ht2[256]; sprintf(filename_ht2,
"%s_ht2.pgm",
p.prefix);
85 char filename_hs1[256]; sprintf(filename_hs1,
"%s_hs1.pgm",
p.prefix);
86 char filename_hs2[256]; sprintf(filename_hs2,
"%s_hs2.pgm",
p.prefix);
87 char filename_hs_xc[256]; sprintf(filename_hs_xc,
"%s_hs_xc.pgm",
p.prefix);
95 if(!file_ht1 | !file_ht2)
return -4;
96 if(!file_hs1 | !file_hs2)
return -4;
97 if(!file_hs_xc)
return -5;
111 gray ** grays = pgm_allocarray(cols, rows);
116 maxvalue = GSL_MAX(maxvalue, f[i]);
117 if(maxvalue==0)maxvalue=1;
121 for(
int y=0;y<rows;y++)
122 for(
int x=0;
x<cols;
x++)
125 for(
int x=0;
x<cols;
x++) {
126 int y = round((rows-2)*f[
x]/maxvalue);
129 grays[y][
x] = maxgray;
132 pgm_writepgm(out,grays,cols,rows,maxgray,0);
134 pgm_freearray(grays,rows);
141 gray ** grays = pgm_allocarray(cols, rows);
146 maxvalue = GSL_MAX(maxvalue, b->
ht[t][r]);
152 grays[t][r] = (gray) ceil(b->
ht[t][r] * (maxgray-1) / maxvalue);
154 pgm_writepgm(out,grays,cols,rows,maxgray,0);
156 pgm_freearray(grays,rows);
160 int cols, rows; gray
max;
161 gray **image = pgm_readpgm(in, &cols, &rows, &max);
162 if(!image) {
return 0; }
164 p->
max_norm = 1.1 * hypot(cols/2.0, rows/2.0);
172 for (
int v=0; v<rows; v++)
173 for (
int u=0; u<cols; u++) {
174 double x = u - cols/2;
175 double y = v - rows/2;
176 if(image[v][u]==0)
continue;
180 sm_debug(
"Used %d points.\n", npoints);
183 pgm_freearray(image, rows);
void options_banner(const char *message)
void hsm_compute_ht_base(hsm_buffer b, const double base_pose[3])
void write_function_on_image(int n, const double *f, int rows, FILE *out)
hsm_buffer create_ht_for_image(struct hsm_params *p, FILE *in, const double base[3])
void hsm_compute_ht_point(hsm_buffer b, double x0, double y0, double weight)
void hsm_compute_spectrum(hsm_buffer b)
hsm_buffer hsm_buffer_alloc(struct hsm_params *p)
FILE * open_file_for_writing(const char *filename)
int main(int argc, const char **argv)
struct option * options_allocate(int n)
void hsm_match(struct hsm_params *p, hsm_buffer b1, hsm_buffer b2)
void options_int(struct option *, const char *name, int *p, int def_value, const char *desc)
void hsm_add_options(struct option *ops, struct hsm_params *p)
void write_ht_on_image(hsm_buffer b, FILE *out)
void sm_debug_write(int flag)
FILE * open_file_for_reading(const char *filename)
void options_print_help(struct option *options, FILE *f)
void sm_debug(const char *msg,...)
void options_string(struct option *, const char *name, const char **p, const char *def_balue, const char *desc)
int options_parse_args(struct option *ops, int argc, const char *argv[])