generate.h

00001 
00002 /*----------------------------------------------------------------------------
00003  *                                  E.S.O.
00004  *----------------------------------------------------------------------------
00005  * File name    :   generate.h
00006  * Author       :   Nicolas Devillard
00007  * Created on   :   Sept 28, 1995
00008  * Hardware     :   Sun Sparc 20
00009  * Software     :   ANSI C under Solaris Unix
00010  *                  Part of ECLIPSE library for Adonis
00011  * Description  :   pattern image generation
00012  *--------------------------------------------------------------------------*/
00013 
00014 /*
00015 
00016  $Id: generate.h,v 1.1 2003/09/03 12:50:47 amodigli Exp $
00017  $Author: amodigli $
00018  $Date: 2003/09/03 12:50:47 $
00019  $Revision: 1.1 $
00020 
00021  */
00022 
00023 #ifndef _GENERATE_H_
00024 #define _GENERATE_H_
00025 
00026 
00027 /*----------------------------------------------------------------------------
00028  *                              Includes
00029  *--------------------------------------------------------------------------*/
00030 
00031 #include <math.h>
00032 #include <stdlib.h>
00033 #include <unistd.h>
00034 
00035 #include "memory.h"
00036 #include "cube_defs.h"
00037 #include "image_handling.h"
00038 #include "fit_curve.h"
00039 #include "fourier.h"
00040 #include "image_arith.h"
00041 #include "pixelmaps.h"
00042 #include "random_numbers.h"
00043 
00044 
00045 /*----------------------------------------------------------------------------
00046  *                      Function ANSI C prototypes
00047  *--------------------------------------------------------------------------*/
00048 
00049 
00050 /*----------------------------------------------------------------------------
00051  * Function :   generate_airy_pattern()
00052  * In       :   image size, max pixelvalue, airy size, pattern center
00053  * Out      :   1 image
00054  * Job      :   generate an image containing an airy pattern
00055  * Notice   :   max_pix is the highest possible pixelvalue in the
00056  *              generated image, airy_size is the diameter (in pixels)
00057  *              of the main lobe in the Airy pattern, the pattern is
00058  *              centered in the image where specified.
00059  *--------------------------------------------------------------------------*/
00060 
00061 OneImage    *
00062 generate_airy_pattern(
00063     int         lx,
00064     int         ly,
00065     double      center_x,
00066     double      center_y,
00067     pixelvalue  max_pix,
00068     double      airy_size
00069 ) ;
00070 
00071 
00072 
00073 /*----------------------------------------------------------------------------
00074  * Function :   airy_2d()
00075  * In       :   x, y, max_pix, airy_size
00076  * Out      :   double
00077  * Job      :   compute the value of a 2d Airy function at point x,y
00078  *              with parameters max_pix and airy_size
00079  * Notice   :
00080  *--------------------------------------------------------------------------*/
00081 
00082 double  
00083 airy_2d(
00084     double  x,
00085     double  y,
00086     double  max_pix,
00087     double  airy_size
00088 ) ;
00089 
00090 
00091 
00092 /*----------------------------------------------------------------------------
00093  * Function :   generate_gaussian_pattern()
00094  * In       :   image size, center of distribution, sigma
00095  * Out      :   1 image
00096  * Job      :   generate an image of a 2d gaussian
00097  * Notice   :
00098  *--------------------------------------------------------------------------*/
00099 
00100 
00101 OneImage    *
00102 generate_gaussian_pattern(
00103     int         lx,
00104     int         ly,
00105     double      center_x,
00106     double      center_y,
00107     double      sigma
00108 ) ;
00109 
00110 
00111 /*----------------------------------------------------------------------------
00112  * Function :   generate_lorentzian_pattern()
00113  * In       :   image size, center position, intensity, dispersion 
00114  * Out      :   1 image
00115  * Job      :   generate an image of a lorentzian pattern of given
00116  *              intensity and dispersion
00117  * Notice   :
00118  *--------------------------------------------------------------------------*/
00119 
00120 OneImage *
00121 generate_lorentzian_pattern( 
00122      int lx, 
00123      int ly,
00124      double center_x,
00125      double center_y,
00126      double intensity,
00127      double dispersion
00128 ) ; 
00129 
00130 
00131 
00132 /*----------------------------------------------------------------------------
00133  * Function :   lorentzian_2d()
00134  * In       :   x, y, intensity, dispersion
00135  * Out      :   double 
00136  * Job      :   compute the value of a lorentzian function at point x,y
00137  *              relative to the center of the distribution, with given
00138  *              intensity and dispersion factors.
00139  * Notice   :
00140  *--------------------------------------------------------------------------*/
00141 
00142 double  lorentzian_2d(
00143     double  x,
00144     double  y,
00145     double  intensity,
00146     double  dispersion
00147 ) ; 
00148 
00149 
00150 /*----------------------------------------------------------------------------
00151  * Function :   gaussian_2d()
00152  * In       :   x, y, sigma
00153  * Out      :   double
00154  * Job      :   compute the value at x,y of a gaussian distribution of
00155  *              given standard deviation sigma, x and y are given
00156  *              relatively to the distribution peak.
00157  * Notice   :
00158  *--------------------------------------------------------------------------*/
00159 
00160 double  
00161 gaussian_2d(
00162     double  x,
00163     double  y,
00164     double  sigma
00165 ) ;
00166 
00167 
00168 /*----------------------------------------------------------------------------
00169  * Function :   generate_random_uniform()
00170  * In       :   image size, min and max pixelvalue
00171  * Out      :   1 image
00172  * Job      :   generate an image with a uniform random noise distribution
00173  * Notice   :
00174  *--------------------------------------------------------------------------*/
00175 
00176 OneImage *
00177 generate_random_uniform(
00178     int         lx,
00179     int         ly,
00180     pixelvalue  min_pix,
00181     pixelvalue  max_pix
00182 ) ;
00183 
00184 
00185 
00186 
00187 /*----------------------------------------------------------------------------
00188  * Function :   generate_random_gauss()
00189  * In       :   sigma and mean of the probability density distribution
00190  *              size of the image to create
00191  * Out      :   newly allocated image
00192  * Job      :   create an image containing noise with a gaussian probability
00193  *              density distribution, of given mean and sigma.
00194  * Notice   :   to get the default sigma (1/sqrt(2)), give a negative value
00195  *              no default mean value is provided
00196  *--------------------------------------------------------------------------*/
00197 
00198 OneImage *
00199 generate_random_gauss(
00200     ulong32     size_x,
00201     ulong32     size_y,
00202     double      sigma,
00203     double      mean
00204 ) ;
00205 
00206 
00207 /*----------------------------------------------------------------------------
00208  * Function :   generate_random_lorentz()
00209  * In       :   dispersion of the probability density distribution
00210  *              size of the image to create
00211  * Out      :   newly allocated image
00212  * Job      :   create an image containing noise with a lorentzian probability
00213  *              density distribution, of given dispersion.
00214  * Notice   :   to get the default dispersion (1.0), give a negative value
00215  *              no default mean value is provided
00216  *--------------------------------------------------------------------------*/
00217 
00218 OneImage *
00219 generate_random_lorentz(
00220     ulong32     size_x,
00221     ulong32     size_y,
00222     double      dispersion,
00223     double      mean
00224 ) ;
00225 
00226 
00227 
00228 /*----------------------------------------------------------------------------
00229  * Function :   generate_otf()
00230  * In       :   telescope and observational parameters (see list below)
00231  * Out      :   1 image
00232  * Job      :   generate an image of an ideal Optical Transfer Function
00233  *              for a given configuration.
00234  * Notice   :   Output is in IEEE 32 bit double format
00235  *              Code from otf_theo.c by F. Rigault and JL Beuzit
00236  *              the code was strongly modified to be inserted here
00237  *              To use a default value, pass -1.0. Default values are set
00238  *              for the 3.6m ESO telescope in la Silla.
00239  *--------------------------------------------------------------------------*/
00240 
00241 /*
00242  * Generates a theoretical OTF for the following given parameters:
00243  * - telescope diameter
00244  * - obstruction ratio
00245  * - detector size (number of pixels)
00246  * - pixel scale (on the sky)
00247  * - filter (central wavelength and bandwith)
00248  * 
00249  * Based on the paper "Amplitude estimation from speckle
00250  * interferometry" by Christian Perrier in "Diffraction-limited
00251  * imaging with very large telescopes", NATO ASI Series C,
00252  * Vol. 274, edited by D. Alloin and J.-M. Mariotti, 1989 (p. 99).
00253  */
00254 
00255 OneImage *
00256 generate_otf(
00257     double   primary_diameter,   /* telescope mirror (meters)   */
00258     double   secondary_diameter, /* telescope mirror (meters)   */
00259     double   lambda0,    /* central wavelength of observation (microns)  */
00260     double   dlambda,    /* filter bandwith (microns)                    */
00261     ulong32  size,       /* image size (image is square)                 */
00262     double   pixel_scale    /* pixel scale on the sky (arcseconds)       */
00263 ) ;
00264 
00265 
00266 
00267 /*----------------------------------------------------------------------------
00268  * Function :   generate_psf()
00269  * In       :   primary mirror diameter in meters
00270  *              secondary mirror diameter in meters
00271  *              central observation wavelength
00272  *              filter width
00273  *              pixel scale on the sky in arcseconds
00274  *              image size (image is square)
00275  * Out      :   1 image
00276  * Job      :   compute an ideal PSF
00277  * Notice   :   normalized to unity flux
00278  *              Mostly used to compute Strehl ratios
00279  *--------------------------------------------------------------------------*/
00280 
00281 OneImage    *
00282 generate_psf(
00283     double   primary,
00284     double   secondary,
00285     double   lambda0,
00286     double   dlambda,
00287     double   pixel_scale,
00288     ulong32 image_size
00289 ) ;
00290 
00291 
00292 
00293 /*----------------------------------------------------------------------------
00294  * Function :   generate_binary_disk()
00295  * In       :   disk center, radius, image size
00296  * Out      :   1 newly allocated pixel_map
00297  * Job      :   create a pixel_map containing a white disk (1) over a
00298  *              black (0) background
00299  * Notice   :   disk center coordinates a la FITS: first pixel is (1,1)
00300  *              in lower left corner, last pixel (lx,ly) in upper right
00301  *              corner.
00302  *--------------------------------------------------------------------------*/
00303 
00304 pixel_map *
00305 generate_binary_disk(
00306     ulong32     size_x,
00307     ulong32     size_y,
00308     double       center_x,
00309     double       center_y,
00310     double       radius
00311 ) ;
00312 
00313 
00314 
00315 /*----------------------------------------------------------------------------
00316  * Function :   generate_binary_rectangle()
00317  * In       :   image size, rectangle lower left and upper right corner
00318  * Out      :   1 newly created pixel_map
00319  * Job      :   creates a white (1) rectangle over a black (0) background
00320  * Notice   :   coordinates a la FITS: first pixel is (1,1)
00321  *              in lower left corner, last pixel (lx,ly) in upper right
00322  *              corner.
00323  *--------------------------------------------------------------------------*/
00324 
00325 pixel_map *
00326 generate_binary_rectangle(
00327     ulong32     size_x,
00328     ulong32     size_y,
00329     ulong32     llx,
00330     ulong32     lly,
00331     ulong32     urx,
00332     ulong32     ury
00333 ) ;
00334 
00335 
00336 
00337 /*---------------------------------------------------------------------------
00338    Function :   generate_2d_poly_image()
00339    In       :   pointer to 6 coefficients, image size
00340    Out      :   newly allocated image
00341    Job      :   create an image from a 2-degree polynomial in (x,y)
00342    Notice   :   the coordinate system for the polynomial is the FITS
00343                 one, i.e. (1,1) is the lower left pixel, x-axis
00344                 increasing from left to right, y-axis from bottom to
00345                 top. Coefficients must be stored as:
00346 
00347                 c[0] for x^2
00348                 c[1] for y^2
00349                 c[2] for x.y
00350                 c[3] for x
00351                 c[4] for y
00352                 c[5] for 1
00353 
00354  ---------------------------------------------------------------------------*/
00355 
00356 OneImage *
00357 generate_2d_poly_image(
00358     int         lx,
00359     int         ly,
00360     double  *   c
00361 ) ;
00362 
00363 
00364 /*---------------------------------------------------------------------------
00365    Function :   generate_polynomial_image()
00366    In       :   a polynomial definition and the image size 
00367    Out      :   1 image
00368    Job      :   generate an image of a polynomial in x and y
00369     Notice  :   A polynomial is defined by a string, a list of
00370                 coefficients and the # of coeffs in the list.
00371                 The string defining the polynomial is similar as the one
00372                 used by fitting functions (see fit_curve.h).
00373  ---------------------------------------------------------------------------*/
00374 
00375 OneImage * generate_polynomial_image(
00376     int         lx,
00377     int         ly,
00378     double  *   c,
00379     int         nc,
00380     int         poly_deg,
00381     char    *   poly_string
00382 ) ;
00383 
00384 
00385 /*---------------------------------------------------------------------------
00386    Function :   generate_polynomial_double_image()
00387    In       :   a polynomial definition and the image size 
00388    Out      :   1 image
00389    Job      :   generate an image of a polynomial in x and y
00390     Notice  :   A polynomial is defined by a string, a list of
00391                 coefficients and the # of coeffs in the list.
00392                 The string defining the polynomial is similar as the one
00393                 used by fitting functions (see fit_curve.h).
00394                 The generated image is an array of doubles, this
00395                 function should only be needed when float pixels do
00396                 not have enough resolution to retain numeric
00397                 precision.
00398                 The returned image is normalized so that it has a mean
00399                 value of 1.0.
00400  ---------------------------------------------------------------------------*/
00401 
00402 double * generate_polynomial_double_image(
00403     int         lx,
00404     int         ly,
00405     double  *   c,
00406     int         nc,
00407     int         poly_deg,
00408     char    *   poly_string
00409 );
00410 
00411 
00412 /*--------------------------------------------------------------------------
00413    Function :   fillrect_in_image()
00414    In       :   image
00415                 coordinates of rectangular zone to fill
00416                 value to fill with
00417    Out      :   the (destructively) modified image
00418                 -1 if not OK
00419    Job      :    
00420    Notice   :   C-style coordinates. i.e top,left=0,0   
00421  -------------------------------------------------------------------------*/
00422 int fillrect_in_image(OneImage *in, pixelvalue val,
00423         int left,int right,int top,int bottom);
00424 
00425 
00426 
00427 /*---------------------------------------------------------------------------
00428    Function :   generate_polygon_pixmap()
00429    In       :   polygon definition, size of the image to generate,
00430                 pval is 0 or 1, it is the value to assign to pixels
00431                 inside the polygon, !pval will be assigned to pixels
00432                 outside the polygon.
00433    Out      :   a newly created image
00434    Job      :   create a binary image, containing a polygon
00435    Notice   :   Polygon point coordinates are given in [0,lx-1]x[0,ly-1]
00436  ---------------------------------------------------------------------------*/
00437 
00438 pixel_map *
00439 generate_polygon_in_image(
00440     int         lx,
00441     int         ly,
00442     dpoint  *   polygon,
00443     int         np,
00444     int         pval
00445 );
00446 
00447 
00448 
00449 #endif
00450 /*--------------------------------------------------------------------------*/
00451 

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