image_arith.h

00001 
00002 /*----------------------------------------------------------------------------
00003  *                                  E.S.O.
00004  *----------------------------------------------------------------------------
00005  * File name    :   image_arith.h
00006  * Author       :   Nicolas Devillard
00007  * Created on   :   Aug 11, 1995
00008  * Hardware     :   Sun Sparc 20
00009  * Software     :   ANSI C under Solaris Unix
00010  *                  Part of ECLIPSE library for Adonis
00011  * Description  :   basic arithmetic functions over images
00012  *--------------------------------------------------------------------------*/
00013 
00014 /*
00015 
00016  $Id: image_arith.h,v 1.2 2005/09/05 14:32:17 amodigli Exp $
00017  $Author: amodigli $
00018  $Date: 2005/09/05 14:32:17 $
00019  $Revision: 1.2 $
00020 
00021  */
00022 
00023 #ifndef _IMAGE_ARITHMETIC_H_
00024 #define _IMAGE_ARITHMETIC_H_
00025 
00026 
00027 /*----------------------------------------------------------------------------
00028  *                              Includes
00029  *--------------------------------------------------------------------------*/
00030 
00031 #include <stdio.h>
00032 #include <string.h>
00033 #include <math.h>
00034 #include <malloc.h>
00035 
00036 #include "memory.h"
00037 #include "cube_defs.h"
00038 
00039 #include "image_handling.h"
00040 
00041 
00042 /*----------------------------------------------------------------------------
00043  *                              Defines
00044  *--------------------------------------------------------------------------*/
00045 
00046 /* Image normalization types    */
00047 
00048 #define NORM_SCALE      1
00049 #define NORM_MEAN       2
00050 #define NORM_FLUX       3
00051 #define NORM_AFLUX      4
00052 
00053 
00054 /*----------------------------------------------------------------------------
00055  *                      Function ANSI C prototypes
00056  *--------------------------------------------------------------------------*/
00057 
00058 /*----------------------------------------------------------------------------
00059  * Function :   add_image()
00060  * In       :   2 images
00061  * Out      :   1 newly allocated image
00062  * Job      :   add two images
00063  * Notice   :   images must share same dimensions
00064  *--------------------------------------------------------------------------*/
00065 /*<python>*/
00066 OneImage    *
00067 add_image(
00068     OneImage    *   image1,
00069     OneImage    *   image2) ; 
00070 /*</python>*/
00071 
00072 
00073 /*----------------------------------------------------------------------------
00074  * Function :   sub_image()
00075  * In       :   2 images
00076  * Out      :   1 newly allocated image
00077  * Job      :   subtract two images
00078  * Notice   :   images must share same dimensions
00079  *--------------------------------------------------------------------------*/
00080 
00081 /*<python>*/
00082 OneImage *
00083 sub_image(
00084     OneImage *image1,
00085     OneImage *image2) ;
00086 /*</python>*/
00087   
00088 
00089 /*----------------------------------------------------------------------------
00090  * Function :   mul_image()
00091  * In       :   2 images
00092  * Out      :   1 newly allocated image
00093  * Job      :   multiply two images
00094  * Notice   :   images must share same dimensions
00095  *--------------------------------------------------------------------------*/
00096 
00097 /*<python>*/
00098 OneImage *
00099 mul_image(
00100     OneImage *image1,
00101     OneImage *image2) ;
00102 /*</python>*/
00103  
00104 
00105 /*----------------------------------------------------------------------------
00106  * Function :   div_image()
00107  * In       :   2 images
00108  * Out      :   1 newly allocated image
00109  * Job      :   divide two images
00110  * Notice   :   images must share same dimensions
00111  *--------------------------------------------------------------------------*/
00112 
00113 /*<python>*/
00114 OneImage *
00115 div_image(
00116     OneImage *image1,
00117     OneImage *image2) ;
00118 /*</python>*/
00119 
00120 /*----------------------------------------------------------------------------
00121  * Function :   add_img_local()
00122  * In       :   2 images
00123  * Out      :   int 0 if ok, -1 otherwise
00124  * Job      :   add two images, store the result in the first image
00125  * Notice   :   optimized (i.e. mostly unreadable)  
00126  *--------------------------------------------------------------------------*/
00127 
00128 int
00129 add_img_local(
00130     OneImage * im1,
00131     OneImage * im2
00132 ) ;
00133 
00134 
00135 /*----------------------------------------------------------------------------
00136  * Function :   sub_img_local()
00137  * In       :   2 images
00138  * Out      :   int 0 if ok, -1 otherwise
00139  * Job      :   subtract two images, store the result in the first image
00140  * Notice   :   optimized (i.e. mostly unreadable)  
00141  *--------------------------------------------------------------------------*/
00142 
00143 int
00144 sub_img_local(
00145     OneImage * im1,
00146     OneImage * im2
00147 ) ;
00148 
00149 
00150 /*----------------------------------------------------------------------------
00151  * Function :   mul_img_local()
00152  * In       :   2 images
00153  * Out      :   int 0 if ok, -1 otherwise
00154  * Job      :   multiply two images, store the result in the first image
00155  * Notice   :   optimized (i.e. mostly unreadable)  
00156  *--------------------------------------------------------------------------*/
00157 
00158 int
00159 mul_img_local(
00160     OneImage * im1,
00161     OneImage * im2
00162 ) ;
00163 
00164 
00165 /*----------------------------------------------------------------------------
00166  * Function :   div_img_local()
00167  * In       :   2 images
00168  * Out      :   int 0 if ok, -1 otherwise
00169  * Job      :   divide two images, store the result in the first image
00170  * Notice   :   optimized (i.e. mostly unreadable)  
00171  *--------------------------------------------------------------------------*/
00172 
00173 int
00174 div_img_local(
00175     OneImage * im1,
00176     OneImage * im2
00177 ) ;
00178 
00179 
00180 
00181 /*-------------------------------------------------------------------------*/
00204 /*--------------------------------------------------------------------------*/
00205 
00206 int
00207 cst_op_image_local(
00208     OneImage    *   image,
00209     double          constant,
00210     int             operation
00211 ) ;
00212 
00213 
00214 
00215 /*----------------------------------------------------------------------------
00216  * Function :   cst_op_image()
00217  * In       :   1 image, 1 constant, operation to perform
00218  * Out      :   1 newly allocated image
00219  * Job      :   arithmetic operations between an image and a constant
00220  * Notice   :   possible operations are:
00221     Addition        '+'
00222     Subtraction     '-'
00223     Multiplication  '*'
00224     Division        '/'
00225     Logarithm       'l'
00226     Power           '^'
00227     Exponentiation  'e'
00228  *--------------------------------------------------------------------------*/
00229 
00230 /*<python>*/
00231 OneImage    *
00232 cst_op_image(
00233     OneImage    *image_in,
00234     double      constant,
00235     char            operation) ;
00236 /*</python>*/
00237 
00238 
00239 /*----------------------------------------------------------------------------
00240  * Function :   norm_image()
00241  * In       :   1 image, normalization type
00242  * Out      :   1 newly allocated image
00243  * Job      :   normalize an image according to a quantity
00244  * Notice   :   possible normalization modes are:
00245  *              NORM_SCALE makes 0 the minimum, 1 the maximum
00246  *              NORM_MEAN makes the mean 1.0
00247  *              NORM_FLUX makes the flux unity
00248  *              NORM_AFLUX makes the absolute flux unity
00249  *--------------------------------------------------------------------------*/
00250 
00251 OneImage *
00252 norm_image(
00253     OneImage    *   image_in,
00254     int             mode
00255 ) ;
00256 
00257 
00258 
00259 /*----------------------------------------------------------------------------
00260  * Function :   norm_flux()
00261  * In       :   1 image
00262  * Out      :   error code 0 if ok, -1 otherwise
00263  * Job      :   normalize an image to unity flux
00264  * Notice   :   WARNING! the image is modified!
00265  *--------------------------------------------------------------------------*/
00266 
00267 int
00268 norm_flux(OneImage * image_in) ;
00269         
00270 
00271 /*----------------------------------------------------------------------------
00272  * Function :   thresh_image()
00273  * In       :   1 image, min and max pixelvalue
00274  * Out      :   1 newly allocated image 
00275  * Job      :   threshold an image
00276  * Notice   :   pixels lower than lo_cut get value assign_lo_cut
00277  *              pixels above hi_cut get value assign_hi_cut
00278  *              to specify no threshold on lower bound, set lo_cut to
00279  *              MIN_PIX_VALUE, on upper bound to MAX_PIX_VALUE.
00280  *--------------------------------------------------------------------------*/
00281 
00282 OneImage *
00283 thresh_image(
00284     OneImage    *   image_in,
00285     pixelvalue      lo_cut,
00286     pixelvalue      hi_cut,
00287     pixelvalue      assign_lo_cut,
00288     pixelvalue      assign_hi_cut
00289 ) ;
00290 
00291 
00292 /*----------------------------------------------------------------------------
00293  * Function :   abs_image()
00294  * In       :   1 image
00295  * Out      :   1 newly allocated image
00296  * Job      :   for each pixel, out = abs(in)
00297  * Notice   :
00298  *--------------------------------------------------------------------------*/
00299 
00300 OneImage    *
00301 abs_image(OneImage * image_in) ;
00302 
00303 
00304 /*----------------------------------------------------------------------------
00305  * Function :   mean_image()
00306  * In       :   2 images
00307  * Out      :   1 newly allocated image
00308  * Job      :   take two images and compute their average
00309  * Notice   :   outpix = (pix1 + pix2)/2
00310  *--------------------------------------------------------------------------*/
00311 
00312 OneImage    *
00313 mean_image(
00314     OneImage    *   image_1,
00315     OneImage    *   image_2) ;
00316 
00317 
00318 
00319 /*----------------------------------------------------------------------------
00320  * Function :   subtract_min_from_image()
00321  * In       :   1 image
00322  * Out      :   error code 0 if ok, -1 otherwise
00323  * Job      :   subtract min value of an image to all its pixels, making
00324  *              it positive.
00325  * Notice   :   input image is modified
00326  *--------------------------------------------------------------------------*/
00327 
00328 int
00329 subtract_min_from_image(OneImage * image_in) ;
00330 
00331 
00332 /*----------------------------------------------------------------------------
00333  * Function :   get_floor_image()
00334  * In       :   1 image
00335  * Out      :   1 newly allocated image
00336  * Job      :   floor an image: pixelvalue to closest least integer
00337  * Notice   :
00338  *--------------------------------------------------------------------------*/
00339 
00340 OneImage *
00341 get_floor_image(OneImage * image_in) ;
00342 
00343 /*----------------------------------------------------------------------------
00344  * Function :   reciprocal_image()
00345  * In       :   1 image
00346  * Out      :   1 newly allocated image
00347  * Job      :   compute the reciprocal image: out = 1 / in
00348  * Notice   :   zero-valued pixels in input are zero-valued in output
00349  *--------------------------------------------------------------------------*/
00350 
00351 OneImage *
00352 reciprocal_image(OneImage * image_in) ;
00353 
00354 /*---------------------------------------------------------------------------
00355    Function :   invert_image()  
00356    In       :   1 image
00357    Out      :   int 0 if Ok, -1 otherwise
00358    Job      :   invert all pixels, i.e. pix = -pix
00359    Notice   :   operates in place - no new memory allocated
00360  ---------------------------------------------------------------------------*/
00361 
00362 int invert_image(OneImage * in) ;
00363 
00364 /*---------------------------------------------------------------------------
00365    Function :   subtract_median_from_each_row()
00366    In       :   1 image
00367    Out      :   int 0 if Ok, something else otherwise
00368    Job      :   for each row in the image, compute the median value and
00369                 subtract it from each pixel in the row.
00370    Notice   :   the input image is modified
00371                 This algorithm is suitable to remove detector row
00372                 saturation.
00373  ---------------------------------------------------------------------------*/
00374 
00375 int
00376 subtract_median_from_each_row(OneImage * in) ;
00377 
00378 /*---------------------------------------------------------------------------
00379    Function :   collapse_image()
00380    In       :   1 image, collapsing direction (int) 
00381    Out      :   a newly allocated 1D image
00382    Job      :   compute the sum of the rows OR of the columns
00383    Notice   :   collapse along y (sum of rows) -> int=0
00384                          along x (sum of columns) -> int=1
00385  ---------------------------------------------------------------------------*/
00386 
00387 OneImage *
00388 collapse_image(OneImage * inimage, int direction) ;
00389 
00390 
00391 /*---------------------------------------------------------------------------
00392    Function :   collapse_image_median()
00393    In       :   1 image, collapsing direction (int), number of lines
00394                 (or columns) to discard on each side.
00395    Out      :   newly allocated (1d) image
00396    Job      :   compute a collapsed line over rows or columns
00397    Notice   :   the collapsed line has the median value of the row or column
00398                 above it, minus the discarded values.
00399                 collapse along y -> direction=0
00400                 collapse along x -> direction=1
00401  ---------------------------------------------------------------------------*/
00402 
00403 OneImage *
00404 collapse_image_median(
00405     OneImage    *   in,
00406     int             direction,
00407     int             discard_lo,
00408     int             discard_hi
00409 );
00410 
00411 #endif
00412 /*--------------------------------------------------------------------------*/

Generated on Wed Oct 26 13:08:52 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001