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

Linux Cross Reference
Tina5/tina-libs/tina/image/imgPrc_gauss.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_gauss.c,v $
 37  * Date    :  $Date: 2004/08/05 14:32:44 $
 38  * Version :  $Revision: 1.8 $
 39  * CVS Id  :  $Id: imgPrc_gauss.c,v 1.8 2004/08/05 14:32:44 neil Exp $
 40  *
 41  * Author  : Legacy TINA
 42  */
 43 /** 
 44  *  @file
 45  *  @brief Apply a Gaussian smoothing kernel to an image.
 46  *
 47  *  Function to perform Gaussian smoothing of images, using a 1d Gaussian profile.
 48  *  Note that TINA does not allow these profiles to be longer than 20 elements. Also
 49  *  note that crashes will occur if an attempt is made to smooth an image much smaller 
 50  *  than the length of the profile.
 51  */
 52 
 53 #include "imgPrc_gauss.h"
 54 
 55 #if HAVE_CONFIG_H
 56 #include <config.h>
 57 #endif
 58 
 59 #include <math.h>
 60 #include <tina/sys/sysDef.h>
 61 #include <tina/sys/sysPro.h>
 62 #include <tina/math/mathDef.h>
 63 #include <tina/math/mathPro.h>
 64 #include <tina/image/img_GenDef.h>
 65 #include <tina/image/img_GenPro.h>
 66 #include <tina/image/img_PrcDef.h>
 67 #include <tina/image/imgPrc_conv_prof.h>
 68 #include <tina/image/imgPrc_smooth_1d.h>
 69 #include <tina/image/imgPrc_filter.h>
 70 #include <tina/image/imgPrc_prof1.h>
 71 
 72 /**
 73  * @brief Function to apply Gaussian smoothing to an image.
 74  * @param image Pointer to the image to be smoothed.
 75  * @param sig The standard deviation of the Gaussian smoothing kernel
 76  * @param precision The probability at which the Gaussian kernel is truncated.
 77  * @return image Pointer to the smoothed image.
 78  *
 79  * A 1-d Gaussian profile is created with standard deviation sig, truncated at the point 
 80  * where the probability falls below precision.  This is applied to the image columns and 
 81  * rows separately, then a pointer to the smoothed image is returned. The original image is 
 82  * not freed here.
 83  */
 84 Imrect         *imf_gauss(Imrect * image, double sig, double precision)
 85 {
 86         Imrect         *wim;
 87         Prof1          *prof;
 88 
 89         if (image == NULL)
 90                 return (NULL);
 91 
 92         prof = prof_gauss(sig, precision);
 93         wim = im_filter_rows(image, smooth_1d_sym, (void *) prof);
 94         image = im_filter_cols(wim, smooth_1d_sym, (void *) prof);
 95         prof1_free(prof);
 96         im_free(wim);
 97         return (image);
 98 }
 99 
100 Imrect *imf_gauss_rows(Imrect *image, double sig, double precision)
101 {
102   Imrect *fim;
103   Prof1 *prof;
104 
105   if (image == NULL)
106     return(NULL);
107 
108   prof = prof_gauss(sig, precision);
109   fim = im_filter_rows(image, smooth_1d_sym, prof);
110   prof1_free(prof);
111   return(fim);
112 }
113 
114 Imrect *imf_gauss_cols(Imrect *image, double sig, double precision)
115 {
116   Imrect *fim;
117   Prof1 *prof;
118 
119   if (image == NULL)
120     return(NULL);
121 
122   prof = prof_gauss(sig, precision);
123   fim = im_filter_cols(image, smooth_1d_sym, prof);
124   prof1_free(prof);
125   return(fim);
126 }
127 
128 

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