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

Linux Cross Reference
Tina5/tina-libs/tina/image/imgPrc_sin.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_sin.c,v $
 37  * Date    :  $Date: 2003/09/22 16:09:02 $
 38  * Version :  $Revision: 1.5 $
 39  * CVS Id  :  $Id: imgPrc_sin.c,v 1.5 2003/09/22 16:09:02 tony Exp $
 40  *
 41  * Author  : Legacy TINA
 42  */
 43 
 44 /** 
 45  *  @file
 46  *  @brief Sine and inverse sine transformation of scalar and complex images.
 47  *  For use as stabilising transforms with bi-nomial pixel data. 
 48  *
 49  */
 50 
 51 #include "imgPrc_sin.h"
 52 
 53 #if HAVE_CONFIG_H
 54 #include <config.h>
 55 #endif
 56 
 57 #include <math.h>
 58 #include <tina/sys/sysDef.h>
 59 #include <tina/sys/sysPro.h>
 60 #include <tina/math/mathDef.h>
 61 #include <tina/math/mathPro.h>
 62 #include <tina/image/img_GenDef.h>
 63 #include <tina/image/img_GenPro.h>
 64 
 65 
 66 Imrect         *imf_sin(Imrect * im1)
 67 {
 68         Imrect         *im2;
 69         Imregion       *roi;
 70         float          *row1, *row2;
 71         int             lx, ux, ly, uy;
 72         int             i, j;
 73 
 74         if (im1 == NULL)
 75                 return (NULL);
 76 
 77         roi = im1->region;
 78         if (roi == NULL)
 79                 return (NULL);
 80         lx = roi->lx;
 81         ux = roi->ux;
 82         ly = roi->ly;
 83         uy = roi->uy;
 84 
 85         im2 = im_alloc(im1->height, im1->width, roi, float_v);
 86         row1 = fvector_alloc(lx, ux);
 87         row2 = fvector_alloc(lx, ux);
 88 
 89         for (i = ly; i < uy; ++i)
 90         {
 91                 im_get_rowf(row1, im1, i, lx, ux);
 92                 for (j = lx; j < ux; ++j)
 93                         row2[j] = (float) sin(row1[j]);
 94                 im_put_rowf(row2, im2, i, lx, ux);
 95         }
 96 
 97         fvector_free(row1, lx);
 98         fvector_free(row2, lx);
 99         return (im2);
100 }
101 
102 Imrect         *imz_sin(Imrect * im1)
103 {
104         Imrect         *im2;
105         Imregion       *roi;
106         Complex        *row1;
107         Complex        *row2;
108         int             lx, ux, ly, uy;
109         int             i, j;
110 
111         if (im1 == NULL)
112                 return (NULL);
113 
114         roi = im1->region;
115         if (roi == NULL)
116                 return (NULL);
117         lx = roi->lx;
118         ux = roi->ux;
119         ly = roi->ly;
120         uy = roi->uy;
121 
122         im2 = im_alloc(im1->height, im1->width, roi, complex_v);
123         row1 = zvector_alloc(lx, ux);
124         row2 = zvector_alloc(lx, ux);
125 
126         for (i = ly; i < uy; ++i)
127         {
128                 im_get_rowz(row1, im1, i, lx, ux);
129                 for (j = lx; j < ux; ++j)
130                         row2[j] = cmplx_sin(row1[j]);
131                 im_put_rowz(row2, im2, i, lx, ux);
132         }
133 
134         zvector_free(row1, lx);
135         zvector_free(row2, lx);
136         return (im2);
137 }
138 
139 Imrect         *im_sin(Imrect * im)
140 {
141         switch (im->vtype)
142         {
143                 case complex_v:
144                 return (imz_sin(im));
145         default:
146                 return (imf_sin(im));
147         }
148 }
149 
150 Imrect         *imf_asin(Imrect * im1)
151 {
152         Imrect         *im2;
153         Imregion       *roi;
154         float          *row1, *row2;
155         int             lx, ux, ly, uy;
156         int             i, j;
157 
158         if (im1 == NULL)
159                 return (NULL);
160 
161         roi = im1->region;
162         if (roi == NULL)
163                 return (NULL);
164         lx = roi->lx;
165         ux = roi->ux;
166         ly = roi->ly;
167         uy = roi->uy;
168 
169         im2 = im_alloc(im1->height, im1->width, roi, float_v);
170         row1 = fvector_alloc(lx, ux);
171         row2 = fvector_alloc(lx, ux);
172 
173         for (i = ly; i < uy; ++i)
174         {
175                 im_get_rowf(row1, im1, i, lx, ux);
176                 for (j = lx; j < ux; ++j)
177                         row2[j] = (float) asin(row1[j]);
178                 im_put_rowf(row2, im2, i, lx, ux);
179         }
180 
181         fvector_free(row1, lx);
182         fvector_free(row2, lx);
183         return (im2);
184 }
185 
186 Imrect         *imz_asin(Imrect * im1)
187 {
188         Imrect         *im2;
189         Imregion       *roi;
190         Complex        *row1;
191         Complex        *row2;
192         int             lx, ux, ly, uy;
193         int             i, j;
194 
195         if (im1 == NULL)
196                 return (NULL);
197 
198         roi = im1->region;
199         if (roi == NULL)
200                 return (NULL);
201         lx = roi->lx;
202         ux = roi->ux;
203         ly = roi->ly;
204         uy = roi->uy;
205 
206         im2 = im_alloc(im1->height, im1->width, roi, complex_v);
207         row1 = zvector_alloc(lx, ux);
208         row2 = zvector_alloc(lx, ux);
209 
210         for (i = ly; i < uy; ++i)
211         {
212                 im_get_rowz(row1, im1, i, lx, ux);
213                 for (j = lx; j < ux; ++j)
214                         row2[j] = cmplx_asin(row1[j]);
215                 im_put_rowz(row2, im2, i, lx, ux);
216         }
217 
218         zvector_free(row1, lx);
219         zvector_free(row2, lx);
220         return (im2);
221 }
222 
223 Imrect         *im_asin(Imrect * im)
224 {
225         switch (im->vtype)
226         {
227                 case complex_v:
228                 return (imz_asin(im));
229         default:
230                 return (imf_asin(im));
231         }
232 }
233 

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