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

Linux Cross Reference
Tina4/src/vision/improc/prof1.c

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

  1 /**@(#)
  2 **/
  3 /* prof1.c
  4  * 
  5  * standard handling functions for generic profiles
  6  * 
  7  */
  8 
  9 #include <math.h>
 10 #include <tina/sys.h>
 11 #include <tina/sysfuncs.h>
 12 #include <tina/math.h>
 13 #include <tina/vision.h>
 14 
 15 Prof1  *prof1_alloc(int n1, int n2, Vartype vtype)
 16 {
 17     Prof1  *prof;
 18 
 19     if (n2 < n1)
 20     {
 21         error("prof1_alloc: bad size", non_fatal);
 22         return (NULL);
 23     }
 24     if (n2 == n1)
 25     {
 26         error("prof1_alloc: zero size", warning);
 27         return (NULL);
 28     }
 29     prof = ts_ralloc(Prof1);
 30     prof->n1 = n1;
 31     prof->n2 = n2;
 32     prof->vtype = vtype;
 33 
 34     switch (vtype)
 35     {
 36     case char_v:
 37     case uchar_v:
 38         prof->el.char_v = cvector_alloc(n1, n2);
 39         break;
 40     case short_v:
 41     case ushort_v:
 42         prof->el.short_v = svector_alloc(n1, n2);
 43         break;
 44     case int_v:
 45     case uint_v:
 46         prof->el.int_v = ivector_alloc(n1, n2);
 47         break;
 48     case float_v:
 49         prof->el.float_v = fvector_alloc(n1, n2);
 50         break;
 51     case double_v:
 52         prof->el.double_v = dvector_alloc(n1, n2);
 53         break;
 54     case complex_v:
 55         prof->el.complex_v = zvector_alloc(n1, n2);
 56         break;
 57     case ptr_v:
 58         prof->el.ptr_v = pvector_alloc(n1, n2);
 59         break;
 60     }
 61     return (prof);
 62 }
 63 
 64 void    prof1_free(Prof1 * prof)
 65 {
 66     int     n;
 67 
 68     if (prof == NULL)
 69         return;
 70     n = prof->n1;
 71 
 72     switch (prof->vtype)
 73     {
 74     case char_v:
 75     case uchar_v:
 76         cvector_free((void *) prof->el.char_v, n);
 77         break;
 78     case short_v:
 79     case ushort_v:
 80         svector_free((void *) prof->el.short_v, n);
 81         break;
 82     case int_v:
 83     case uint_v:
 84         ivector_free((void *) prof->el.int_v, n);
 85         break;
 86     case float_v:
 87         fvector_free((void *) prof->el.float_v, n);
 88         break;
 89     case double_v:
 90         dvector_free((void *) prof->el.double_v, n);
 91         break;
 92     case complex_v:
 93         zvector_free((void *) prof->el.complex_v, n);
 94         break;
 95     case ptr_v:
 96         pvector_free((void *) prof->el.ptr_v, n);
 97         break;
 98     }
 99     rfree((void *) prof);
100 }
101 
102 Prof1  *prof1_reverse(Prof1 * prof)
103 {
104     Prof1  *rev;
105     Prof1  *prof1_alloc(int n1, int n2, Vartype vtype);
106     int     i, n1, n2;
107 
108     if (prof == NULL)
109         return (NULL);
110 
111     n1 = -prof->n2 + 1;
112     n2 = -prof->n1 + 1;
113     rev = prof1_alloc(n1, n2, prof->vtype);
114     switch (prof->vtype)
115     {
116     case char_v:
117     case uchar_v:
118         for (i = n1; i < n2; ++i)
119             rev->el.char_v[i] = prof->el.char_v[-i];
120         break;
121     case short_v:
122     case ushort_v:
123         for (i = n1; i < n2; ++i)
124             rev->el.short_v[i] = prof->el.short_v[-i];
125         break;
126     case int_v:
127     case uint_v:
128         for (i = n1; i < n2; ++i)
129             rev->el.int_v[i] = prof->el.int_v[-i];
130         break;
131     case float_v:
132         for (i = n1; i < n2; ++i)
133             rev->el.float_v[i] = prof->el.float_v[-i];
134         break;
135     case double_v:
136         for (i = n1; i < n2; ++i)
137             rev->el.double_v[i] = prof->el.double_v[-i];
138         break;
139     case complex_v:
140         for (i = n1; i < n2; ++i)
141             rev->el.complex_v[i] = prof->el.complex_v[-i];
142         break;
143     case ptr_v:
144         for (i = n1; i < n2; ++i)
145             rev->el.ptr_v[i] = prof->el.ptr_v[-i];
146         break;
147     }
148     return (rev);
149 }
150 

~ [ 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.