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

Linux Cross Reference
Tina6/tina-libs/tina/image/imgPrc_filter.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_filter.c,v $
 37  * Date    :  $Date: 2004/08/05 14:32:44 $
 38  * Version :  $Revision: 1.7 $
 39  * CVS Id  :  $Id: imgPrc_filter.c,v 1.7 2004/08/05 14:32:44 neil Exp $
 40  *
 41  * Author  : Legacy TINA
 42  */
 43 /** 
 44  *  @file
 45  *  @brief One dimensional generic filtering.
 46  *
 47  *  These functions act as callers to the TINA smoothing functions, such as those in 
 48  *  imPrc_smooth_1d, allowing 1-d profiles to be applied to images using the smoothing 
 49  *  function of choice. They convert to floating point images. The original images are 
 50  *  not freed here.
 51  */ 
 52 
 53 #include "imgPrc_filter.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 
 67 /**
 68  * @brief Call a smoothing function to apply a 1-d profile to the rows of an image.
 69  * @param image Pointer to the image to be smoothed
 70  * @param func Pointer to the smoothing function to be called.
 71  * @param data The 1-d smoothing profile to be applied.
 72  * @return filtered_im Pointer to the smoothed image.
 73  *
 74  * Calls the function func (e.g. one of the smoothing functions in imPrc_smooth_1d) to apply the
 75  * 1-d smoothing profile data to the rows of the image.
 76  */
 77 Imrect         *im_filter_rows(Imrect * image, void (*func) ( /* ??? */ ), void *data)
 78 {
 79         Imrect         *filtered_im;
 80         float          *line;
 81         int             lx, ux, ly, uy;
 82         int             i;
 83 
 84         if (image == NULL)
 85                 return (NULL);
 86 
 87         lx = image->region->lx;
 88         ux = image->region->ux;
 89         ly = image->region->ly;
 90         uy = image->region->uy;
 91 
 92         filtered_im = im_alloc(image->height, image->width, image->region, float_v);
 93         line = fvector_alloc(lx, ux);
 94 
 95         for (i = ly; i < uy; ++i)
 96         {
 97                 im_get_rowf(line, image, i, lx, ux);
 98                 func(line, lx, ux, data);
 99                 im_put_rowf(line, filtered_im, i, lx, ux);
100         }
101 
102         fvector_free(line, lx);
103         return (filtered_im);
104 }
105 
106 
107 /**
108  * @brief Call a smoothing function to apply a 1-d profile to the columns of an image.
109  * @param image Pointer to the image to be smoothed
110  * @param func Pointer to the smoothing function to be called.
111  * @param data The 1-d smoothing profile to be applied.
112  * @return filtered_im Pointer to the smoothed image.
113  *
114  * Calls the function func (e.g. one of the smoothing functions in imPrc_smooth_1d) to apply the
115  * 1-d smoothing profile data to the columns of the image.
116  */
117 Imrect         *im_filter_cols(Imrect * image, void (*func) ( /* ??? */ ), void *data)
118 {
119         Imrect         *filtered_im;
120         float          *line;
121         int             lx, ux, ly, uy;
122         int             i;
123 
124         if (image == NULL)
125                 return (NULL);
126 
127         lx = image->region->lx;
128         ux = image->region->ux;
129         ly = image->region->ly;
130         uy = image->region->uy;
131 
132         filtered_im = im_alloc(image->height, image->width, image->region, float_v);
133         line = fvector_alloc(ly, uy);
134 
135         for (i = lx; i < ux; ++i)
136         {
137                 im_get_colf(line, image, i, ly, uy);
138                 func(line, ly, uy, data);
139                 im_put_colf(line, filtered_im, i, ly, uy);
140         }
141 
142         fvector_free(line, ly);
143         return (filtered_im);
144 }
145 

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