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

Linux Cross Reference
Tina6/tina-libs/tina/image/imgPrc_sqrt.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_sqrt.c,v $
 37  * Date    :  $Date: 2003/09/30 16:53:49 $
 38  * Version :  $Revision: 1.6 $
 39  * CVS Id  :  $Id: imgPrc_sqrt.c,v 1.6 2003/09/30 16:53:49 ipoole Exp $
 40  *
 41  * Author  : Legacy TINA
 42  */
 43 
 44 /** 
 45  *  @file
 46  *  @brief Square root transformation of scalar and complex images. 
 47  *
 48  *  For use with Fourier based algorithms and noise stabilisation of data with
 49  *  Poisson noise characteristics (eg: image histograms).
 50  */
 51 
 52 #include "imgPrc_sqrt.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 Imrect         *imf_sqrt(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                         if (row1[j] >= 0.0)
 94                                 row2[j] = (float) sqrt(row1[j]);
 95                         else
 96                                 row2[j] = (float) -sqrt(-row1[j]);
 97                 im_put_rowf(row2, im2, i, lx, ux);
 98         }
 99 
100         fvector_free(row1, lx);
101         fvector_free(row2, lx);
102         return (im2);
103 }
104 
105 Imrect         *imz_sqrt(Imrect * im1)
106 {
107         Imrect         *im2;
108         Imregion       *roi;
109         Complex        *row1;
110         Complex        *row2;
111         int             lx, ux, ly, uy;
112         int             i, j;
113 
114         if (im1 == NULL)
115                 return (NULL);
116 
117         roi = im1->region;
118         if (roi == NULL)
119                 return (NULL);
120         lx = roi->lx;
121         ux = roi->ux;
122         ly = roi->ly;
123         uy = roi->uy;
124 
125         im2 = im_alloc(im1->height, im1->width, roi, complex_v);
126         row1 = zvector_alloc(lx, ux);
127         row2 = zvector_alloc(lx, ux);
128 
129         for (i = ly; i < uy; ++i)
130         {
131                 im_get_rowz(row1, im1, i, lx, ux);
132                 for (j = lx; j < ux; ++j)
133                         row2[j] = cmplx_sqrt(row1[j]);
134                 im_put_rowz(row2, im2, i, lx, ux);
135         }
136 
137         zvector_free(row1, lx);
138         zvector_free(row2, lx);
139         return (im2);
140 }
141 
142 Imrect         *im_sqrt(Imrect * im)
143 {
144         switch (im->vtype)
145         {
146                 case complex_v:
147                 return (imz_sqrt(im));
148         default:
149                 return (imf_sqrt(im));
150         }
151 }
152 

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