~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/vision/hough/hough2.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 
  2 /* Anthony Ashbrook 22/6/93 */
  3 /* Modified: Anthony Ashbrook. October 1993 */
  4 
  5 #include <tina/sys.h>
  6 #include <tina/sysfuncs.h>
  7 #include <tina/math.h>
  8 #include <tina/mathfuncs.h>
  9 #include <tina/vision.h>
 10 #include <tina/visionfuncs.h>
 11 #include <tina/line2.h>
 12 #include <tina/image.h>
 13 #include <tina/houghfuncs.h>
 14 
 15 #include <stdio.h>
 16 #include <stdlib.h>
 17 #include <math.h>
 18 
 19 /*#include "extra.h"
 20 */
 21 
 22 /* ---------- Functions ---------- */
 23 
 24 Imrect *hough2_alloc(double min_x, double min_y, double max_x, double max_y, double binsize_x, double binsize_y, Vartype type)
 25 {
 26     Imrect       *hough2;
 27     Imregion      roi;
 28     Hough2_region *hough2_roi;
 29 
 30 /* Define the physical size of the hough space array. Need to use the 'ceil' 
 31    function because the hough space may not be exactly divisable by the bin
 32    size. */
 33 
 34     roi.lx = 0;
 35     roi.ux = (int)ceil((max_x-min_x)/binsize_x);
 36     roi.ly = 0;
 37     roi.uy = (int)ceil((max_y-min_y)/binsize_y);
 38   
 39     hough2 = im_alloc(roi.uy, roi.ux, &roi, type);
 40 
 41 /* Add the logical hough coords to the props list */
 42 
 43     hough2_roi = ralloc(sizeof(Hough2_region));
 44 
 45     if (hough2_roi!=NULL)
 46     {
 47       hough2_roi->min_x = min_x;
 48       hough2_roi->min_y = min_y;
 49       hough2_roi->max_x = max_x;
 50       hough2_roi->max_y = max_y;
 51       hough2_roi->binsize_x = binsize_x;
 52       hough2_roi->binsize_y = binsize_y;
 53 
 54       hough2->props = proplist_add(hough2->props, hough2_roi, HOUGH2_ROI_TYPE,  
 55                                                                         rfree);
 56     }
 57 
 58     return (hough2);
 59 }
 60 
 61 /* ---------- */
 62 
 63 /* This function extends the passed line and then clips it to the logical 
 64    coords of the hough space. If the extended line doesn't pass through the
 65    hough space the passed line is unaltered. The function returns TRUE if 
 66    line has been altered otherwise it returns FALSE */
 67 
 68 int hough2_extend_line(Line2 *line, Imrect *hough2)
 69 {
 70     double         min_x, min_y, max_x, max_y; 
 71     Vec2           start, end;
 72     double         bottom_edge_intersect; 
 73     double         top_edge_intersect;     
 74     double         left_edge_intersect;   
 75     double         right_edge_intersect;
 76     double         m, c;
 77     Hough2_region *hough2_roi=NULL;
 78     Line2         *new_line;
 79 
 80 /* Extract the logical coords of the hough space */
 81 
 82     hough2_roi = prop_get(hough2->props, HOUGH2_ROI_TYPE);
 83 
 84     if (hough2_roi==NULL)
 85     {
 86         format("Error: hough2_roi not defined.\n");
 87         return FALSE;
 88     }
 89 
 90     min_x = hough2_roi->min_x;
 91     min_y = hough2_roi->min_y;
 92     max_x = hough2_roi->max_x;
 93     max_y = hough2_roi->max_y;
 94  
 95     if (vec2_x(line->v)==0.0) /* Special case for vertical lines */
 96     {
 97         if ((vec2_x(line->p1)>=min_x) &&
 98             (vec2_x(line->p1)<=max_x))
 99             {           
100                 vec2_x(start) = vec2_x(line->p1);
101                 vec2_y(start) = (float)min_y;
102                 vec2_x(end)   = vec2_x(line->p1);
103                 vec2_y(end)   = (float)max_y;
104                 new_line = line2_make(start, end, (int) NULL);
105                 *line = *new_line;
106                 line2_free(new_line);
107                 return TRUE;
108             }
109             else
110             {
111                 return FALSE;
112             }
113     }/*endif vertical*/
114 
115     if (vec2_y(line->v)==0.0) /* Special case for horizontal lines */
116     {
117         if ((vec2_y(line->p1)>=min_y) &&
118             (vec2_y(line->p1)<=max_y))
119             {           
120                 vec2_x(start) = (float)min_x;
121                 vec2_y(start) = vec2_y(line->p1);
122                 vec2_x(end)   = (float)max_x;
123                 vec2_y(end)   = vec2_y(line->p1);
124                 new_line = line2_make(start, end, (int) NULL);
125                 *line = *new_line;
126                 line2_free(new_line);
127                 return TRUE;
128             }
129             else
130             {
131                 return FALSE;
132             }
133     }/*endif horizontal*/
134 
135 /* The line is neither horizontal or vertical - determine where it intersects
136    the lines which define the hough space. */
137 
138     m = vec2_y(line->v)/vec2_x(line->v);
139     c = vec2_y(line->p1)-m*vec2_x(line->p1);
140 
141     left_edge_intersect   = m*min_x+c;
142     right_edge_intersect  = m*max_x+c;
143     bottom_edge_intersect = (min_y-c)/m;
144     top_edge_intersect    = (max_y-c)/m;
145 
146 /* Return if this line doesn't cross the hough space */
147 
148     if ((left_edge_intersect<min_y) &&
149         (right_edge_intersect<min_y)
150                               ||
151         (left_edge_intersect>max_y) &&
152         (right_edge_intersect>max_y)
153                               ||
154         (bottom_edge_intersect<min_x) &&
155         (top_edge_intersect<min_x)
156                               ||
157         (bottom_edge_intersect>max_x) &&
158         (top_edge_intersect>max_x))         return FALSE;
159   
160       
161 /* Initially assume that the left and right intersects are the line endpoints */
162 
163     vec2_x(start) = (float)min_x;
164     vec2_y(start) = (float)left_edge_intersect;
165     vec2_x(end)   = (float)max_x;
166     vec2_y(end)   = (float)right_edge_intersect;
167 
168 /* Only change these assumptions if necessary */
169 
170     if (left_edge_intersect<min_y)
171     {
172         vec2_x(start) = (float)bottom_edge_intersect;
173         vec2_y(start) = (float)min_y;
174     }
175 
176     if (left_edge_intersect>max_y)
177     {
178         vec2_x(start) = (float)top_edge_intersect;
179         vec2_y(start) = (float)max_y;
180     }
181 
182 
183     if (right_edge_intersect<min_y)
184     {
185         vec2_x(end) = (float)bottom_edge_intersect;
186         vec2_y(end) = (float)min_y;
187     }
188 
189     if (right_edge_intersect>max_y)
190     {
191         vec2_x(end) = (float)top_edge_intersect;
192         vec2_y(end) = (float)max_y;
193     }
194 
195 /* Now change the old line to the new line */
196 
197     new_line = line2_make(start, end, (int) NULL);
198     *line = *new_line;
199     line2_free(new_line);
200     return TRUE;
201 }
202 
203 /* ---------- */
204 
205 void hough2_plot_line(Line2 *line, Imrect *hough2, double weight)
206 {
207     int            x_diff, y_diff;
208     double         temp, min_x, min_y, max_x, max_y, binsize_x, binsize_y;
209     double            x0, y0, x1, y1;
210     Hough2_region *hough2_roi;
211 
212         /* (1) Transform the line coords from logical coords
213                to hough space array indices.
214            (2) Swap start and end points such that x0 is 
215                always less than x1.
216            (3) The problem is now limited to 4 cases:
217                    (i)   y' positive and greater than x'
218                    (ii)  y' positive and less than x'
219                    (iii) y' negative and abs less than x'
220                    (iv)  y' negative and abs greater than x'
221                Test for case and execute appropriately.  */
222 
223 /* Extract the logical coords of the hough space and the binsizes */
224 
225     hough2_roi = prop_get(hough2->props, HOUGH2_ROI_TYPE);
226 
227     if (hough2_roi==NULL)
228     {
229         format("Error: hough2 roi not set.\n");
230         return;
231     }
232 
233     min_x = hough2_roi->min_x;
234     min_y = hough2_roi->min_y;
235     max_x = hough2_roi->max_x;
236     max_y = hough2_roi->max_y;
237     binsize_x = hough2_roi->binsize_x;
238     binsize_y = hough2_roi->binsize_y;
239 
240 /* The array indices can now be determined */
241 
242     x0 = (vec2_x(line->p1)-min_x)/binsize_x;
243     y0 = (vec2_y(line->p1)-min_y)/binsize_y;
244     x1 = (vec2_x(line->p2)-min_x)/binsize_x;
245     y1 = (vec2_y(line->p2)-min_y)/binsize_y;
246 
247 /* Swap start and end points if necessary */
248 
249     if (x0>x1)
250     {
251         temp = x0;
252         x0 = x1;
253         x1 = temp;
254 
255         temp = y0;
256         y0 = y1;
257         y1 = y0;
258     }
259 
260 /* Determine which case applies */
261 
262     x_diff = (int)(x1-x0);
263     y_diff = (int)(y1-y0);
264 
265     if (y_diff>=0) /* +ve gradient */
266     {
267         if (y_diff>=x_diff)
268             y_based_plot(y0, y1, x0, (double)x_diff/(double)y_diff, 
269                                                             hough2, weight);
270         else
271             x_based_plot(x0, x1, y0, (double)y_diff/(double)x_diff, 
272                                                             hough2, weight);
273     }
274     else  /* -ve gradient */
275     {
276         if ((-1*y_diff)>=x_diff)
277             y_based_plot(y1, y0, x1, (double)x_diff/(double)y_diff, 
278                                                             hough2, weight);
279         else
280             x_based_plot(x0, x1, y0, (double)y_diff/(double)x_diff, 
281                                                             hough2, weight);
282     }
283 }
284 
285 /* ---------- */
286 
287 void y_based_plot(double y0, double y1, double x0, double grad, Imrect *hough2, double weight)
288 {
289     int       y;
290     double    x;
291     Vartype   vtype;
292     int       lx, ly, ux, uy;  /* max and min image array indices */
293     double    gl;
294 
295     vtype =   hough2->vtype;
296 
297     lx = hough2->region->lx;
298     ly = hough2->region->ly;
299     ux = hough2->region->ux;
300     uy = hough2->region->uy;
301 
302     x = x0 + grad *(y0+0.5-tina_rint(y0));
303 
304     if (y0<ly) y0 = ly;
305     if (y1>uy) y1 = uy;
306 
307     for(y=tina_rint(y0);y<y1;y++)
308     { 
309         if ( (tina_rint(x-1)>=lx) && (tina_rint(x+1)<ux) )
310         {
311             IM_PIX_GET(hough2,y, tina_rint(x-1), gl);
312             IM_PIX_SET(hough2,y, tina_rint(x-1), gl+weight);
313             IM_PIX_GET(hough2,y, tina_rint(x), gl);
314             IM_PIX_SET(hough2,y, tina_rint(x), gl+weight);
315             IM_PIX_GET(hough2,y, tina_rint(x+1), gl);
316             IM_PIX_SET(hough2,y, tina_rint(x+1), gl+weight);
317         }
318 
319         x+=grad;
320     }
321 }
322 
323 /* ---------- */
324 
325 void x_based_plot(double x0, double x1, double y0, double grad, Imrect *hough2, double weight)
326 {
327     int    x;
328     double y;
329     double gl;
330     Vartype   vtype;
331     int       lx, ly, ux, uy;  /* max and min image array indices */
332 
333     vtype =   hough2->vtype;
334 
335     lx = hough2->region->lx;
336     ly = hough2->region->ly;
337     ux = hough2->region->ux;
338     uy = hough2->region->uy;
339 
340     y = y0 + grad *(x0+0.5-tina_rint(x0));
341 
342     if (x0<lx) x0 = lx;
343     if (x1>ux) x1 = ux;
344 
345     for(x=tina_rint(x0);x<x1;x++)
346     {
347       if ( (tina_rint(y-1)>=ly) && (tina_rint(y+1)<uy) )
348       {
349           IM_PIX_GET(hough2,tina_rint(y-1),x,gl);
350           IM_PIX_SET(hough2,tina_rint(y-1),x,gl+weight);
351           IM_PIX_GET(hough2,tina_rint(y),x,gl);
352           IM_PIX_SET(hough2,tina_rint(y),x,gl+weight);
353           IM_PIX_GET(hough2,tina_rint(y+1),x,gl);
354           IM_PIX_SET(hough2,tina_rint(y+1),x,gl+weight);
355       }
356       y+=grad;    
357     }
358 }
359 
360 /* ---------- */
361 
362 double im_get_quadcovar(Imrect * image, double x, double y, float *px, float *py
363 , Mat2 *C)
364 {
365     Imregion       *region = image->region;
366     double           pixval[3][3];
367     double           a, b, c, d, e, f;
368     double          inter;
369     double           temp;
370     short           i, j, n, m;
371     double           xs, ys;
372     double det;
373 
374     i = tina_int(x - 1);
375     j = tina_int(y - 1);
376 
377     if (j < region->ly + 1 || j > region->uy - 1
378         || i < region->lx + 1 || i > region->ux - 1)
379         return (0);
380 
381     for (n = 0; n < 3; n++)
382     {
383         for (m = 0; m < 3; m++)
384         {
385             pixval[n][m] = im_get_pixf(image, j + n, i + m);
386         }
387     }
388 
389     a = pixval[1][1];
390     b = (pixval[0][2] - pixval[0][0]
391         + pixval[1][2] - pixval[1][0]
392         + pixval[2][2] - pixval[2][0]) / 6.0;
393     c = (pixval[2][0] - pixval[0][0]
394         + pixval[2][1] - pixval[0][1]
395         + pixval[2][2] - pixval[0][2]) / 6.0;
396     d = (pixval[0][0] - 2.0 * pixval[0][1] + pixval[0][2]
397         + 3.0 * pixval[1][0] - 6.0 * pixval[1][1] + 3.0 * pixval[1][2]
398         + pixval[2][0] - 2.0 * pixval[2][1] + pixval[2][2]) / 10.0;
399     e = (pixval[0][0] - pixval[2][0]
400         + pixval[2][2] - pixval[0][2]) / 4.0;
401     f = (pixval[0][0] + 3.0 * pixval[0][1] + pixval[0][2]
402         - 2.0 * pixval[1][0] - 6.0 * pixval[1][1] - 2.0 * pixval[1][2]
403         + pixval[2][0] + 3.0 * pixval[2][1] + pixval[2][2]) / 10.0;
404 
405     temp = 4.0 * d * f - e * e;
406     *px = (float)1.5 + (float) i + (e * c - 2 * f * b) / temp;
407     *py = (float)1.5 + (float) j + (e * b - 2 * d * c) / temp;
408 
409     xs = (e * c - 2 * f * b) / temp;
410     ys = (e * b - 2 * d * c) / temp;
411 
412     inter = a + b * xs + c * ys + d * xs * xs + e * xs * ys + f * ys * ys;
413 
414 
415     /* set the covariace matrix */
416     det = d*f-e*e/4.0;
417     mat2_xx(*C) = (float)(-f/det);
418     mat2_yy(*C) = (float)(-d/det);
419     mat2_xy(*C) = mat2_yx(*C) = (float)((e/2.0)/det);
420 
421     return (inter);
422 }
423 
424 List *hough2_locate_peaks(Imrect *hough2, double thres)
425 {
426     double         min_x, min_y, max_x, max_y; /* logical coords */
427     int            x0, x1, y0, y1;             /* array indices  */
428     int            i, j;
429     double         binsize_x, binsize_y;
430     Vec2           p;
431     float          x, y;
432     List          *peaks_list=NULL;
433     double         top_lef, top_cen, top_rig;
434     double         mid_lef, mid_cen, mid_rig;
435     double         bot_lef, bot_cen, bot_rig;
436     double        *peak_val;
437     Point2        *peak;
438     Hough2_region *hough2_roi;
439     Vartype        vtype;
440     Mat2 *C;
441 
442 
443     if (hough2==NULL)
444     {
445         format("Error: hough2 not defined.\n");
446         return NULL;
447     }
448 
449 /* Extract the physical coords of the hough space */
450 
451     x0 = hough2->region->lx;
452     y0 = hough2->region->ly;
453     x1 = hough2->region->ux;
454     y1 = hough2->region->uy;
455 
456 /* Extract the logical coords of the hough space and the binsizes */
457 
458     if ((hough2_roi = prop_get(hough2->props, HOUGH2_ROI_TYPE)) == NULL)
459     {
460         format("Error: hough2_roi no defined.\n");
461         return NULL;
462     }
463 
464     min_x = hough2_roi->min_x;
465     min_y = hough2_roi->min_y;
466     max_x = hough2_roi->max_x;
467     max_y = hough2_roi->max_y;
468     binsize_x = hough2_roi->binsize_x;
469     binsize_y = hough2_roi->binsize_y;
470 
471 /* If the hough2 is less than 3x3 bins cannot find peaks */
472 
473     if ((x1-x0 < 3) || (y1-y0 < 3))
474     {
475         format("Error: hough2 too small to find peaks.\n");
476         return NULL;
477     }
478 
479 /* Access the image data */ 
480 
481     vtype =   hough2->vtype;
482 
483 /* Pass 3x3 window over the hough2. Add peaks to the peaks_list. */
484 
485     for(j=(y0+1);j<(y1-1);j++)
486         for(i=(x0+1);i<(x1-1);i++)
487         {
488             IM_PIX_GET(hough2, j  , i  , mid_cen);
489             IM_PIX_GET(hough2, j-1, i-1, top_lef);
490             IM_PIX_GET(hough2, j-1, i  , top_cen);
491             IM_PIX_GET(hough2, j-1, i+1, top_rig);
492             IM_PIX_GET(hough2, j  , i-1, mid_lef);
493             IM_PIX_GET(hough2, j  , i+1, mid_rig);
494             IM_PIX_GET(hough2, j+1, i-1, bot_lef);
495             IM_PIX_GET(hough2, j+1, i  , bot_cen);
496             IM_PIX_GET(hough2, j+1, i+1, bot_rig);
497 
498             if ( (mid_cen>=thres ) &&
499                  (mid_cen>=top_lef) &&
500                  (mid_cen>=top_cen) &&
501                  (mid_cen>top_rig) &&
502                  (mid_cen>=mid_lef) &&
503                  (mid_cen>mid_rig) &&
504                  (mid_cen>=bot_lef) &&
505                  (mid_cen>bot_cen) &&
506                  (mid_cen>bot_rig))
507                 {
508                     /* Interpolate surrounding pixels to determine peak pos
509                        and store the covariance matrix on the props list */
510 
511                     C = mat2_alloc();
512                     peak_val = (double *)ralloc(sizeof(double));
513                     *peak_val = im_get_quadcovar(hough2, i, j, &x, &y, C);
514                     
515                     vec2_x(p) = (float)(((double)x)*binsize_x+min_x);
516                     vec2_y(p) = (float)(((double)y)*binsize_y+min_y);
517                     peak = point2_make(p, HOUGH_PEAK_TYPE);
518                     peaks_list = ref_addtostart(peaks_list, peak, POINT2);
519                     peak->props = proplist_add(peak->props, peak_val, HOUGH2_PEAK,rfree);
520                     peak->props = proplist_add(peak->props, C, COVAR2, mat2_free);
521                 }
522         }/*endfor(i)*/
523 
524     return (peaks_list);                           
525 }
526 
527 /* ---------- */
528 
529 Vec2 *hough2_locate_max_peak(Imrect *hough2, double thres)
530 {
531     List *peak_list;
532     Point2 *p;
533     double peak_func();
534     Vec2 *vec2_copy();
535 
536     peak_list = hough2_locate_peaks(hough2, thres);
537 
538     if (peak_list==NULL) return NULL;
539 
540     peak_list = sort_list(peak_list, peak_func, NULL);
541     p = peak_list->to;
542 
543     return vec2_copy(&p->p);
544 
545     list_rm(peak_list, rfree);
546 }
547 
548 /* ---------- */
549 
550 double peak_func(Point2 *p)
551 {
552     double peak_val;
553     peak_val = *(double *)prop_get(p->props,HOUGH2_PEAK);
554     return (-peak_val);
555 }
556 
557 /* ---------- */
558 
559 void hough2_fill(Imrect *hough2, double val)
560 {
561     int lx, ly, ux, uy;             /* array indices  */
562         int i, j;
563 
564     if (hough2==NULL)
565     {
566         format("Error: hough2 not defined.\n");
567                 return;
568     }
569 
570 /* Extract the physical coords of the hough space */
571 
572     lx = hough2->region->lx;
573     ly = hough2->region->ly;
574     ux = hough2->region->ux;
575     uy = hough2->region->uy;
576 
577         for(i=lx;i<ux;i++)
578         {
579                 for(j=ly;j<uy;j++)
580                 {
581                         /*IM_PIX_SET(hough2, j, i, val);*/
582                         ((double**)hough2->data)[j][i] = val;
583                 }
584         }
585 }
586 
587 /* ---------- */
588 
589 void hough2_plot_ellipse(Imrect *hough2, Vec2 *c, Mat2 *C, 
590                          double weight) 
591 {
592     Hough2_region *hough2_roi;    
593     double minx, miny, maxx, maxy, binsizex, binsizey;
594     double ellipse_bound;
595     int ellipse_minx, ellipse_maxx, ellipse_miny, ellipse_maxy;
596     int x, y;
597     double px, py, dx, dy;
598     double chi2, f, g;
599     int lx, ly, ux, uy;
600     Mat2 invC;
601     double det;
602 
603     if (hough2==NULL)
604     {
605         format("Error: hough2 not defined.\n");
606         return;
607     }
608 
609 /* Extract the physical coords of the hough space */
610 
611     lx = hough2->region->lx;
612     ly = hough2->region->ly;
613     ux = hough2->region->ux;
614     uy = hough2->region->uy;
615 
616 /* Extract the logical coords of the hough space and the binsizes */
617 
618     if ((hough2_roi = prop_get(hough2->props, HOUGH2_ROI_TYPE)) == NULL)
619     {
620         format("Error: hough2_roi not defined.\n");
621         return;
622     }
623 
624     minx = hough2_roi->min_x;
625     miny = hough2_roi->min_y;
626     maxx = hough2_roi->max_x;
627     maxy = hough2_roi->max_y;
628     binsizex = hough2_roi->binsize_x;
629     binsizey = hough2_roi->binsize_y;
630 
631     if (mat2_xx(*C) > mat2_yy(*C))
632     {
633         ellipse_bound = 3.0*sqrt(mat2_xx(*C));
634     }
635     else
636     {
637         ellipse_bound = 3.0*sqrt(mat2_yy(*C));
638     }
639 
640     ellipse_minx = (int)((vec2_x(*c) - ellipse_bound - minx)/binsizex);
641     ellipse_maxx = (int)((vec2_x(*c) + ellipse_bound - minx)/binsizex);
642     ellipse_miny = (int)((vec2_y(*c) - ellipse_bound - miny)/binsizey);
643     ellipse_maxy = (int)((vec2_y(*c) + ellipse_bound - miny)/binsizey);
644 
645     /* Determine the inverse of the covariance matrix */
646 
647     det = mat2_xx(*C)*mat2_yy(*C) - mat2_xy(*C)*mat2_yx(*C);
648 
649     mat2_xx(invC) = (float)(mat2_yy(*C)/det);
650     mat2_xy(invC) = (float)(-mat2_xy(*C)/det);
651     mat2_yx(invC) = (float)(-mat2_yx(*C)/det);
652     mat2_yy(invC) = (float)(mat2_xx(*C)/det);
653 
654     for(x = ellipse_minx; x <= ellipse_maxx; x++)
655     {
656         for(y = ellipse_miny; y <= ellipse_maxy; y++)
657         {
658             if ( (x>=lx) && (x<ux) && (y>=ly) && (y<uy) )
659             {
660                 /* Get the position of this pixel centre */
661                 px = ((double)x+0.5)*binsizex + minx;
662                 py = ((double)y+0.5)*binsizey + miny;
663 
664                 dx = px-vec2_x(*c);
665                 dy = py-vec2_y(*c);
666 
667                 chi2 = dx*dx*mat2_xx(invC) + dx*dy*mat2_xy(invC) + 
668                        dx*dy*mat2_yx(invC) + dy*dy*mat2_yy(invC);
669 
670                 f = weight*(9.0-chi2);
671   
672                 if (f>0.0)
673                 {
674                     g = ((double**)hough2->data)[y][x];
675                     ((double**)hough2->data)[y][x] = (double)f+g;
676                 }
677             }   
678         }
679     }
680 }
681 
682 /* ---------- */
683 
684 void sqrt_hough2(Imrect *hough2)
685 {
686     int     i,j, min_x, min_y, max_x, max_y;
687     double  hough2_data;
688 
689     min_x = hough2->region->lx;
690     min_y = hough2->region->ly;
691     max_x = hough2->region->ux;
692     max_y = hough2->region->uy;
693 
694 /* Each histogram entry is replaced by its square root */
695 
696     for(i=min_y;i<max_y;i++)
697         for(j=min_x;j<max_x;j++)
698         {
699             IM_PIX_GET(hough2,i,j,hough2_data);
700             IM_PIX_SET(hough2,i,j,(double)sqrt((double)hough2_data));
701         }
702 }
703 
704 /* ---------- */
705 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.