mkuan_u2.c

00001 /*
00002 *    Copyright (c) 2007. The BATI team. All right reserved.
00003 *
00004 *    This file is part of BATI library.
00005 *
00006 *    BATI library is free software: you can redistribute it and/or modify
00007 *    it under the terms of the GNU General Public License as published by
00008 *    the Free Software Foundation, either version 3 of the License, or
00009 *    (at your option) any later version.
00010 *
00011 *    BATI library  is distributed in the hope that it will be useful,
00012 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 *    GNU General Public License for more details.
00015 *
00016 *    You should have received a copy of the GNU General Public License
00017 *    along with BATI library.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 /* * XX = u1 | u2 | fl : executable filtre de Kuan.\\
00020 Moyenne ponderee entre la valeur de l'intensite du pixel et celle de la moyenne local en fonction 
00021 de la variance locale et de celle du bruit multiplicatif.\\
00022 ATTENTION : le filtrage est effectue sur les images ROS en intensite (module carre). 
00023 Les donnees lues sont supposees etre de l'amplitude (ex : PRI-ESA, fichiers .imw). 
00024 On commence donc par les elever au carre, on filtre et on reprend la racine carree.\\
00025 Entree : image de type XX = u1 | u2 | fl\\
00026 Sortie : image de meme type\\
00027 @name mkuan_XX
00028 @author E. Trouve
00029 @version 1.0 (21/03/2000)
00030 @see lkuan
00031 */
00032 
00033 #include <math.h>
00034 
00035 #include "image.h"
00036 #include "proto2D.h"
00037 #include "radar.h"
00038 
00039 int main(int argc, char *argv[]){
00040   /* images */ 
00041   imau2 im0;
00042   imafl im2, moyint, moycarre;
00043   pixfl tab2[65536];
00044 
00045   /* operateurs */
00046   read_ima_t  rea;
00047   moy2D_t     moy;
00048   moycarre2D_t  moycar;
00049   kuan_t      kuan;
00050   write_ima_t wri;
00051  
00052  /* main : variables et parametres propres au main*/
00053   param par0, *ptp;      /* tete et pointeur pour la chaine de parametres */
00054   int i, j;
00055   double tmpdb;
00056  
00057 /* LECTURE PARAMETRES */
00058   param_debut(argc, argv, &par0); 
00059   ptp = &par0;
00060   ptp = read_ima_lect(&rea, ptp, ">> image initiale (u2) :");
00061   ptp = kuan_lect(&kuan, ptp, "Kuan :");
00062   moy.dimX = kuan.dimX; moycar.dimX = kuan.dimX;
00063   moy.dimY = kuan.dimY; moycar.dimY = kuan.dimY;
00064   ptp = write_ima_lect(&wri, ptp, ">> image resultat (u2) :");
00065   param_fin(argc, argv, &par0);
00066 
00067 /* INITIALISATION  */
00068   read_imau2_init(&rea, &im0);
00069   /* passage en intensite */
00070   im2.nc = im0.nc;
00071   im2.nr = im0.nr;
00072   alloc_imafl(&im2);
00073   for(j=0; j<65536; j++)
00074       tab2[j] = (pixfl)j*(pixfl)j;
00075   for(j=0; j<im0.nr; j++)
00076       for(i=0; i<im0.nc; i++)
00077           im2.p[j][i] = tab2[im0.p[j][i]];
00078   moy2Dfl_init(&moy, im2, &moyint);
00079   moycarre2Dfl_init(&moycar, im2, &moycarre);
00080   /* pas de kuanu2_init, calcul sur place */; 
00081   write_ima_init(&wri);
00082  
00083 /* CALCUL */
00084   moy2Dfl_calc(&moy, im2, &moyint);
00085   moycarre2Dfl_calc(&moycar, im2, &moycarre);
00086   kuanfl_calc(&kuan, im2, moyint, moycarre, &im2);
00087   /* retour en amplitude */
00088   for(j=0; j<im0.nr; j++)
00089       for(i=0; i<im0.nc; i++){
00090           tmpdb = sqrt((double)im2.p[j][i]) +0.5;
00091           if( tmpdb < 65536. )
00092               im0.p[j][i] = (pixu2)tmpdb;
00093           else
00094               im0.p[j][i] = 65535;
00095       }
00096 /* FREMETURE */
00097   write_imau2_ferm(&wri, im0);
00098 }
00099 
00100 
00101 

Generated on Tue Apr 22 13:31:04 2008 for ima2D by  doxygen 1.5.3