00001 00002 /*--------------------------------------------------------------------------- 00003 * E.S.O. 00004 *--------------------------------------------------------------------------- 00005 * File name : pixel_handling.c 00006 * Author : Nicolas Devillard 00007 * Created on : March 4th, 1997 00008 * Hardware : Sun Sparc 20 00009 * Software : C Language under Solaris Unix 00010 * Description : Functions to handle list of pixels and their use 00011 *--------------------------------------------------------------------------*/ 00012 00013 /* 00014 00015 $Id: pixel_handling.h,v 1.1 2003/09/03 12:50:47 amodigli Exp $ 00016 $Author: amodigli $ 00017 $Date: 2003/09/03 12:50:47 $ 00018 $Revision: 1.1 $ 00019 00020 */ 00021 00022 #ifndef _PIXEL_HANDLING_H_ 00023 #define _PIXEL_HANDLING_H_ 00024 00025 00026 /*--------------------------------------------------------------------------- 00027 * Includes 00028 *--------------------------------------------------------------------------*/ 00029 00030 00031 #include "memory.h" 00032 #include "local_types.h" 00033 #include "image_handling.h" 00034 #include "pixelmaps.h" 00035 #include "median.h" 00036 00037 /*--------------------------------------------------------------------------- 00038 * Function codes 00039 *--------------------------------------------------------------------------*/ 00040 00041 00042 /* only useful for qsort() */ 00043 int 00044 pixel_compare( 00045 const void * pix1, 00046 const void * pix2 00047 ) ; 00048 00049 /*--------------------------------------------------------------------------- 00050 * Function : addPixelToList() 00051 * In : a pixel position, and a pixelvalue 00052 * Out : int value: 0 if OK, or else -1 00053 * Job : append a pixel to a pixel list (linked list) 00054 * Notice : 00055 *--------------------------------------------------------------------------*/ 00056 00057 void addPixelToList( 00058 pixel_list ** plist, 00059 double x, 00060 double y, 00061 pixelvalue val 00062 ) ; 00063 00064 00065 00066 00067 /*--------------------------------------------------------------------------- 00068 * Function : freePixelList() 00069 * In : pixel_list* 00070 * Out : void 00071 * Job : frees memory taken by a pixel_list 00072 * Notice : recursive 00073 *--------------------------------------------------------------------------*/ 00074 00075 void freePixelList(pixel_list *plist) ; 00076 00077 00078 00079 /*--------------------------------------------------------------------------- 00080 * Function : getPixelListFromTextFile() 00081 * In : file name 00082 * Out : newly allocated pixel_list 00083 * Job : read a list of pixels from a file and return a newly 00084 * allocated structure to store them. 00085 * Notice : 00086 *--------------------------------------------------------------------------*/ 00087 00088 /* 00089 * The file format has the following requirements: 00090 * Lines starting with a hash (#) are taken as comments and not read 00091 * Pixels are defined by 3 values: x_position, y_position, and pixelvalue 00092 * and pixels are separated by CR, as in the following example: 00093 * 12 34 98.56 00094 * 100 200 18.6 00095 * 10 356 -1e4 00096 */ 00097 00098 pixel_list *getPixelListFromTextFile(char *filename) ; 00099 00100 00101 00102 00103 /*--------------------------------------------------------------------------- 00104 * Function : writePixelListToTextFile() 00105 * In : pixel_list * 00106 * Out : void 00107 * Job : output a list of pixels to a file 00108 * Notice : 00109 *--------------------------------------------------------------------------*/ 00110 00111 void writePixelListToTextFile( 00112 char *filename, 00113 pixel_list *plist 00114 ) ; 00115 00116 00117 00118 00119 /*--------------------------------------------------------------------------- 00120 * Function : setMapsPixelsFromList() 00121 * In : pixel_map, pixel_list 00122 * Out : the input pixel_map is modified 00123 * Job : set the pixels in pixel_map according to the given list 00124 * Notice : pixelvalues above 0.5 are set to ONE, below to ZERO 00125 *--------------------------------------------------------------------------*/ 00126 00127 void setMapPixelsFromList( 00128 pixel_map *map, 00129 pixel_list *plist 00130 ) ; 00131 00132 00133 00134 /*--------------------------------------------------------------------------- 00135 * Function : setImagePixelsFromList() 00136 * In : OneImage, pixel_list 00137 * Out : the input OneImage is modified 00138 * Job : set the pixels in OneImage according to the given list 00139 * Notice : Pixels are given in FITS coordinates (1,1) at ll corner 00140 *--------------------------------------------------------------------------*/ 00141 00142 void setImagePixelsFromList( 00143 OneImage *ima, 00144 pixel_list *plist 00145 ) ; 00146 00147 00148 /*---------------------------------------------------------------------------- 00149 * Function : pixel_qsort() 00150 * In : pixel array, size of the array 00151 * Out : void 00152 * Job : sort out the array of pixels 00153 * Notice : optimized implementation, unreadable. 00154 * algorithm from Numerical Recipes 00155 *--------------------------------------------------------------------------*/ 00156 00157 void pixel_qsort(pixelvalue *pix_arr, int npix) ; 00158 00159 00160 /*--------------------------------------------------------------------------- 00161 Function : pixel2double_array() 00162 In : allocated array of pixelvalues, number of pixels in array 00163 Out : newly allocated array of doubles converted from input 00164 Job : convert an array from pixelvalue to double 00165 Notice : see also double2pixel_array() 00166 ---------------------------------------------------------------------------*/ 00167 00168 double * pixel2double_array(pixelvalue * arr, int n); 00169 00170 00171 /*--------------------------------------------------------------------------- 00172 Function : double2pixel_array() 00173 In : allocated array of doubles, number of pixels in array 00174 Out : newly allocated array of pixelvalues converted from input 00175 Job : convert an array from double to pixelvalue 00176 Notice : see also pixel2double_array() 00177 ---------------------------------------------------------------------------*/ 00178 00179 pixelvalue * double2pixel_array(double * arr, int n); 00180 00181 /*--------------------------------------------------------------------------*/ 00182 00183 #endif
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001