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

Linux Cross Reference
Tina5/tina-libs/tina/image/imgPrc_prof1.c

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

  1 /**********
  2  *
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  *
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-libs/tina/image/imgPrc_prof1.c,v $
 37  * Date    :  $Date: 2003/09/22 16:09:02 $
 38  * Version :  $Revision: 1.4 $
 39  * CVS Id  :  $Id: imgPrc_prof1.c,v 1.4 2003/09/22 16:09:02 tony Exp $
 40  *
 41  * Author  : Legacy TINA
 42  *
 43  * Notes : 
 44  */
 45 
 46 /** 
 47  *  @file
 48  *  @brief Allocation, free and reverse for generic profiles
 49  *
 50  */
 51 
 52 #include "imgPrc_prof1.h"
 53 
 54 #if HAVE_CONFIG_H
 55 #include <config.h>
 56 #endif
 57 
 58 #include <math.h>
 59 #include <tina/sys/sysDef.h>
 60 #include <tina/sys/sysPro.h>
 61 #include <tina/math/mathDef.h>
 62 #include <tina/math/mathPro.h>
 63 #include <tina/image/img_GenDef.h>
 64 #include <tina/image/img_GenPro.h>
 65 
 66 
 67 Prof1          *prof1_alloc(int n1, int n2, Vartype vtype)
 68 {
 69         Prof1          *prof;
 70 
 71         if (n2 < n1)
 72         {
 73                 error("prof1_alloc: bad size", non_fatal);
 74                 return (NULL);
 75         }
 76         if (n2 == n1)
 77         {
 78                 error("prof1_alloc: zero size", warning);
 79                 return (NULL);
 80         }
 81         prof = ts_ralloc(Prof1);
 82         prof->n1 = n1;
 83         prof->n2 = n2;
 84         prof->vtype = vtype;
 85 
 86         switch (vtype)
 87         {
 88         case char_v:
 89         case uchar_v:
 90                 prof->el.char_v = cvector_alloc(n1, n2);
 91                 break;
 92         case short_v:
 93         case ushort_v:
 94                 prof->el.short_v = svector_alloc(n1, n2);
 95                 break;
 96         case int_v:
 97         case uint_v:
 98                 prof->el.int_v = ivector_alloc(n1, n2);
 99                 break;
100         case float_v:
101                 prof->el.float_v = fvector_alloc(n1, n2);
102                 break;
103         case double_v:
104                 prof->el.double_v = dvector_alloc(n1, n2);
105                 break;
106         case complex_v:
107                 prof->el.complex_v = zvector_alloc(n1, n2);
108                 break;
109         case ptr_v:
110                 prof->el.ptr_v = pvector_alloc(n1, n2);
111                 break;
112         default:
113                 error("prof1_alloc: unsupported type", non_fatal);
114                 break;
115         }
116         return (prof);
117 }
118 
119 void            prof1_free(Prof1 * prof)
120 {
121         int             n;
122 
123         if (prof == NULL)
124                 return;
125         n = prof->n1;
126 
127         switch (prof->vtype)
128         {
129         case char_v:
130         case uchar_v:
131                 cvector_free(prof->el.char_v, n);
132                 break;
133         case short_v:
134         case ushort_v:
135                 svector_free(prof->el.short_v, n);
136                 break;
137         case int_v:
138         case uint_v:
139                 ivector_free(prof->el.int_v, n);
140                 break;
141         case float_v:
142                 fvector_free(prof->el.float_v, n);
143                 break;
144         case double_v:
145                 dvector_free(prof->el.double_v, n);
146                 break;
147         case complex_v:
148                 zvector_free(prof->el.complex_v, n);
149                 break;
150         case ptr_v:
151                 pvector_free(prof->el.ptr_v, n);
152                 break;
153         default:
154                 error("prof1_free: unsupported type", non_fatal);
155                 break;
156         }
157         rfree(prof);
158 }
159 
160 Prof1          *prof1_reverse(Prof1 * prof)
161 {
162         Prof1          *rev;
163         Prof1          *prof1_alloc(int n1, int n2, Vartype vtype);
164         int             i, n1, n2;
165 
166         if (prof == NULL)
167                 return (NULL);
168 
169         n1 = -prof->n2 + 1;
170         n2 = -prof->n1 + 1;
171         rev = prof1_alloc(n1, n2, prof->vtype);
172         switch (prof->vtype)
173         {
174         case char_v:
175         case uchar_v:
176                 for (i = n1; i < n2; ++i)
177                         rev->el.char_v[i] = prof->el.char_v[-i];
178                 break;
179         case short_v:
180         case ushort_v:
181                 for (i = n1; i < n2; ++i)
182                         rev->el.short_v[i] = prof->el.short_v[-i];
183                 break;
184         case int_v:
185         case uint_v:
186                 for (i = n1; i < n2; ++i)
187                         rev->el.int_v[i] = prof->el.int_v[-i];
188                 break;
189         case float_v:
190                 for (i = n1; i < n2; ++i)
191                         rev->el.float_v[i] = prof->el.float_v[-i];
192                 break;
193         case double_v:
194                 for (i = n1; i < n2; ++i)
195                         rev->el.double_v[i] = prof->el.double_v[-i];
196                 break;
197         case complex_v:
198                 for (i = n1; i < n2; ++i)
199                         rev->el.complex_v[i] = prof->el.complex_v[-i];
200                 break;
201         case ptr_v:
202                 for (i = n1; i < n2; ++i)
203                         rev->el.ptr_v[i] = prof->el.ptr_v[-i];
204                 break;
205         default:
206                 error("prof1_reverse: unsupported type", non_fatal);
207                 break;
208         }
209         return (rev);
210 }
211 

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