| [658] | 1 | //  Classes image typee | 
|---|
|  | 2 | //                    E.Aubourg , E. Lesquoy  01-03/95 | 
|---|
|  | 3 | //                    Modifs R. Ansari   04/95 | 
|---|
|  | 4 |  | 
|---|
|  | 5 | // LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA | 
|---|
|  | 6 |  | 
|---|
|  | 7 | // $Id: cimage.cc,v 1.1.1.1 1999-11-26 16:37:09 ansari Exp $ | 
|---|
|  | 8 |  | 
|---|
|  | 9 |  | 
|---|
|  | 10 | #include "machdefs.h" | 
|---|
|  | 11 | #include <string.h> | 
|---|
|  | 12 | #include <stdio.h> | 
|---|
|  | 13 |  | 
|---|
|  | 14 | #include "perrors.h" | 
|---|
|  | 15 | #include "cimage.h" | 
|---|
|  | 16 | #include "fct1dfit.h" | 
|---|
|  | 17 | #include "histos.h" | 
|---|
|  | 18 | #include "nbconst.h" | 
|---|
|  | 19 | #include "utils.h" | 
|---|
|  | 20 |  | 
|---|
|  | 21 | /* ..............   Classe  Image<T>    ...............   */ | 
|---|
|  | 22 |  | 
|---|
|  | 23 | //++ | 
|---|
|  | 24 | // Class        Image<T> | 
|---|
|  | 25 | // Lib          Images++ | 
|---|
|  | 26 | // include      cimage.h | 
|---|
|  | 27 | // | 
|---|
|  | 28 | // | 
|---|
|  | 29 | //      Classe descendant (heritier) de la classe *RzImage*, permettant | 
|---|
|  | 30 | //      l'instantiation d'objets image avec un typage fort (entier, reel, ...) | 
|---|
|  | 31 | // | 
|---|
|  | 32 | //      Des objets de type "Image<uint_1>, Image<uint_2>, Image<int_2>, Image<int_4>" | 
|---|
|  | 33 | //      (entier) et "Image<r_4>" (flottant) peuvent etre crees. | 
|---|
|  | 34 | //      Des typedef (*ImageU1*, *ImageU2*, *ImageI2*, *ImageI4*, *ImageR4*) | 
|---|
|  | 35 | //      facilite l'utilisation de ces classes. | 
|---|
|  | 36 | //-- | 
|---|
|  | 37 | //++ | 
|---|
|  | 38 | // Links        Parents | 
|---|
|  | 39 | // RzImage | 
|---|
|  | 40 | //-- | 
|---|
|  | 41 | //++ | 
|---|
|  | 42 | // Links        Descendants | 
|---|
|  | 43 | // FitsImage<T> | 
|---|
|  | 44 | //-- | 
|---|
|  | 45 | //++ | 
|---|
|  | 46 | // Links        Voir aussi | 
|---|
|  | 47 | // DVList | 
|---|
|  | 48 | //-- | 
|---|
|  | 49 |  | 
|---|
|  | 50 | //++ | 
|---|
|  | 51 | // Titre        Constructeurs | 
|---|
|  | 52 | //-- | 
|---|
|  | 53 |  | 
|---|
|  | 54 | //++ | 
|---|
|  | 55 | // Image<T>(int sizx, sizy, int zero) | 
|---|
|  | 56 | //      Creation d'une image de type "T", de taille "sizx*sizy" pixels. | 
|---|
|  | 57 | //      Si "zero" non nul, tous les pixels de l'image sont mis a zero. | 
|---|
|  | 58 | // Image<T>(char* flnm) | 
|---|
|  | 59 | //      Cree une image a partir du fichier "flnm". Celui-ci doit etre | 
|---|
|  | 60 | //      au format "PPF" et cree par la methode "Save() ou "Write()". | 
|---|
|  | 61 | //-- | 
|---|
|  | 62 |  | 
|---|
|  | 63 | template <class T> | 
|---|
|  | 64 | Image<T>::Image(int sizx, int sizy, int zero) | 
|---|
|  | 65 | : RzImage(DataType((T)0), sizx, sizy), imagePtr( (T*) voidP ) | 
|---|
|  | 66 | { | 
|---|
|  | 67 | if (zero) Zero(); | 
|---|
|  | 68 | END_CONSTRUCTOR | 
|---|
|  | 69 | } | 
|---|
|  | 70 |  | 
|---|
|  | 71 | /* --Methode-- */ | 
|---|
|  | 72 | template <class T> | 
|---|
|  | 73 | Image<T>::Image() | 
|---|
|  | 74 | : RzImage(DataType((T)0)), imagePtr(0) | 
|---|
|  | 75 | { | 
|---|
|  | 76 | END_CONSTRUCTOR | 
|---|
|  | 77 | } | 
|---|
|  | 78 |  | 
|---|
|  | 79 |  | 
|---|
|  | 80 | /* --Methode-- */ | 
|---|
|  | 81 | template <class T> | 
|---|
|  | 82 | void Image<T>::Allocate(int sizx, int sizy, int zero, ImgVectP* pvpsh) | 
|---|
|  | 83 | { | 
|---|
|  | 84 | RzImage::Allocate(DataType((T)0), sizx, sizy, pvpsh); | 
|---|
|  | 85 | imagePtr = (T*) voidP; | 
|---|
|  | 86 | if (!imagePtr) THROW(allocationErr); | 
|---|
|  | 87 | if (zero) Zero(); | 
|---|
|  | 88 | } | 
|---|
|  | 89 |  | 
|---|
|  | 90 | template <class T> | 
|---|
|  | 91 | void Image<T>::SetPixels(int szx, int szy, T* pim) | 
|---|
|  | 92 | { | 
|---|
|  | 93 | RzImage::SetPixels(DataType((T)0), szx, szy, pim); | 
|---|
|  | 94 | imagePtr = pim; | 
|---|
|  | 95 | } | 
|---|
|  | 96 |  | 
|---|
|  | 97 | /* --Methode-- */ | 
|---|
|  | 98 | template <class T> | 
|---|
|  | 99 | Image<T>::~Image() | 
|---|
|  | 100 | {} | 
|---|
|  | 101 |  | 
|---|
|  | 102 |  | 
|---|
|  | 103 | //++ | 
|---|
|  | 104 | // Image<T>(const Image<T>& src, int sharePixels) | 
|---|
|  | 105 | //      Constructeur par copie. Fabrique une image identique a l'image "src". | 
|---|
|  | 106 | //      Si "sharePixels" est non nul, le tableau des pixels est commun | 
|---|
|  | 107 | //      aux deux images ("src" et celle creee) | 
|---|
|  | 108 | // Image<T>(const Image<T>& src, int orgx, int orgy, int sizx, int sizy) | 
|---|
|  | 109 | //      Construit une image de type "T", a partir des pixels de l'image | 
|---|
|  | 110 | //      "src" (du meme type), de taille "sizx*sizy" et de l'origine | 
|---|
|  | 111 | //      "orgx, orgy" dans "src". Si "orgx" et/ou "orgy" sont negatifs, | 
|---|
|  | 112 | //      la taille de la nouvelle image est automatiquement calculee | 
|---|
|  | 113 | //      pour contenir toute l'image source a partir de l'origine specifiee. | 
|---|
|  | 114 | //      Genere l'exception "sizeMismatchErr" en cas d'incompatibilite | 
|---|
|  | 115 | //      taille/origine. | 
|---|
|  | 116 | //-- | 
|---|
|  | 117 |  | 
|---|
|  | 118 | /* --Methode-- */ | 
|---|
|  | 119 | template <class T> | 
|---|
|  | 120 | Image<T>::Image(const Image<T>& src, int sharePixels) | 
|---|
|  | 121 | : RzImage(src, sharePixels) | 
|---|
|  | 122 | { | 
|---|
|  | 123 | imagePtr = (T*) voidP; | 
|---|
|  | 124 | if (!imagePtr) THROW(allocationErr); | 
|---|
|  | 125 | END_CONSTRUCTOR | 
|---|
|  | 126 | } | 
|---|
|  | 127 |  | 
|---|
|  | 128 | /* --Methode-- */ | 
|---|
|  | 129 | template <class T> | 
|---|
|  | 130 | Image<T>::Image(const Image<T>& src, int orgx, int orgy, int sizx, int sizy) | 
|---|
|  | 131 | :RzImage() | 
|---|
|  | 132 | { | 
|---|
|  | 133 | // A optimiser... | 
|---|
|  | 134 | if (sizx < 0) sizx = src.XSize()-orgx; | 
|---|
|  | 135 | if (sizy < 0) sizy = src.YSize()-orgy; | 
|---|
|  | 136 | if (orgx+sizx > src.XSize() || orgy+sizy > src.YSize()) | 
|---|
|  | 137 | THROW(sizeMismatchErr); | 
|---|
|  | 138 |  | 
|---|
|  | 139 | Allocate(sizx, sizy); | 
|---|
|  | 140 | for (int i=0; i<sizx; i++) | 
|---|
|  | 141 | for (int j=0; j<sizy; j++) | 
|---|
|  | 142 | (*this)(i,j) = src(i+orgx, j+orgy); | 
|---|
|  | 143 |  | 
|---|
|  | 144 | SetOrg(src.XOrg()+orgx, src.YOrg()+orgy); | 
|---|
|  | 145 | SetPxSize(src.XPxSize(), src.YPxSize()); | 
|---|
|  | 146 | END_CONSTRUCTOR | 
|---|
|  | 147 | } | 
|---|
|  | 148 |  | 
|---|
|  | 149 | //++ | 
|---|
|  | 150 | // LaTeX        Pour contrer un mauvais espacement des paragraphes de LaTeX | 
|---|
|  | 151 | // \newpage | 
|---|
|  | 152 | //-- | 
|---|
|  | 153 | //++ | 
|---|
|  | 154 | // Image<T>() | 
|---|
|  | 155 | //      Creation d'une image de type "T" sans allocation du tableau des pixels. | 
|---|
|  | 156 | //      Le tableau des pixels devra etre ensuite alloue par la methode "Allocate()" | 
|---|
|  | 157 | //-- | 
|---|
|  | 158 |  | 
|---|
|  | 159 | //++ | 
|---|
|  | 160 | // Image<T>(const RzImage& rzimg) | 
|---|
|  | 161 | //      Permet de construire une image typee a partir d'une RzImage ("rzimg") | 
|---|
|  | 162 | //      Le tableau des pixels est commun aux deux images. | 
|---|
|  | 163 | //      Les pixels de l'image "rzimg" doivent etre du type "T", sinon | 
|---|
|  | 164 | //      l'exception "typeMismatchErr" est generee. | 
|---|
|  | 165 | //-- | 
|---|
|  | 166 | /* --Methode-- */ | 
|---|
|  | 167 | template <class T> | 
|---|
|  | 168 | Image<T>::Image(const RzImage& rzimg) | 
|---|
|  | 169 | :RzImage(rzimg,1) | 
|---|
|  | 170 | { | 
|---|
|  | 171 |  | 
|---|
|  | 172 | if (rzimg.PixelType() != DataType((T)0)) | 
|---|
|  | 173 | THROW(typeMismatchErr); | 
|---|
|  | 174 | imagePtr = (T*) voidP; | 
|---|
|  | 175 | if (!imagePtr) THROW(allocationErr); | 
|---|
|  | 176 |  | 
|---|
|  | 177 | END_CONSTRUCTOR | 
|---|
|  | 178 | } | 
|---|
|  | 179 |  | 
|---|
|  | 180 | //++ | 
|---|
|  | 181 | // void Allocate(int sizx, int sizy, int zero=1, ImgVectP* pvpsh=NULL) | 
|---|
|  | 182 | //      Alloue le tableau des pixels. | 
|---|
|  | 183 | //-- | 
|---|
|  | 184 | //++ | 
|---|
|  | 185 | // ~Image<T> | 
|---|
|  | 186 | //      Destructeur. supprime le tableau des pixels en memoire si celui-ci | 
|---|
|  | 187 | //      n'est pas utilise par d'autres objets image. | 
|---|
|  | 188 | //-- | 
|---|
|  | 189 |  | 
|---|
|  | 190 | /* --Methode-- */ | 
|---|
|  | 191 | template <class T> | 
|---|
|  | 192 | Image<T>::Image(char *flnm) | 
|---|
|  | 193 | :RzImage(flnm) | 
|---|
|  | 194 | { | 
|---|
|  | 195 | imagePtr = (T*) voidP; | 
|---|
|  | 196 | if (!imagePtr) THROW(allocationErr); | 
|---|
|  | 197 |  | 
|---|
|  | 198 | END_CONSTRUCTOR | 
|---|
|  | 199 | } | 
|---|
|  | 200 |  | 
|---|
|  | 201 |  | 
|---|
|  | 202 | /* --Methode-- */ | 
|---|
|  | 203 | template <class T> | 
|---|
|  | 204 | void  Image<T>::ReadSelf(PInPersist& s) | 
|---|
|  | 205 | { | 
|---|
|  | 206 | RzImage::ReadSelf(s); | 
|---|
|  | 207 | imagePtr = (T*) voidP; | 
|---|
|  | 208 | } | 
|---|
|  | 209 |  | 
|---|
|  | 210 | //++ | 
|---|
|  | 211 | // Titre        Operateurs | 
|---|
|  | 212 | //      Un grand nombre des operations pouvant etre effectuees sur un | 
|---|
|  | 213 | //      tableau de nombre ont ete defini pour les objets "Image<T>" | 
|---|
|  | 214 | //      Dans les operations faisant intervenir deux images, l'exception | 
|---|
|  | 215 | //      "sizeMismatchErr" est generee si les tailles (en X ou en Y) des | 
|---|
|  | 216 | //      deux images ne sont pas identiques. | 
|---|
|  | 217 | //-- | 
|---|
|  | 218 |  | 
|---|
|  | 219 | //++ | 
|---|
|  | 220 | // Image<T>& operator= (const Image<T>& rhs) | 
|---|
|  | 221 | //      Copie le contenu (valeurs des pixels) de l'image "rhs". | 
|---|
|  | 222 | //      Si l'image destination (membre gauche de =) n'a pas son | 
|---|
|  | 223 | //      tableau de pixels alloue, celui-ci est cree a une taille | 
|---|
|  | 224 | //      identique a celle de "rhs" | 
|---|
|  | 225 | // Image<T>& operator= (T val) | 
|---|
|  | 226 | //      Met tous les pixels de l'image a la valeur "val" | 
|---|
|  | 227 | //-- | 
|---|
|  | 228 |  | 
|---|
|  | 229 | /* --Methode-- */ | 
|---|
|  | 230 | template <class T> | 
|---|
|  | 231 | Image<T>& Image<T>::operator = (const Image<T>& src) | 
|---|
|  | 232 | { | 
|---|
|  | 233 | if (imagePtr) { | 
|---|
|  | 234 | if (siz_x != src.siz_x || siz_y != src.siz_y) | 
|---|
|  | 235 | THROW(sizeMismatchErr); | 
|---|
|  | 236 | } else | 
|---|
|  | 237 | Allocate(src.siz_x, src.siz_y); | 
|---|
|  | 238 |  | 
|---|
|  | 239 | (RzImage)(*this) = (RzImage)src; | 
|---|
|  | 240 | return *this; | 
|---|
|  | 241 | } | 
|---|
|  | 242 |  | 
|---|
|  | 243 | /* --Methode-- */ | 
|---|
|  | 244 | template <class T> | 
|---|
|  | 245 | Image<T>& Image<T>::operator = (T a) | 
|---|
|  | 246 | { | 
|---|
|  | 247 | T* pDst = imagePtr; | 
|---|
|  | 248 | int nPix = siz_x * siz_y; | 
|---|
|  | 249 |  | 
|---|
|  | 250 | for (int i=0; i<nPix; i++, pDst++) | 
|---|
|  | 251 | *pDst = a; | 
|---|
|  | 252 |  | 
|---|
|  | 253 | return *this; | 
|---|
|  | 254 | } | 
|---|
|  | 255 |  | 
|---|
|  | 256 | /* --Methode-- */ | 
|---|
|  | 257 | template <class T> | 
|---|
|  | 258 | void Image<T>::Zero() | 
|---|
|  | 259 | { | 
|---|
|  | 260 | memset(imagePtr,0,siz_x * siz_y * sizeof(T)); | 
|---|
|  | 261 | } | 
|---|
|  | 262 |  | 
|---|
|  | 263 | /* --Methode-- */ | 
|---|
|  | 264 | #if 0 // a la mort de RzImage | 
|---|
|  | 265 | template <class T> | 
|---|
|  | 266 | void Image<T>::Clear() | 
|---|
|  | 267 | { | 
|---|
|  | 268 | if (imagePtr) { | 
|---|
|  | 269 | delete[] imagePtr; | 
|---|
|  | 270 | imagePtr = 0; | 
|---|
|  | 271 | siz_x = 0; | 
|---|
|  | 272 | siz_y = 0; | 
|---|
|  | 273 | } | 
|---|
|  | 274 | } | 
|---|
|  | 275 | #endif | 
|---|
|  | 276 |  | 
|---|
|  | 277 | /* --Methode-- */ | 
|---|
|  | 278 | template <class T> | 
|---|
|  | 279 | Image<T>& Image<T>::operator+= (Image<T> const& a) | 
|---|
|  | 280 | { | 
|---|
|  | 281 | if (siz_x != a.siz_x || siz_y != a.siz_y) | 
|---|
|  | 282 | THROW(sizeMismatchErr); | 
|---|
|  | 283 | T* pSrc = a.imagePtr; | 
|---|
|  | 284 | T* pDst = imagePtr; | 
|---|
|  | 285 | int nPix = siz_x * siz_y; | 
|---|
|  | 286 |  | 
|---|
|  | 287 | for (int i=0; i<nPix; i++, pSrc++, pDst++) | 
|---|
|  | 288 | *pDst = PutInRange((double)*pSrc + (double)*pDst, *pDst); | 
|---|
|  | 289 |  | 
|---|
|  | 290 | return *this; | 
|---|
|  | 291 | } | 
|---|
|  | 292 |  | 
|---|
|  | 293 |  | 
|---|
|  | 294 | /* --Methode-- */ | 
|---|
|  | 295 | template <class T> | 
|---|
|  | 296 | Image<T>& Image<T>::operator-= (Image<T> const& a) | 
|---|
|  | 297 | { | 
|---|
|  | 298 | if (siz_x != a.siz_x || siz_y != a.siz_y) | 
|---|
|  | 299 | THROW(sizeMismatchErr); | 
|---|
|  | 300 | T* pSrc = a.imagePtr; | 
|---|
|  | 301 | T* pDst = imagePtr; | 
|---|
|  | 302 | int nPix = siz_x * siz_y; | 
|---|
|  | 303 |  | 
|---|
|  | 304 | for (int i=0; i<nPix; i++, pSrc++, pDst++) | 
|---|
|  | 305 | *pDst = PutInRange((double)*pDst - (double)*pSrc, *pDst); | 
|---|
|  | 306 |  | 
|---|
|  | 307 | return *this; | 
|---|
|  | 308 | } | 
|---|
|  | 309 |  | 
|---|
|  | 310 | /* --Methode-- */ | 
|---|
|  | 311 | template <class T> | 
|---|
|  | 312 | Image<T>& Image<T>::operator*= (Image<T> const& a) | 
|---|
|  | 313 | { | 
|---|
|  | 314 | if (siz_x != a.siz_x || siz_y != a.siz_y) | 
|---|
|  | 315 | THROW(sizeMismatchErr); | 
|---|
|  | 316 | T* pSrc = a.imagePtr; | 
|---|
|  | 317 | T* pDst = imagePtr; | 
|---|
|  | 318 | int nPix = siz_x * siz_y; | 
|---|
|  | 319 |  | 
|---|
|  | 320 | for (int i=0; i<nPix; i++, pSrc++, pDst++) | 
|---|
|  | 321 | *pDst = PutInRange((double)*pDst * (double)*pSrc, *pDst); | 
|---|
|  | 322 |  | 
|---|
|  | 323 | return *this; | 
|---|
|  | 324 | } | 
|---|
|  | 325 |  | 
|---|
|  | 326 | /* --Methode-- */ | 
|---|
|  | 327 | template <class T> | 
|---|
|  | 328 | Image<T>& Image<T>::operator/= (Image<T> const& a) | 
|---|
|  | 329 | { | 
|---|
|  | 330 | if (siz_x != a.siz_x || siz_y != a.siz_y) | 
|---|
|  | 331 | THROW(sizeMismatchErr); | 
|---|
|  | 332 | T* pSrc = a.imagePtr; | 
|---|
|  | 333 | T* pDst = imagePtr; | 
|---|
|  | 334 | int nPix = siz_x * siz_y; | 
|---|
|  | 335 |  | 
|---|
|  | 336 | for (int i=0; i<nPix; i++, pSrc++, pDst++) | 
|---|
|  | 337 | if (*pSrc) | 
|---|
|  | 338 | *pDst = PutInRange((double)*pDst / (double)*pSrc, *pDst); | 
|---|
|  | 339 | else *pDst = (T) MaxRange(*pDst); | 
|---|
|  | 340 |  | 
|---|
|  | 341 | return *this; | 
|---|
|  | 342 | } | 
|---|
|  | 343 |  | 
|---|
|  | 344 | //++ | 
|---|
|  | 345 | //  Image<T>& operator += -= *= /= (Image<T> const& rhs) | 
|---|
|  | 346 | //      Ajoute (+=), soustrait(-=), multiplie(*=), divise(/=) les valeurs des pixels | 
|---|
|  | 347 | //      de l'image a gauche de l'operateur par les pixels correspondants | 
|---|
|  | 348 | //      de l'image a droite de l'operateur ("rhs") | 
|---|
|  | 349 | //  Image<T>& operator += -= *= /= (double crhs) | 
|---|
|  | 350 | //      Ajoute (+=), soustrait(-=), multiplie(*=), divise(/=) les valeurs des pixels | 
|---|
|  | 351 | //      de l'image a gauche de l'operateur par la constante "crhs" | 
|---|
|  | 352 | //-- | 
|---|
|  | 353 |  | 
|---|
|  | 354 |  | 
|---|
|  | 355 | /* --Methode-- */ | 
|---|
|  | 356 | template <class T> | 
|---|
|  | 357 | Image<T>& Image<T>::operator+= (double a) | 
|---|
|  | 358 | { | 
|---|
|  | 359 | T* pDst = imagePtr; | 
|---|
|  | 360 | int nPix = siz_x * siz_y; | 
|---|
|  | 361 |  | 
|---|
|  | 362 | for (int i=0; i<nPix; i++, pDst++) | 
|---|
|  | 363 | *pDst = PutInRange((double)*pDst + a, *pDst); | 
|---|
|  | 364 |  | 
|---|
|  | 365 | return *this; | 
|---|
|  | 366 | } | 
|---|
|  | 367 |  | 
|---|
|  | 368 | /* --Methode-- */ | 
|---|
|  | 369 | template <class T> | 
|---|
|  | 370 | Image<T>& Image<T>::operator-= (double a) | 
|---|
|  | 371 | { | 
|---|
|  | 372 | T* pDst = imagePtr; | 
|---|
|  | 373 | int nPix = siz_x * siz_y; | 
|---|
|  | 374 |  | 
|---|
|  | 375 | for (int i=0; i<nPix; i++, pDst++) | 
|---|
|  | 376 | *pDst = PutInRange((double)*pDst - a, *pDst); | 
|---|
|  | 377 |  | 
|---|
|  | 378 | return *this; | 
|---|
|  | 379 | } | 
|---|
|  | 380 |  | 
|---|
|  | 381 | /* --Methode-- */ | 
|---|
|  | 382 | template <class T> | 
|---|
|  | 383 | Image<T>& Image<T>::operator*= (double a) | 
|---|
|  | 384 | { | 
|---|
|  | 385 | T* pDst = imagePtr; | 
|---|
|  | 386 | int nPix = siz_x * siz_y; | 
|---|
|  | 387 |  | 
|---|
|  | 388 | for (int i=0; i<nPix; i++, pDst++) | 
|---|
|  | 389 | *pDst = PutInRange((double)*pDst * a, *pDst); | 
|---|
|  | 390 |  | 
|---|
|  | 391 | return *this; | 
|---|
|  | 392 | } | 
|---|
|  | 393 |  | 
|---|
|  | 394 |  | 
|---|
|  | 395 | /* --Methode-- */ | 
|---|
|  | 396 | template <class T> | 
|---|
|  | 397 | Image<T>& Image<T>::operator/= (double a) | 
|---|
|  | 398 | { | 
|---|
|  | 399 | T* pDst = imagePtr; | 
|---|
|  | 400 | int nPix = siz_x * siz_y; | 
|---|
|  | 401 |  | 
|---|
|  | 402 | for (int i=0; i<nPix; i++, pDst++) | 
|---|
|  | 403 | *pDst = PutInRange((double)*pDst / a, *pDst); | 
|---|
|  | 404 |  | 
|---|
|  | 405 | return *this; | 
|---|
|  | 406 | } | 
|---|
|  | 407 |  | 
|---|
|  | 408 |  | 
|---|
|  | 409 |  | 
|---|
|  | 410 | //++ | 
|---|
|  | 411 | // Image<T> operator + - * / (Image<T> const& a, Image<T> const& b) | 
|---|
|  | 412 | //      Ajoute, soustrait, multiplie, divise les pixels des deux | 
|---|
|  | 413 | //      images "a" et "b" et l'affecte a gauche de l'operateur egal. | 
|---|
|  | 414 | // operator + - * / (Image<T> const& a, double cb) | 
|---|
|  | 415 | //      Ajoute, soustrait, multiplie, divise le contenu de l'image "a" | 
|---|
|  | 416 | //      par la constante "cb" et l'affecte a l'image a gauche de l'operateur = . | 
|---|
|  | 417 | // | 
|---|
|  | 418 | //      Il est preferable d'utiliser dans la mesure du possible, les | 
|---|
|  | 419 | //      operateurs "+=", "-=", "*=", "/=" afin d'eviter des copies | 
|---|
|  | 420 | //      inutiles. | 
|---|
|  | 421 | // | 
|---|
|  | 422 | //      *Exemples:* | 
|---|
|  | 423 | //| // Creation des images | 
|---|
|  | 424 | //| ImageR4  ai(200,300), bi, ci; | 
|---|
|  | 425 | //| // Tous les pixels a 238.5 | 
|---|
|  | 426 | //| ai = 238.5; | 
|---|
|  | 427 | //| // Image bi meme taille, meme valeurs de pixels que ai | 
|---|
|  | 428 | //| bi = ai; | 
|---|
|  | 429 | //| // On soustrait 13.2 a tous les pixels de ai | 
|---|
|  | 430 | //| ai -= 13.2; | 
|---|
|  | 431 | //| // Je divise bi par ai (pixel par pixel) qu'on affecte a bi | 
|---|
|  | 432 | //| bi /= ai; | 
|---|
|  | 433 | //| // On somme ai et bi (pixel par pixel) qu'on affecte a ci | 
|---|
|  | 434 | //| ci = ai + bi; | 
|---|
|  | 435 | //-- | 
|---|
|  | 436 |  | 
|---|
|  | 437 |  | 
|---|
|  | 438 | /* --Methode-- */ | 
|---|
|  | 439 | template <class T> | 
|---|
|  | 440 | Image<T> Image<T>::WhereNonZero() | 
|---|
|  | 441 | { | 
|---|
|  | 442 | Image<T> c(*this); | 
|---|
|  | 443 | for (int i=0; i<XSize(); i++) | 
|---|
|  | 444 | for (int j=0; j<YSize(); j++) | 
|---|
|  | 445 | c(i,j) = c(i,j) ? 1 : 0; | 
|---|
|  | 446 | return c; | 
|---|
|  | 447 | } | 
|---|
|  | 448 |  | 
|---|
|  | 449 | //++ | 
|---|
|  | 450 | // void PrintImage(ostream& os) const | 
|---|
|  | 451 | //      Envoie le contenu de l'image (formatte, texte) sur le | 
|---|
|  | 452 | //      flot (stream) de sortie "os". | 
|---|
|  | 453 | //      Attention: Ca peut faire beaucoup de ligne ! | 
|---|
|  | 454 | // void PrintImage() const | 
|---|
|  | 455 | //      Appel a PrintImage(cout) - Sortie sur cout . | 
|---|
|  | 456 | //-- | 
|---|
|  | 457 |  | 
|---|
|  | 458 |  | 
|---|
|  | 459 | /* --Methode-- */ | 
|---|
|  | 460 | template <class T> | 
|---|
|  | 461 | void Image<T>::PrintImage(ostream& os) const | 
|---|
|  | 462 | //  Impression de tout le contenu de l'image | 
|---|
|  | 463 | { | 
|---|
|  | 464 | #define PrPvLn 10 | 
|---|
|  | 465 | #define PrSize 6 | 
|---|
|  | 466 | int i,j,k,ido,ideb,ifin; | 
|---|
|  | 467 | int siz_x,siz_y; | 
|---|
|  | 468 |  | 
|---|
|  | 469 | siz_x= XSize(); | 
|---|
|  | 470 | siz_y= YSize(); | 
|---|
|  | 471 |  | 
|---|
|  | 472 | os << " Image::PrintImage: type pixel " ; | 
|---|
|  | 473 | os << DataName(dataType) ; | 
|---|
|  | 474 | os << ", NbPix=("<<siz_x<<","<<siz_y<<") \n"; | 
|---|
|  | 475 |  | 
|---|
|  | 476 |  | 
|---|
|  | 477 | /* segmentation avec des lignes de PrPvLn valeurs */ | 
|---|
|  | 478 |  | 
|---|
|  | 479 | ido = (siz_x-1) / PrPvLn + 1; | 
|---|
|  | 480 |  | 
|---|
|  | 481 | char buff[256]; | 
|---|
|  | 482 |  | 
|---|
|  | 483 | for(k=0;k<ido;k++) | 
|---|
|  | 484 | { | 
|---|
|  | 485 | ideb = k*PrPvLn; | 
|---|
|  | 486 | ifin = ideb + PrPvLn; | 
|---|
|  | 487 | if ( ifin >siz_x ) ifin =  siz_x ; | 
|---|
|  | 488 | sprintf(buff, "    ---- colonnes   %d   a   %d  ----\n",ideb,ifin-1); | 
|---|
|  | 489 | os << buff ; | 
|---|
|  | 490 | for(j=0; j<siz_y; j++) | 
|---|
|  | 491 | { | 
|---|
|  | 492 | sprintf(buff, "%3d - ",j); | 
|---|
|  | 493 | os << buff; | 
|---|
|  | 494 | for (i=ideb; i<ifin; i++) | 
|---|
|  | 495 | { | 
|---|
|  | 496 | os.width(PrSize); | 
|---|
|  | 497 | // les uint_1 sont traites comme characteres par les ostream ... | 
|---|
|  | 498 | if (PixelType() == kuint_1) os << ((int)((*this)(i,j))) << " "; | 
|---|
|  | 499 | else os << (*this)(i,j) << " "; | 
|---|
|  | 500 | } | 
|---|
|  | 501 | os << endl; | 
|---|
|  | 502 | } | 
|---|
|  | 503 | } | 
|---|
|  | 504 |  | 
|---|
|  | 505 | return; | 
|---|
|  | 506 | } | 
|---|
|  | 507 |  | 
|---|
|  | 508 |  | 
|---|
|  | 509 | //++ | 
|---|
|  | 510 | // Titre        Acces aux pixels | 
|---|
|  | 511 | //-- | 
|---|
|  | 512 | //++ | 
|---|
|  | 513 | // T&  operator() (int x, int y) | 
|---|
|  | 514 | //      Acces au pixel "(x,y)" de l'image (lecture/ecriture) | 
|---|
|  | 515 | // T&  operator[] (int i) | 
|---|
|  | 516 | //      Acces au pixel numero "i" de l'image (lecture/ecriture) | 
|---|
|  | 517 | // | 
|---|
|  | 518 | //| ImageU2 img(100,100); | 
|---|
|  | 519 | //| int i,j,k; | 
|---|
|  | 520 | //| // Remplissage de la moitie de l'image | 
|---|
|  | 521 | //| for(k=0; k<100*50; k++)  img[k] = k%500; | 
|---|
|  | 522 | //| img(50, 10); // Valeur du pixel (50, 10) | 
|---|
|  | 523 | // | 
|---|
|  | 524 | // T*  ImagePtr() | 
|---|
|  | 525 | //      Renvoie un pointeur du type "T (uint_2, r_4, ...)" sur le | 
|---|
|  | 526 | //      tableau des pixels de l'image. A n'utiliser que si un reelle | 
|---|
|  | 527 | //      optimisation de l'acces aux pixels peut etre effectuee. | 
|---|
|  | 528 | //-- | 
|---|
|  | 529 |  | 
|---|
|  | 530 |  | 
|---|
|  | 531 |  | 
|---|
|  | 532 | //++ | 
|---|
|  | 533 | // Titre        Traitements simples | 
|---|
|  | 534 | //-- | 
|---|
|  | 535 | //++ | 
|---|
|  | 536 | // int  CheckDyn(double min=-9.e19, double max=9.e19) | 
|---|
|  | 537 | //      Cette methode retourne le nombre de pixels hors dynamique "( <min ou >max )" | 
|---|
|  | 538 | //      Met a jour les donnees membres "min/maxPix nbNul/Sat". | 
|---|
|  | 539 | //      Calcule aussi la moyenne et le sigma des pixels -> "moyPix, sigPix" | 
|---|
|  | 540 | //      Implementation plus efficace de la methode "RzImage::CheckDyn()" | 
|---|
|  | 541 | //-- | 
|---|
|  | 542 |  | 
|---|
|  | 543 | /* --Methode-- */ | 
|---|
|  | 544 | template <class T> | 
|---|
|  | 545 | int Image<T>::CheckDyn(double min, double max) | 
|---|
|  | 546 |  | 
|---|
|  | 547 | /*  Cette methode retourne le nombre de pixels hors dynamique    */ | 
|---|
|  | 548 | /* ds le pave ( <min ou >max )                                   */ | 
|---|
|  | 549 | /* Met a jour la structure image Min/MaxPix nbNul/Sat            */ | 
|---|
|  | 550 | /* Calcule aussi la moyenne et le sigma des pixels, met a jour   */ | 
|---|
|  | 551 | /* moypix et sigpix dans la structure                            */ | 
|---|
|  | 552 |  | 
|---|
|  | 553 | { | 
|---|
|  | 554 | T pixv=0; | 
|---|
|  | 555 | double dv; | 
|---|
|  | 556 |  | 
|---|
|  | 557 | T minadu = PutInRange(min, pixv); | 
|---|
|  | 558 | T maxadu = PutInRange(max, pixv); | 
|---|
|  | 559 | T minpix = PutInRange(maxadu+1, pixv); | 
|---|
|  | 560 | T maxpix = PutInRange(minadu-1, pixv); | 
|---|
|  | 561 |  | 
|---|
|  | 562 | double m = 0.; | 
|---|
|  | 563 | double s = 0.; | 
|---|
|  | 564 | int n9 = 0; | 
|---|
|  | 565 | int n0 = 0; | 
|---|
|  | 566 | int n = XSize()*YSize(); | 
|---|
|  | 567 | for(int i=0; i<n; i++) | 
|---|
|  | 568 | { | 
|---|
|  | 569 | pixv = imagePtr[i]; | 
|---|
|  | 570 | if (pixv <= maxadu && pixv >= minadu) | 
|---|
|  | 571 | { | 
|---|
|  | 572 | if (pixv < minpix)  minpix = pixv; | 
|---|
|  | 573 | else if (pixv > maxpix)  maxpix = pixv; | 
|---|
|  | 574 | dv = (double)pixv; | 
|---|
|  | 575 | m += dv;  s += (dv*dv); | 
|---|
|  | 576 | } | 
|---|
|  | 577 | else | 
|---|
|  | 578 | { | 
|---|
|  | 579 | if (pixv > maxadu)  n9++; | 
|---|
|  | 580 | if (pixv < minadu)  n0++; | 
|---|
|  | 581 | } | 
|---|
|  | 582 | } | 
|---|
|  | 583 |  | 
|---|
|  | 584 | nbNul = n0; | 
|---|
|  | 585 | nbSat = n9; | 
|---|
|  | 586 | minPix = minpix; | 
|---|
|  | 587 | maxPix = maxpix; | 
|---|
|  | 588 |  | 
|---|
|  | 589 | n -= (n0+n9); | 
|---|
|  | 590 | if (n > 0) | 
|---|
|  | 591 | { dv = (double)n;  m /= dv;  s = s/dv - m*m; | 
|---|
|  | 592 | if (s>0.)  s = sqrt(s);  else s = 0.; | 
|---|
|  | 593 | moyPix = m;  sigPix = s; } | 
|---|
|  | 594 | else { moyPix = 0.;  sigPix = -1.; } | 
|---|
|  | 595 |  | 
|---|
|  | 596 | return(n0+n9); | 
|---|
|  | 597 | } | 
|---|
|  | 598 |  | 
|---|
|  | 599 | //++ | 
|---|
|  | 600 | // SeuilBas(double seuil, double val) | 
|---|
|  | 601 | //      Met les pixels en dessous du "seuil" (< seuil) a la valeur "val". | 
|---|
|  | 602 | // SeuilBas(double seuil) | 
|---|
|  | 603 | //      Met les pixels en dessous du "seuil" (< seuil) a zero | 
|---|
|  | 604 | // SeuilHaut(double seuil, double val) | 
|---|
|  | 605 | //      Met les pixels au dessus du "seuil" (> seuil) a la valeur "val". | 
|---|
|  | 606 | // SeuilHaut(double seuil) | 
|---|
|  | 607 | //      Met les pixels au dessus du "seuil" (> seuil) a zero | 
|---|
|  | 608 | //-- | 
|---|
|  | 609 |  | 
|---|
|  | 610 | /* --Methode-- */ | 
|---|
|  | 611 | template <class T> | 
|---|
|  | 612 | void Image<T>::SeuilBas(double seuil, double val) | 
|---|
|  | 613 |  | 
|---|
|  | 614 | /*   Met a une valeur definie tous les pixels    */ | 
|---|
|  | 615 | /*   en dessous du seuil                         */ | 
|---|
|  | 616 |  | 
|---|
|  | 617 | { | 
|---|
|  | 618 | if (!ImagePtr())   THROW(nullPtrErr); | 
|---|
|  | 619 | T* PtPix=ImagePtr(); | 
|---|
|  | 620 | int nPix=XSize()*YSize(); | 
|---|
|  | 621 | for(int i=0 ; i<nPix;i++,PtPix++) {if(*PtPix < (T) seuil) *PtPix = (T) val;}; | 
|---|
|  | 622 | } | 
|---|
|  | 623 |  | 
|---|
|  | 624 | /* --Methode-- */ | 
|---|
|  | 625 | template <class T> | 
|---|
|  | 626 | void Image<T>::SeuilHaut(double seuil, double val) | 
|---|
|  | 627 |  | 
|---|
|  | 628 | /*   Met a une valeur definie tous les pixels    */ | 
|---|
|  | 629 | /*   en dessus du seuil                         */ | 
|---|
|  | 630 |  | 
|---|
|  | 631 | { | 
|---|
|  | 632 | if (!ImagePtr())   THROW(nullPtrErr); | 
|---|
|  | 633 | T* PtPix=ImagePtr(); | 
|---|
|  | 634 | int nPix=XSize()*YSize(); | 
|---|
|  | 635 | for(int i=0 ; i<nPix;i++,PtPix++) {if(*PtPix > (T) seuil) *PtPix = (T) val;}; | 
|---|
|  | 636 | } | 
|---|
|  | 637 |  | 
|---|
|  | 638 | /* --Methode-- */ | 
|---|
|  | 639 | template <class T> | 
|---|
|  | 640 | void Image<T>::SeuilBas(double seuil) | 
|---|
|  | 641 | { | 
|---|
|  | 642 | SeuilBas(seuil,seuil); | 
|---|
|  | 643 | } | 
|---|
|  | 644 |  | 
|---|
|  | 645 | /* --Methode-- */ | 
|---|
|  | 646 | template <class T> | 
|---|
|  | 647 | void Image<T>::SeuilHaut(double seuil) | 
|---|
|  | 648 | { | 
|---|
|  | 649 | SeuilHaut(seuil,seuil); | 
|---|
|  | 650 | } | 
|---|
|  | 651 |  | 
|---|
|  | 652 | /* --Methode-- (cmv 23/09/96) */ | 
|---|
|  | 653 | template <class T> | 
|---|
|  | 654 | //++ | 
|---|
|  | 655 | void Image<T>::HBinInt(int& nbin,float& xmin,float& xmax) | 
|---|
|  | 656 | // | 
|---|
|  | 657 | //      Valeur pour avoir un bin entier quand on fait un | 
|---|
|  | 658 | //      histogramme 1D des pixels (pour les images entieres). | 
|---|
|  | 659 | //-- | 
|---|
|  | 660 | { | 
|---|
|  | 661 | if( PixelType()<kuint_2 || PixelType()>kint_4 ) return; | 
|---|
|  | 662 | double binw = (xmax-xmin)/nbin; | 
|---|
|  | 663 | binw = (double) ( (int)(binw+0.5) ); | 
|---|
|  | 664 | if( binw <= 0. ) binw = 1.; | 
|---|
|  | 665 | xmin = (float) ( (int) xmin ); | 
|---|
|  | 666 | xmax = (float) ( (int) (xmax + binw) ); | 
|---|
|  | 667 | nbin = (int)( (xmax-xmin)/binw + 0.1 ); | 
|---|
|  | 668 | } | 
|---|
|  | 669 |  | 
|---|
|  | 670 | /* --Methode-- (cmv 23/09/96) */ | 
|---|
|  | 671 | template <class T> | 
|---|
|  | 672 | //++ | 
|---|
|  | 673 | int Image<T>::EstimeFdSg(float& xbmax,float& sgbmax | 
|---|
|  | 674 | ,float nbsig,float frac,float lowbad,float highbad,int deb) | 
|---|
|  | 675 | // | 
|---|
|  | 676 | //      Pour donner une estimation  du fond de ciel et du sigma ciel. | 
|---|
|  | 677 | //      Il est conseille de faire ceci sur une image partielle. | 
|---|
|  | 678 | //      Une premiere estimation du fond et du sigma est faite en nettoyant | 
|---|
|  | 679 | //      iterativement (cf MoySigmaIter). | 
|---|
|  | 680 | //      Puis un histogramme est rempli et rebinne jusqu'a ce que son maximum | 
|---|
|  | 681 | //      soit statistiquement significatif. Le fond et le sigma sont ensuite | 
|---|
|  | 682 | //      calcules par les methodes `FitMax' et `EstimeWidthS' de la classe Histo. | 
|---|
|  | 683 | //| xbmax = position du maximum | 
|---|
|  | 684 | //| sgbmax = valeur du sigma | 
|---|
|  | 685 | //| nbsig = dimensionnement de l'histo de depart en nombre | 
|---|
|  | 686 | //|         de sigma autour de la valeur maximum | 
|---|
|  | 687 | //| frac = valeur maximum principale / maximum secondaire a partir | 
|---|
|  | 688 | //|        de laquelle on considere qu'elle a une signification | 
|---|
|  | 689 | //|        statistique. | 
|---|
|  | 690 | //| lowbad,highbad = dynamique utile de l'image traitee | 
|---|
|  | 691 | //| deb = niveau de debug | 
|---|
|  | 692 | //| Return : 0 = OK, -1 = echec MoySigmaIter, -2 = echec FitMax, | 
|---|
|  | 693 | //|                  -3 = echec FindWidth | 
|---|
|  | 694 | //-- | 
|---|
|  | 695 | { | 
|---|
|  | 696 | T pixv=0; | 
|---|
|  | 697 | T minadu = PutInRange((double) lowbad , pixv); | 
|---|
|  | 698 | T maxadu = PutInRange((double) highbad, pixv); | 
|---|
|  | 699 | bool testl = (lowbad<highbad) ? true : false; | 
|---|
|  | 700 | lowbad  = (float) minadu;  highbad = (float) maxadu; | 
|---|
|  | 701 |  | 
|---|
|  | 702 | if(deb<0) deb=0; | 
|---|
|  | 703 | int envd = 0; | 
|---|
|  | 704 | GetIntEnv("PDEBUG_FOND", envd); | 
|---|
|  | 705 | if (deb < envd) deb = envd; | 
|---|
|  | 706 |  | 
|---|
|  | 707 | // moyenne et sigma bruts (iteratifs) | 
|---|
|  | 708 | int rc; | 
|---|
|  | 709 | float fd,sg; | 
|---|
|  | 710 | rc = MoySigmaIter(fd,sg,lowbad,highbad,1,5,0.1,3.5,deb-1); | 
|---|
|  | 711 | if(deb>0) cout<<"EstimeFdSg: MoySigmaIter rc="<<rc<<" fd="<<fd<<" sg="<<sg<<endl; | 
|---|
|  | 712 | if(rc<=0) return -1; | 
|---|
|  | 713 |  | 
|---|
|  | 714 | // remplissage histogramme avec beaucoup de bins | 
|---|
|  | 715 | int nbin; | 
|---|
|  | 716 | float xmin,xmax; | 
|---|
|  | 717 | xmin = fd - nbsig*sg; if(testl && xmin<lowbad ) xmin = lowbad; | 
|---|
|  | 718 | xmax = fd + nbsig*sg; if(testl && xmax>highbad) xmax = highbad; | 
|---|
|  | 719 | nbin = XSize()*YSize()/20; if(nbin>2000) nbin=2000; | 
|---|
|  | 720 | Histo H(xmin,xmax,nbin); | 
|---|
|  | 721 | for(int i=0;i<XSize()*YSize();i++) H.Add((float) (*this)[i],1.); | 
|---|
|  | 722 |  | 
|---|
|  | 723 | // redimensionnement de l'histo pour avoir une bonne signification stat. | 
|---|
|  | 724 | for(;;) { | 
|---|
|  | 725 | float max1,max2; | 
|---|
|  | 726 | int imax1,imax2; | 
|---|
|  | 727 | rc = H.MaxiLocal(max1,imax1,max2,imax2); | 
|---|
|  | 728 | float rap = 1.; | 
|---|
|  | 729 | if( max1 != 0. ) rap = max2/max1; | 
|---|
|  | 730 | // if(nbin<100) H.Print(80); | 
|---|
|  | 731 | if(deb>1) | 
|---|
|  | 732 | cout<<"nbin="<<nbin | 
|---|
|  | 733 | <<"   maxloc="<<rc | 
|---|
|  | 734 | <<"   maxi="<<max1<<" imax="<<imax1<<" xmax="<<H.BinCenter(imax1) | 
|---|
|  | 735 | <<"   maxn="<<max2<<" imaxn="<<imax2<<" xmaxn="<<H.BinCenter(imax2) | 
|---|
|  | 736 | <<" -> "<<rap<<endl; | 
|---|
|  | 737 | if( rap<frac || nbin<=10 ) break; | 
|---|
|  | 738 | nbin = (int)(nbin/1.5); | 
|---|
|  | 739 | H.HRebin(nbin); | 
|---|
|  | 740 | } | 
|---|
|  | 741 | if(deb>1) { if(nbin<250) H.Print(80); else H.Print(80,-1.,1.,-1);} | 
|---|
|  | 742 |  | 
|---|
|  | 743 | TRY { | 
|---|
|  | 744 | xbmax = H.FitMax(2,0.5f,deb-2); | 
|---|
|  | 745 | if(deb>1) cout<<"H.FitMax = "<<xbmax<<endl; | 
|---|
|  | 746 | } CATCHALL { | 
|---|
|  | 747 | if(deb) cout<< "Echec H.FitMax"<< endl; | 
|---|
|  | 748 | return(-2); | 
|---|
|  | 749 | } ENDTRY | 
|---|
|  | 750 |  | 
|---|
|  | 751 | TRY { | 
|---|
|  | 752 | float sdroit = -2.; | 
|---|
|  | 753 | H.EstimeWidthS(0.5f,sgbmax,sdroit); | 
|---|
|  | 754 | if(sgbmax<=0.) sgbmax = H.FindWidth(0.5f,deb-2); | 
|---|
|  | 755 | sgbmax /= 2.36; | 
|---|
|  | 756 | if(deb>1) cout<<"H.FindWidth = "<<sgbmax<<" (droit="<<sdroit<<")"<<endl; | 
|---|
|  | 757 | } CATCHALL { | 
|---|
|  | 758 | cout<< "Echec H.FindWidth"<< endl; | 
|---|
|  | 759 | return(-3); | 
|---|
|  | 760 | } ENDTRY | 
|---|
|  | 761 |  | 
|---|
|  | 762 | return 0; | 
|---|
|  | 763 | } | 
|---|
|  | 764 |  | 
|---|
|  | 765 | /* --Methode--  (cmv 23/09/96) */ | 
|---|
|  | 766 | template <class T> | 
|---|
|  | 767 | //++ | 
|---|
|  | 768 | float Image<T>::FondCiel(int nbin,float bin_low,float bin_high | 
|---|
|  | 769 | ,int degre,float frac,int modu,int deb) | 
|---|
|  | 770 | // | 
|---|
|  | 771 | //      Calcul du fond de ciel: | 
|---|
|  | 772 | //      Remplissage d'un histogramme avec le contenu des pixels du pave, | 
|---|
|  | 773 | //      recherche du bin contenant le maximum, | 
|---|
|  | 774 | //      recheche des limites a frac% de chaque cote du maximum | 
|---|
|  | 775 | //      et fit d'un polynome du 2sd ou 3ieme degre dans cette zone. | 
|---|
|  | 776 | //| Input: | 
|---|
|  | 777 | //|   nbin,bin_low,bin_high : definition de l'histogramme | 
|---|
|  | 778 | //|   degre : degre du fit (2 ou 3) | 
|---|
|  | 779 | //|   frac : definition de la zone de fit a frac% du maximum | 
|---|
|  | 780 | //|   modu : on prend 1 px sur modu | 
|---|
|  | 781 | //|   deb : debug flag | 
|---|
|  | 782 | //| Output: renvoie le maximum de l'histogramme (fond de ciel) | 
|---|
|  | 783 | //|         et update le membre protected fond (si succes) | 
|---|
|  | 784 | //-- | 
|---|
|  | 785 | { | 
|---|
|  | 786 | T pixv; | 
|---|
|  | 787 |  | 
|---|
|  | 788 | if(modu<=0) modu = 1; | 
|---|
|  | 789 | if(frac<=0.) frac = 0.5; | 
|---|
|  | 790 | if(degre<2 || degre>3) degre = 2; | 
|---|
|  | 791 | if(deb>0) | 
|---|
|  | 792 | printf("Image::FondCiel: nbin=%d dyn=%g,%g deg=%d frac=%g modu=%d\n" | 
|---|
|  | 793 | ,nbin,bin_low,bin_high,degre,frac,modu); | 
|---|
|  | 794 | if(nbin<=degre) THROW(inconsistentErr); | 
|---|
|  | 795 |  | 
|---|
|  | 796 | TRY { | 
|---|
|  | 797 |  | 
|---|
|  | 798 | Histo tab(bin_low,bin_high,nbin); | 
|---|
|  | 799 | double sum = 0.; | 
|---|
|  | 800 | volatile int n = 0, nsum = 0; | 
|---|
|  | 801 | for(int i=0;i<XSize()*YSize();i++) { | 
|---|
|  | 802 | n++; | 
|---|
|  | 803 | if( n%modu != 0 ) continue; | 
|---|
|  | 804 | pixv = imagePtr[i]; | 
|---|
|  | 805 | tab.Add( (float) pixv ); | 
|---|
|  | 806 | sum += (double) pixv; | 
|---|
|  | 807 | nsum++; | 
|---|
|  | 808 | } | 
|---|
|  | 809 | if(deb>1) { int im = tab.IMax(); | 
|---|
|  | 810 | tab.Print(80,1.,-1.,0,im-50,im+50); } | 
|---|
|  | 811 |  | 
|---|
|  | 812 | float xf = 0.; | 
|---|
|  | 813 | // tout dans moins de degre bins | 
|---|
|  | 814 | if( tab.BinNonNul() <= degre ) { | 
|---|
|  | 815 | if(nsum<=0) THROW(inconsistentErr); | 
|---|
|  | 816 | xf = sum / (double) nsum; | 
|---|
|  | 817 | if(deb>0) printf("%d bins <= %d -> Succes Mean = %g\n" | 
|---|
|  | 818 | ,tab.BinNonNul(),degre,xf); | 
|---|
|  | 819 | fond = xf; | 
|---|
|  | 820 | RETURN(xf); | 
|---|
|  | 821 | } | 
|---|
|  | 822 |  | 
|---|
|  | 823 | TRY { | 
|---|
|  | 824 | xf = tab.FitMax(degre,frac,deb-1); | 
|---|
|  | 825 | if(deb>0) printf("Succes tab.FitMax = %g\n",xf); | 
|---|
|  | 826 | fond = xf; | 
|---|
|  | 827 | RETURN(xf); | 
|---|
|  | 828 | } CATCHALL { | 
|---|
|  | 829 | if(deb>0) | 
|---|
|  | 830 | printf("Echec tab.FitMax BinNonNul=%d\n",tab.BinNonNul()); | 
|---|
|  | 831 | THROW(inconsistentErr); | 
|---|
|  | 832 | } ENDTRY | 
|---|
|  | 833 |  | 
|---|
|  | 834 | } CATCHALL { | 
|---|
|  | 835 | THROW_SAME; | 
|---|
|  | 836 | } ENDTRY | 
|---|
|  | 837 | } | 
|---|
|  | 838 |  | 
|---|
|  | 839 | /* --Methode-- (cmv 23/09/96) */ | 
|---|
|  | 840 | template <class T> | 
|---|
|  | 841 | //++ | 
|---|
|  | 842 | float Image<T>::SigmaCiel(int nbin,float bin_low,float bin_high | 
|---|
|  | 843 | ,float& means,float lowbad,float highbad | 
|---|
|  | 844 | ,float nsig,int modu,int deb) | 
|---|
|  | 845 | // | 
|---|
|  | 846 | //      Calcul du sigma du fond de ciel: | 
|---|
|  | 847 | //      Remplissage d'un histogramme avec px-<px8> pour les pixels | 
|---|
|  | 848 | //      entre lowbad et highbad (px=valeur du pixel etudie, | 
|---|
|  | 849 | //      <px8>=moyenne des 8 pixels qui lui sont contigus). | 
|---|
|  | 850 | //      Une premiere estimation du sigma (s1) et realisee en cherchant | 
|---|
|  | 851 | //      la largeur a mi-hauteur de cet histogramme. Puis un fit non-lineaire | 
|---|
|  | 852 | //      d'une gaussienne est effectue dans +/- nsig*s1 | 
|---|
|  | 853 | //| Input: | 
|---|
|  | 854 | //|   nbin,bin_low,bin_high : definition de l'histogramme | 
|---|
|  | 855 | //|   lowbad,highbad : limites des pixels a utiliser | 
|---|
|  | 856 | //|   nsig : la zone de fit est definie a +/- nsig*sigma du maximum | 
|---|
|  | 857 | //|   modu : on prend 1 px sur modu | 
|---|
|  | 858 | //|   deb : debug flag | 
|---|
|  | 859 | //| Output: | 
|---|
|  | 860 | //|   means = moyenne fittee de l'histogramme (normalement -> 0) | 
|---|
|  | 861 | //|   renvoie le sigma du fond de ciel | 
|---|
|  | 862 | //|     et update le membre protected sigmaFond (si succes) | 
|---|
|  | 863 | //-- | 
|---|
|  | 864 | { | 
|---|
|  | 865 | T pixv=0; | 
|---|
|  | 866 | T minadu = PutInRange((double) lowbad , pixv); | 
|---|
|  | 867 | T maxadu = PutInRange((double) highbad, pixv); | 
|---|
|  | 868 | volatile bool testl = (lowbad<highbad) ? true : false; | 
|---|
|  | 869 |  | 
|---|
|  | 870 | if(nbin<5) THROW(inconsistentErr); | 
|---|
|  | 871 | if(nsig<=0.) nsig = 4.; | 
|---|
|  | 872 | if(modu<=0) modu = 1; | 
|---|
|  | 873 | means = 0.; | 
|---|
|  | 874 | if(deb>0) | 
|---|
|  | 875 | cout << "SigmaCiel( nbin=" << nbin | 
|---|
|  | 876 | << ", bin_low=" << bin_low | 
|---|
|  | 877 | << ", bin_high=" << bin_high | 
|---|
|  | 878 | << ", lowbad=" << lowbad | 
|---|
|  | 879 | << ", highbad=" << highbad | 
|---|
|  | 880 | << ", nsig=" << nsig | 
|---|
|  | 881 | << ", modu=" << modu | 
|---|
|  | 882 | << ", deb=" << deb << endl; | 
|---|
|  | 883 |  | 
|---|
|  | 884 | // coeff pour corriger le sigma de (S-<S8>) par rapport au sigma de S | 
|---|
|  | 885 | // sigma(S) = sigma(S-<S8>) * 1/sqrt(1+1/8) = 2*sqrt(2)/3 | 
|---|
|  | 886 | double coeff = 2.*Rac2/3.; | 
|---|
|  | 887 |  | 
|---|
|  | 888 | TRY { | 
|---|
|  | 889 |  | 
|---|
|  | 890 | Histo tab(bin_low,bin_high,nbin); | 
|---|
|  | 891 | tab.Errors(); | 
|---|
|  | 892 |  | 
|---|
|  | 893 | int nmod = 0, nsum = 0; | 
|---|
|  | 894 | double sum= 0., sum2 = 0.; | 
|---|
|  | 895 | for(int j=1;j<YSize()-1;j++) for(int i=1;i<XSize()-1;i++) { | 
|---|
|  | 896 | nmod++; | 
|---|
|  | 897 | if( nmod%modu != 0 ) continue; | 
|---|
|  | 898 | pixv = (*this)(i,j); | 
|---|
|  | 899 | if ( testl && (pixv < minadu || pixv > maxadu) ) continue; | 
|---|
|  | 900 | double vp = (double) pixv; | 
|---|
|  | 901 | double pxv = 0.; | 
|---|
|  | 902 | volatile int n = 0; | 
|---|
|  | 903 | for(int j1=j-1;j1<=j+1;j1++) for(int i1=i-1;i1<=i+1;i1++) { | 
|---|
|  | 904 | if ( i1 == i && j1 == j ) continue; | 
|---|
|  | 905 | pixv = (*this)(i1,j1); | 
|---|
|  | 906 | if ( testl && (pixv < minadu || pixv > maxadu) ) continue; | 
|---|
|  | 907 | pxv += (double) pixv; | 
|---|
|  | 908 | n++; | 
|---|
|  | 909 | } | 
|---|
|  | 910 | if ( n != 8 ) continue; | 
|---|
|  | 911 | vp = vp - pxv/(double) n; | 
|---|
|  | 912 | tab.Add( (float) vp ); | 
|---|
|  | 913 | nsum++; | 
|---|
|  | 914 | sum += vp; | 
|---|
|  | 915 | sum2 += vp*vp; | 
|---|
|  | 916 | } | 
|---|
|  | 917 |  | 
|---|
|  | 918 | float ms = tab.BinCenter( tab.IMax() ); | 
|---|
|  | 919 | volatile float sg = 0.; | 
|---|
|  | 920 | if( tab.BinNonNul() == 1 ) { | 
|---|
|  | 921 | if(deb>0) cout << tab.BinNonNul() | 
|---|
|  | 922 | << " bins non nul dans l'histogramme" << endl; | 
|---|
|  | 923 | if(nsum<=1) THROW(inconsistentErr); | 
|---|
|  | 924 | sum /= (double) nsum; | 
|---|
|  | 925 | sum2 = sum2/(double) nsum - sum*sum; | 
|---|
|  | 926 | if(sum2<0.) THROW(inconsistentErr); | 
|---|
|  | 927 | means = sum; | 
|---|
|  | 928 | sum2 = sqrt(sum2) * coeff; | 
|---|
|  | 929 | sigmaFond = sum2; | 
|---|
|  | 930 | RETURN((float) sum2); | 
|---|
|  | 931 | } else { | 
|---|
|  | 932 | TRY { | 
|---|
|  | 933 | sg = tab.FindWidth(0.5,deb-1) / 2.36; | 
|---|
|  | 934 | } CATCHALL { | 
|---|
|  | 935 | THROW_SAME; | 
|---|
|  | 936 | } ENDTRY | 
|---|
|  | 937 | } | 
|---|
|  | 938 | double h = tab.VMax(); | 
|---|
|  | 939 | if(deb>0) cout << "from histo: ms=" << ms | 
|---|
|  | 940 | << "  sg=" << sg | 
|---|
|  | 941 | << "  h=" << h << endl; | 
|---|
|  | 942 |  | 
|---|
|  | 943 | float xmin = ms - nsig*sg; | 
|---|
|  | 944 | float xmax = ms + nsig*sg; | 
|---|
|  | 945 | int imin = tab.FindBin(xmin); | 
|---|
|  | 946 | int imax = tab.FindBin(xmax); | 
|---|
|  | 947 | if( imax-imin+1 < 4 ) {imax++; imin--;} | 
|---|
|  | 948 | if(imin<0) imin=0; | 
|---|
|  | 949 | if(imax>=tab.NBins()) imax=tab.NBins()-1; | 
|---|
|  | 950 | int nb = imax-imin+1; | 
|---|
|  | 951 | if( nb < 4 ) THROW(inconsistentErr); | 
|---|
|  | 952 | if(deb>0) printf("xrange=[%g,%g] irange=[%d,%d] nb=%d\n" | 
|---|
|  | 953 | ,xmin,xmax,imin,imax,nb); | 
|---|
|  | 954 | if(deb>2) tab.Print(80,1.,-1.,0,imin,imax); | 
|---|
|  | 955 |  | 
|---|
|  | 956 | Gauss1DPol     myfunc; | 
|---|
|  | 957 | GeneralFit     myfit(&myfunc); | 
|---|
|  | 958 | GeneralFitData mydata(1,nb); | 
|---|
|  | 959 | for(int i=imin;i<=imax;i++) { | 
|---|
|  | 960 | float e = tab.Error(i); | 
|---|
|  | 961 | if( e <= 0. ) e = 1.; | 
|---|
|  | 962 | mydata.AddData1(tab.BinCenter(i),tab(i),e); | 
|---|
|  | 963 | } | 
|---|
|  | 964 |  | 
|---|
|  | 965 | myfit.SetData(&mydata); | 
|---|
|  | 966 | myfit.SetParam(0,h,h/50.); | 
|---|
|  | 967 | myfit.SetParam(1,ms,sg/10.); | 
|---|
|  | 968 | myfit.SetParam(2,sg,sg/10.); | 
|---|
|  | 969 | myfit.SetBound(2,0.,sg*5.); | 
|---|
|  | 970 | int rc = myfit.Fit(); | 
|---|
|  | 971 | if(rc<0) THROW(inconsistentErr); | 
|---|
|  | 972 | if(deb>1) myfit.PrintFit(); | 
|---|
|  | 973 |  | 
|---|
|  | 974 | means = myfit.GetParm(1); | 
|---|
|  | 975 | sum2 = myfit.GetParm(2) * coeff; | 
|---|
|  | 976 | sigmaFond = sum2; | 
|---|
|  | 977 | RETURN((float) sum2); | 
|---|
|  | 978 |  | 
|---|
|  | 979 | } CATCHALL { | 
|---|
|  | 980 | THROW_SAME; | 
|---|
|  | 981 | } ENDTRY | 
|---|
|  | 982 |  | 
|---|
|  | 983 | } | 
|---|
|  | 984 |  | 
|---|
|  | 985 |  | 
|---|
|  | 986 | /* --Methode-- (cmv 23/09/96) */ | 
|---|
|  | 987 | template <class T> | 
|---|
|  | 988 | //++ | 
|---|
|  | 989 | int Image<T>::MoySigma(float& mean,float& sigma,float lowbad,float highbad,int modu) | 
|---|
|  | 990 | // | 
|---|
|  | 991 | //      Calcul de la moyenne (mean) et du sigma (sigma) dans un pave | 
|---|
|  | 992 | //      en ne considerant que les pixels compris entre lowbad et highbad. | 
|---|
|  | 993 | //      Seul 1 px sur modu est utilise. | 
|---|
|  | 994 | //      La fonction retourne le nombre de pixels utilises pour le calcul. | 
|---|
|  | 995 | //-- | 
|---|
|  | 996 | { | 
|---|
|  | 997 | T pixv=0; | 
|---|
|  | 998 | T minadu = PutInRange((double) lowbad , pixv); | 
|---|
|  | 999 | T maxadu = PutInRange((double) highbad, pixv); | 
|---|
|  | 1000 | bool testl = (lowbad<highbad) ? true : false; | 
|---|
|  | 1001 |  | 
|---|
|  | 1002 | if(modu<=0) modu = 1; | 
|---|
|  | 1003 | mean = sigma = 0.; | 
|---|
|  | 1004 |  | 
|---|
|  | 1005 | int rc = 0, n = 0; | 
|---|
|  | 1006 | double m = 0., s = 0., mm, ss, v; | 
|---|
|  | 1007 |  | 
|---|
|  | 1008 | for(int j=0;j<YSize();j++) { | 
|---|
|  | 1009 | mm = ss = 0.; | 
|---|
|  | 1010 | for(int i=0;i<XSize();i++) { | 
|---|
|  | 1011 | n++; | 
|---|
|  | 1012 | if( n%modu != 0 ) continue; | 
|---|
|  | 1013 | pixv = (*this)(i,j); | 
|---|
|  | 1014 | if( testl && (pixv < minadu || pixv > maxadu) ) continue; | 
|---|
|  | 1015 | v = (double) pixv; | 
|---|
|  | 1016 | rc++; | 
|---|
|  | 1017 | mm += v; | 
|---|
|  | 1018 | ss += v*v; | 
|---|
|  | 1019 | } | 
|---|
|  | 1020 | m += mm; | 
|---|
|  | 1021 | s += ss; | 
|---|
|  | 1022 | } | 
|---|
|  | 1023 |  | 
|---|
|  | 1024 | if(rc==0) return(-1); | 
|---|
|  | 1025 |  | 
|---|
|  | 1026 | m /= (double) rc; | 
|---|
|  | 1027 | s = s/(double) rc - m*m; | 
|---|
|  | 1028 | if(s<0.) return(-2); | 
|---|
|  | 1029 |  | 
|---|
|  | 1030 | mean  = (float) m; | 
|---|
|  | 1031 | sigma = (float) sqrt(s); | 
|---|
|  | 1032 |  | 
|---|
|  | 1033 | moyPix = mean;     // Mise a jour de la structure | 
|---|
|  | 1034 | sigPix = sigma; | 
|---|
|  | 1035 |  | 
|---|
|  | 1036 | return rc; | 
|---|
|  | 1037 | } | 
|---|
|  | 1038 |  | 
|---|
|  | 1039 | /* --Methode-- (cmv 23/09/96) */ | 
|---|
|  | 1040 | template <class T> | 
|---|
|  | 1041 | //++ | 
|---|
|  | 1042 | int Image<T>::MoySigmaIter(float& mean,float& sigma,float lowbad,float highbad | 
|---|
|  | 1043 | ,int modu,int nitermx,float perdiff,float scut,int deb) | 
|---|
|  | 1044 | // | 
|---|
|  | 1045 | //      Calcul de moyenne et sigma iterativement: | 
|---|
|  | 1046 | //| lowbad,highbad = dynamique permise pour la valeur | 
|---|
|  | 1047 | //|                  des pixels en ADU | 
|---|
|  | 1048 | //| modu = 1 px sur modu est utilise | 
|---|
|  | 1049 | //| nitermx = nombre maximum d'iterations permises | 
|---|
|  | 1050 | //| perdiff = condition d'arret en pourcent sur la variation du sigma | 
|---|
|  | 1051 | //| scut = coupure en nombre de sigma courant pour l'iteration suivante | 
|---|
|  | 1052 | //| mean = moyenne retournee | 
|---|
|  | 1053 | //| sigma = sigma retourne | 
|---|
|  | 1054 | //| return <= 0 probleme, sinon (>0) nombre de pixels utilises | 
|---|
|  | 1055 | //-- | 
|---|
|  | 1056 | { | 
|---|
|  | 1057 | if( scut<=0. || nitermx<=0 || perdiff<=0. ) return 0; | 
|---|
|  | 1058 | if(modu<=0) modu = 1; | 
|---|
|  | 1059 | bool testl = (lowbad<highbad) ? true : false; | 
|---|
|  | 1060 |  | 
|---|
|  | 1061 | mean = sigma = 0.; | 
|---|
|  | 1062 | float sigmaold = 0; | 
|---|
|  | 1063 | float xmin = lowbad; | 
|---|
|  | 1064 | float xmax = highbad; | 
|---|
|  | 1065 | int rc = 0; | 
|---|
|  | 1066 |  | 
|---|
|  | 1067 | for(int it=0;it<nitermx;it++) { | 
|---|
|  | 1068 | rc = MoySigma(mean,sigma,xmin,xmax,modu); | 
|---|
|  | 1069 | if(deb>0) cout<<"MoySigmaIter mean="<<mean<<" sigma="<<sigma | 
|---|
|  | 1070 | <<" npix="<<rc<<" entre "<<xmin<<","<<xmax<<endl; | 
|---|
|  | 1071 | if( rc <= 0 || sigma<=0. ) return rc; | 
|---|
|  | 1072 | if( it>=1 && fabs((double)(sigma-sigmaold))/sigma < perdiff ) break; | 
|---|
|  | 1073 | xmin = mean - scut*sigma; if(testl && xmin<lowbad ) xmin = lowbad; | 
|---|
|  | 1074 | xmax = mean + scut*sigma; if(testl && xmax>highbad) xmax = highbad; | 
|---|
|  | 1075 | sigmaold = sigma; | 
|---|
|  | 1076 | } | 
|---|
|  | 1077 |  | 
|---|
|  | 1078 | return rc; | 
|---|
|  | 1079 | } | 
|---|
|  | 1080 |  | 
|---|
|  | 1081 | /* --Methode-- (cmv 23/09/96) */ | 
|---|
|  | 1082 | template <class T> | 
|---|
|  | 1083 | //++ | 
|---|
|  | 1084 | int Image<T>::FondSigmaCiel(float lowbad,float highbad,int pvsz | 
|---|
|  | 1085 | ,float nbsig1,float nbsig2,float nbsig3 | 
|---|
|  | 1086 | ,float binsg,float frac,int modu,int deb) | 
|---|
|  | 1087 | // | 
|---|
|  | 1088 | //      Calcul automatique du fond de ciel et du sigma ciel en utilisant | 
|---|
|  | 1089 | //      les methodes precedentes et en calculant au mieux le binning. | 
|---|
|  | 1090 | //| lowbad,highbad: dynamoque utile de l'image (ADU) | 
|---|
|  | 1091 | //| pvsz : taille du pave a traiter (centre au milieu de l'image) | 
|---|
|  | 1092 | //| nbsig1 : pour EstimeFdSg  -> calcul sgbmax (def=3.5). | 
|---|
|  | 1093 | //| nbsig2 : pour FondCiel (histo entre X maxi +/- nbsig2*sgbmax | 
|---|
|  | 1094 | //|                        nbin = 2.*nbsig2*binsg) (def=5). | 
|---|
|  | 1095 | //| nbsig3 : pour SigmaCiel (histo entre 0 +/- nbsig3*sgbmax | 
|---|
|  | 1096 | //|                         nbin = 2.*nbsig3*binsg) (def=5). | 
|---|
|  | 1097 | //| binsg : taille du bin pour les histos de FondCiel et SigmaCiel | 
|---|
|  | 1098 | //|                        (def=0.33) | 
|---|
|  | 1099 | //| frac : pour EstimeFdSg(...,frac,...)  (def=0.33) | 
|---|
|  | 1100 | //-- | 
|---|
|  | 1101 | { | 
|---|
|  | 1102 | if(pvsz<=0) pvsz = 100; | 
|---|
|  | 1103 | if(nbsig1<=0) nbsig1 = 3.5; | 
|---|
|  | 1104 | if(nbsig2<=0) nbsig2 = 5.0; | 
|---|
|  | 1105 | if(nbsig3<=0) nbsig3 = 5.0; | 
|---|
|  | 1106 | if(binsg<=0) binsg = 0.33; binsg = 1./binsg; | 
|---|
|  | 1107 | if(frac<=0.) frac = 0.33; | 
|---|
|  | 1108 | if(deb<0) deb=0; | 
|---|
|  | 1109 | int lpdb = (deb>=3) ? deb-2 : 0; | 
|---|
|  | 1110 | int envd = 0; | 
|---|
|  | 1111 | GetIntEnv("PDEBUG_FOND", envd); | 
|---|
|  | 1112 | if (lpdb < envd) lpdb = envd; | 
|---|
|  | 1113 | if (deb < envd) deb = envd; | 
|---|
|  | 1114 | float xbmax = 0., sgbmax = 0.; | 
|---|
|  | 1115 | int nbin,rc; | 
|---|
|  | 1116 | float xmin,xmax,binw,means; | 
|---|
|  | 1117 |  | 
|---|
|  | 1118 | // creation sous image | 
|---|
|  | 1119 | int pvsx = pvsz, pvsy = pvsz; | 
|---|
|  | 1120 | if( pvsx > XSize() ) pvsx = XSize(); | 
|---|
|  | 1121 | if( pvsy > YSize() ) pvsy = YSize(); | 
|---|
|  | 1122 | Image<T> *ssima = NULL; | 
|---|
|  | 1123 | bool cree = false; | 
|---|
|  | 1124 | if( pvsx == XSize() && pvsy == YSize() ) { | 
|---|
|  | 1125 | ssima = this; | 
|---|
|  | 1126 | } else { | 
|---|
|  | 1127 | int orgx = XSize()/2 - pvsx/2;  if( orgx < 0 ) orgx = 0; | 
|---|
|  | 1128 | int orgy = YSize()/2 - pvsy/2;  if( orgy < 0 ) orgy = 0; | 
|---|
|  | 1129 | if( orgx + pvsx > XSize() ) pvsx = XSize() - orgx; | 
|---|
|  | 1130 | if( orgy + pvsy > YSize() ) pvsy = YSize() - orgy; | 
|---|
|  | 1131 | ssima = new Image<T>(pvsx,pvsy); | 
|---|
|  | 1132 | cree = true; | 
|---|
|  | 1133 | CopieImageF(*ssima,*this,orgx,orgy,pvsx,pvsy,0,0,0.,0.); | 
|---|
|  | 1134 | } | 
|---|
|  | 1135 |  | 
|---|
|  | 1136 | // moyenne et sigma approches sur sous-image | 
|---|
|  | 1137 | rc = ssima->EstimeFdSg(xbmax,sgbmax,nbsig1,frac,lowbad,highbad,deb-1); | 
|---|
|  | 1138 | if( cree ) delete ssima; | 
|---|
|  | 1139 | if(rc<0) return -2; | 
|---|
|  | 1140 | fond = xbmax; | 
|---|
|  | 1141 | sigmaFond = sgbmax; | 
|---|
|  | 1142 |  | 
|---|
|  | 1143 | // bin entier... pas forcement necessaire. | 
|---|
|  | 1144 | xmin = xbmax - nbsig2*sgbmax; | 
|---|
|  | 1145 | xmax = xbmax + nbsig2*sgbmax; | 
|---|
|  | 1146 | nbin = (int)(2.*nbsig2*binsg); if(nbin<5) nbin=5; | 
|---|
|  | 1147 | binw = (xmax-xmin)/nbin; | 
|---|
|  | 1148 | if(deb>0) cout<<"bin auto: xmin="<<xmin<<" xmax="<<xmax | 
|---|
|  | 1149 | <<" nbin="<<nbin<<" binw="<<binw<<endl; | 
|---|
|  | 1150 | HBinInt(nbin,xmin,xmax); | 
|---|
|  | 1151 | binw = (xmax-xmin)/nbin; | 
|---|
|  | 1152 | if(deb>0) cout<<"bin auto entier:  nbin="<<nbin<<" binw="<<binw | 
|---|
|  | 1153 | <<" entre "<<xmin<<","<<xmax<<endl; | 
|---|
|  | 1154 |  | 
|---|
|  | 1155 | // Optimisation de modu | 
|---|
|  | 1156 | if( modu <= 0 ) { | 
|---|
|  | 1157 | // 4 fois plus de pixels que dans le pre-pave | 
|---|
|  | 1158 | int npv = 4*pvsz*pvsz; | 
|---|
|  | 1159 | int nima = XSize()*YSize(); | 
|---|
|  | 1160 | if( npv >= nima || nima < 10000 ) modu = 1; | 
|---|
|  | 1161 | else modu = (int)( (float) nima / (float) npv ); | 
|---|
|  | 1162 | if(deb) cout<<"modulo choisi a "<<modu<<endl; | 
|---|
|  | 1163 | } | 
|---|
|  | 1164 |  | 
|---|
|  | 1165 | // moyenne evoluee | 
|---|
|  | 1166 | TRY { | 
|---|
|  | 1167 | fond = FondCiel(nbin,xmin,xmax,3,0.5,modu,lpdb); | 
|---|
|  | 1168 | if(deb>0) cout <<"Fond de ciel = "<<fond<< endl; | 
|---|
|  | 1169 | } CATCHALL { | 
|---|
|  | 1170 | if(deb>0) cout << "Echec FondCiel" << endl; | 
|---|
|  | 1171 | return(-3); | 
|---|
|  | 1172 | } ENDTRY | 
|---|
|  | 1173 |  | 
|---|
|  | 1174 | // sigma evolue | 
|---|
|  | 1175 | TRY { | 
|---|
|  | 1176 | float dyn = nbsig3*sgbmax; | 
|---|
|  | 1177 | int nbins = (int) (2.*nbsig3*binsg); | 
|---|
|  | 1178 | float binws = (2.*dyn)/nbins; | 
|---|
|  | 1179 | sigmaFond = SigmaCiel(nbins,-dyn,dyn,means,lowbad,highbad,4.,modu,lpdb); | 
|---|
|  | 1180 | if(deb>0) cout <<"Sigma fond de ciel = "<<sigmaFond | 
|---|
|  | 1181 | <<" (ms="<<means<<") sur "<<nbins | 
|---|
|  | 1182 | <<" bins de largeur "<<binws<< endl; | 
|---|
|  | 1183 | } CATCHALL { | 
|---|
|  | 1184 | if(deb>0) cout << "Echec SigmaCiel" << endl; | 
|---|
|  | 1185 | return(-4); | 
|---|
|  | 1186 | } ENDTRY | 
|---|
|  | 1187 |  | 
|---|
|  | 1188 | // Impression finale | 
|---|
|  | 1189 | if(deb) cout <<"ImgSigmaCiel: fond= "<<xbmax<<" / "<< fond | 
|---|
|  | 1190 | <<"   sigma= "<<sgbmax<<" / "<<sigmaFond<<endl; | 
|---|
|  | 1191 |  | 
|---|
|  | 1192 | return 0; | 
|---|
|  | 1193 | } | 
|---|
|  | 1194 |  | 
|---|
|  | 1195 |  | 
|---|
|  | 1196 |  | 
|---|
|  | 1197 | /*  .......................................................  */ | 
|---|
|  | 1198 | /*         Fonctions de copie d'images et de paves           */ | 
|---|
|  | 1199 | /*  .......................................................  */ | 
|---|
|  | 1200 |  | 
|---|
|  | 1201 |  | 
|---|
|  | 1202 | /* Nouvelle-Fonction */ | 
|---|
|  | 1203 | template <class T2, class T1> | 
|---|
|  | 1204 | void CopieImageF(Image<T2>& copie, Image<T1> const& pim, | 
|---|
|  | 1205 | int org_pim_x, int org_pim_y,            /* origine pave a copier */ | 
|---|
|  | 1206 | int pim_lpav_x, int pim_lpav_y,          /* largeur pave a copier */ | 
|---|
|  | 1207 | int org_copie_x, int org_copie_y,        /* origine copie         */ | 
|---|
|  | 1208 | double cutmin, double cutmax)            /* coupure pour max range*/ | 
|---|
|  | 1209 |  | 
|---|
|  | 1210 | /* Copie d'une image (pim) ds l'autre (copie) a partir d'un  */ | 
|---|
|  | 1211 | /* offset specifie en pixel                                  */ | 
|---|
|  | 1212 | /* attention: pas d'offset -> org_x = org_y = 0              */ | 
|---|
|  | 1213 | { | 
|---|
|  | 1214 | int i,j; | 
|---|
|  | 1215 | // int x,y;  $CHECK$ Reza 21/06/99 changement de methode de calcul des bornes | 
|---|
|  | 1216 | const T1* pt_pim; | 
|---|
|  | 1217 | T2* pt_copie; | 
|---|
|  | 1218 | double pim_pix; | 
|---|
|  | 1219 | int l_copie_x,l_copie_y; | 
|---|
|  | 1220 | int step_copie_x; | 
|---|
|  | 1221 | int step_pim_x; | 
|---|
|  | 1222 | int pim_siz_x, pim_siz_y; | 
|---|
|  | 1223 | // int copie_siz_x, copie_siz_y;  $CHECK$ Reza 21/06/99 changement de methode de calcul des bornes | 
|---|
|  | 1224 | int switch_copie; | 
|---|
|  | 1225 |  | 
|---|
|  | 1226 | pim_siz_x=pim.XSize(); | 
|---|
|  | 1227 | pim_siz_y=pim.YSize(); | 
|---|
|  | 1228 | if((org_pim_x < 0) || (org_pim_x > pim_siz_x)) | 
|---|
|  | 1229 | { cout<< "CopieImage_erreure : org_pim_x: " <<org_pim_x<<" < 0 ou > a "<<pim_siz_x<<endl; | 
|---|
|  | 1230 | THROW(rangeCheckErr);} | 
|---|
|  | 1231 | if((org_pim_y < 0) || (org_pim_y > pim_siz_y)) | 
|---|
|  | 1232 | { cout<< "CopieImage_erreure : org_pim_y: " <<org_pim_y<<" < 0 ou > a "<<pim_siz_y<<endl; | 
|---|
|  | 1233 | THROW(rangeCheckErr);} | 
|---|
|  | 1234 |  | 
|---|
|  | 1235 | if( (org_copie_x < 0) || (org_copie_x > copie.XSize()) ) | 
|---|
|  | 1236 | { cout<< "CopieImage_erreure : org_copie_x: " <<org_copie_x<<" < 0 ou > a "<< copie.XSize() << endl; | 
|---|
|  | 1237 | THROW(rangeCheckErr);} | 
|---|
|  | 1238 | if( (org_copie_y < 0) || (org_copie_y > copie.YSize()) ) | 
|---|
|  | 1239 | { cout<< "CopieImage_erreure : org_copie_y: " <<org_copie_y<<" < 0 ou > a "<< copie.YSize() << endl; | 
|---|
|  | 1240 | THROW(rangeCheckErr);} | 
|---|
|  | 1241 |  | 
|---|
|  | 1242 | /* $CHECK$ Reza 21/06/99  Changement de methode de calcul ------ | 
|---|
|  | 1243 | $CHECK$ Reza 21/06/99 , je change la taille a copier en fonction de l'origine de copie | 
|---|
|  | 1244 | copie_siz_x=copie.XSize()-org_copie_x; | 
|---|
|  | 1245 | copie_siz_y=copie.YSize()-org_copie_y; | 
|---|
|  | 1246 |  | 
|---|
|  | 1247 | x=pim_lpav_x; | 
|---|
|  | 1248 | if(x > (pim_siz_x-org_pim_x)) x=pim_siz_x-org_pim_x; | 
|---|
|  | 1249 | step_pim_x = pim_siz_x-x; | 
|---|
|  | 1250 |  | 
|---|
|  | 1251 | if(x < copie_siz_x) | 
|---|
|  | 1252 | { | 
|---|
|  | 1253 | l_copie_x=x; | 
|---|
|  | 1254 | step_copie_x=copie_siz_x-x; | 
|---|
|  | 1255 | } | 
|---|
|  | 1256 | else | 
|---|
|  | 1257 | { | 
|---|
|  | 1258 | l_copie_x=copie_siz_x; | 
|---|
|  | 1259 | step_copie_x=0; | 
|---|
|  | 1260 | step_pim_x=step_pim_x+x-copie_siz_x; | 
|---|
|  | 1261 | } | 
|---|
|  | 1262 |  | 
|---|
|  | 1263 | if(org_copie_x  > 0 ) | 
|---|
|  | 1264 | { | 
|---|
|  | 1265 | int x=copie_siz_x-org_copie_x; | 
|---|
|  | 1266 | if(x < l_copie_x ) | 
|---|
|  | 1267 | { | 
|---|
|  | 1268 | step_pim_x=step_pim_x+l_copie_x-x; | 
|---|
|  | 1269 | l_copie_x=x; | 
|---|
|  | 1270 | step_copie_x=org_copie_x; | 
|---|
|  | 1271 | } | 
|---|
|  | 1272 | else | 
|---|
|  | 1273 | { | 
|---|
|  | 1274 | step_copie_x=copie_siz_x-l_copie_x; | 
|---|
|  | 1275 | } | 
|---|
|  | 1276 | } | 
|---|
|  | 1277 |  | 
|---|
|  | 1278 | y=pim_lpav_y; | 
|---|
|  | 1279 | if(y > (pim_siz_y-org_pim_y)) y=pim_siz_y-org_pim_y; | 
|---|
|  | 1280 |  | 
|---|
|  | 1281 | if(y < copie_siz_y) | 
|---|
|  | 1282 | { | 
|---|
|  | 1283 | l_copie_y=y; | 
|---|
|  | 1284 | } | 
|---|
|  | 1285 | else | 
|---|
|  | 1286 | { | 
|---|
|  | 1287 | l_copie_y=copie_siz_y; | 
|---|
|  | 1288 | } | 
|---|
|  | 1289 |  | 
|---|
|  | 1290 | */ | 
|---|
|  | 1291 |  | 
|---|
|  | 1292 | l_copie_x = copie.XSize()-org_copie_x; | 
|---|
|  | 1293 | l_copie_y = copie.YSize()-org_copie_y; | 
|---|
|  | 1294 | if ( pim_lpav_x > (pim.XSize()-org_pim_x) )  pim_lpav_x = pim.XSize()-org_pim_x; | 
|---|
|  | 1295 | if ( pim_lpav_y > (pim.YSize()-org_pim_y) )  pim_lpav_y = pim.YSize()-org_pim_y; | 
|---|
|  | 1296 | if ( (pim_lpav_x > 0) && (l_copie_x > pim_lpav_x) )  l_copie_x = pim_lpav_x; | 
|---|
|  | 1297 | if ( (pim_lpav_y > 0) && (l_copie_y > pim_lpav_y) )  l_copie_y = pim_lpav_y; | 
|---|
|  | 1298 | step_pim_x = pim.XSize()-l_copie_x; | 
|---|
|  | 1299 | step_copie_x = copie.XSize()-l_copie_x; | 
|---|
|  | 1300 |  | 
|---|
|  | 1301 | pt_pim  = pim.ImagePtr() + org_pim_y*pim.XSize() + org_pim_x; | 
|---|
|  | 1302 | pt_copie=copie.ImagePtr() + org_copie_y*copie.XSize() + org_copie_x; | 
|---|
|  | 1303 |  | 
|---|
|  | 1304 | switch((int)ConvType(*pt_pim,*pt_copie)) { | 
|---|
|  | 1305 | case t_same: case t_up: | 
|---|
|  | 1306 | switch_copie=0; | 
|---|
|  | 1307 | break; | 
|---|
|  | 1308 | case t_spe: case t_down: | 
|---|
|  | 1309 | switch_copie=1; | 
|---|
|  | 1310 | break; | 
|---|
|  | 1311 | } | 
|---|
|  | 1312 |  | 
|---|
|  | 1313 | if(cutmin < cutmax) switch_copie *= 2; | 
|---|
|  | 1314 |  | 
|---|
|  | 1315 | switch(switch_copie) { | 
|---|
|  | 1316 | case 0: | 
|---|
|  | 1317 | for (j=0; j< l_copie_y; j++) | 
|---|
|  | 1318 | { | 
|---|
|  | 1319 | for(i=0; i< l_copie_x; i++) | 
|---|
|  | 1320 | { | 
|---|
|  | 1321 | *pt_copie++ =(T2)*pt_pim++; | 
|---|
|  | 1322 | } | 
|---|
|  | 1323 | pt_pim   += step_pim_x; | 
|---|
|  | 1324 | pt_copie += step_copie_x; | 
|---|
|  | 1325 | } | 
|---|
|  | 1326 | break; | 
|---|
|  | 1327 | case 1: | 
|---|
|  | 1328 | for (j=0; j< l_copie_y; j++) | 
|---|
|  | 1329 | { | 
|---|
|  | 1330 | for(i=0; i< l_copie_x; i++) | 
|---|
|  | 1331 | { | 
|---|
|  | 1332 | pim_pix = *pt_pim++; | 
|---|
|  | 1333 | *pt_copie++ = PutInRange(pim_pix, *pt_copie); | 
|---|
|  | 1334 | } | 
|---|
|  | 1335 | pt_pim   += step_pim_x; | 
|---|
|  | 1336 | pt_copie += step_copie_x; | 
|---|
|  | 1337 | } | 
|---|
|  | 1338 | break; | 
|---|
|  | 1339 | case 2: | 
|---|
|  | 1340 | for (j=0; j< l_copie_y; j++) | 
|---|
|  | 1341 | { | 
|---|
|  | 1342 | for(i=0; i< l_copie_x; i++) | 
|---|
|  | 1343 | { | 
|---|
|  | 1344 | pim_pix = *pt_pim++; | 
|---|
|  | 1345 | *pt_copie++ = (T2)SharePix(pim_pix,*pt_copie,cutmin,cutmax); | 
|---|
|  | 1346 | } | 
|---|
|  | 1347 | pt_pim   += step_pim_x; | 
|---|
|  | 1348 | pt_copie += step_copie_x; | 
|---|
|  | 1349 | } | 
|---|
|  | 1350 | break; | 
|---|
|  | 1351 | } | 
|---|
|  | 1352 |  | 
|---|
|  | 1353 | copie.SetOrg( pim.XOrg()+org_pim_x-org_copie_x, pim.YOrg()+org_pim_y-org_copie_y); | 
|---|
|  | 1354 | } | 
|---|
|  | 1355 |  | 
|---|
|  | 1356 |  | 
|---|
|  | 1357 | /* Nouvelle-Fonction */ | 
|---|
|  | 1358 | template <class T2, class T1> | 
|---|
|  | 1359 | void CopieImage(Image<T2>& copie , Image<T1> const& pim) | 
|---|
|  | 1360 | { | 
|---|
|  | 1361 | if (!pim.ImagePtr())   THROW(nullPtrErr); | 
|---|
|  | 1362 | if (!copie.ImagePtr()) copie.Allocate(pim.XSize(),pim.YSize()); | 
|---|
|  | 1363 |  | 
|---|
|  | 1364 | CopieImageF(copie, pim,0,0,pim.XSize(),pim.YSize(),0,0,0., 0.); | 
|---|
|  | 1365 | } | 
|---|
|  | 1366 |  | 
|---|
|  | 1367 | /* Nouvelle-Fonction */ | 
|---|
|  | 1368 | template <class T2, class T1> | 
|---|
|  | 1369 | void CopieImage(Image<T2>& copie , Image<T1> const& pim, | 
|---|
|  | 1370 | int org_pim_x    , int org_pim_y, | 
|---|
|  | 1371 | int pim_lpav_x   , int pim_lpav_y, | 
|---|
|  | 1372 | int org_copie_x  , int org_copie_y, | 
|---|
|  | 1373 | double cutmin    , double cutmax ) | 
|---|
|  | 1374 | { | 
|---|
|  | 1375 | if (!pim.ImagePtr())   THROW(nullPtrErr); | 
|---|
|  | 1376 | if (!copie.ImagePtr()) THROW(nullPtrErr); | 
|---|
|  | 1377 | copie.SetOrg( pim.XOrg()+org_pim_x-org_copie_x, pim.YOrg()+org_pim_y-org_copie_y); | 
|---|
|  | 1378 | // copie.SetOrg(org_pim_x,org_pim_y); | 
|---|
|  | 1379 |  | 
|---|
|  | 1380 | /* Reza 28/04/95 : Je protege pour le moment contre les pave en | 
|---|
|  | 1381 | dehors de l'image, mais je veux pouvoir copier des paves decale par | 
|---|
|  | 1382 | rapport aux bornes de l'image source  Re- CMV+Reza 30/09/96 */ | 
|---|
|  | 1383 | /* $CHECK$ Reza 21/06/99 - Ca devrait etre OK  */ | 
|---|
|  | 1384 | if ( (org_pim_x < 0) || (org_pim_y < 0) || | 
|---|
|  | 1385 | (org_pim_x >= pim.XSize() ) || (org_pim_y >= pim.YSize() ) || | 
|---|
|  | 1386 | ((org_pim_x+copie.XSize()) > pim.XSize()) || | 
|---|
|  | 1387 | ((org_pim_y+copie.YSize()) > pim.YSize()) ) copie.Zero(); | 
|---|
|  | 1388 |  | 
|---|
|  | 1389 | if ( (org_pim_x >= pim.XSize()) || (org_pim_y >= pim.YSize()) ) { | 
|---|
|  | 1390 | copie.SetOrg( pim.XOrg()+org_pim_x-org_copie_x, pim.YOrg()+org_pim_y-org_copie_y); | 
|---|
|  | 1391 | return; | 
|---|
|  | 1392 | } | 
|---|
|  | 1393 | // if ( (org_pim_x < 0) || (org_pim_y < 0) || | 
|---|
|  | 1394 | //      (org_pim_x >= pim.XSize() ) || (org_pim_y >= pim.YSize() )) return; | 
|---|
|  | 1395 |  | 
|---|
|  | 1396 | int oox = org_pim_x; | 
|---|
|  | 1397 | int ooy = org_pim_y; | 
|---|
|  | 1398 | int ocx = org_copie_x; | 
|---|
|  | 1399 | int ocy = org_copie_y; | 
|---|
|  | 1400 | if (oox < 0)  { ocx -= oox;  oox = 0; } | 
|---|
|  | 1401 | if (ooy < 0)  { ocy -= ooy;  ooy = 0; } | 
|---|
|  | 1402 | /*  Fin de $CHECK$  */ | 
|---|
|  | 1403 |  | 
|---|
|  | 1404 | // void CopieImageF(Image<T2>& copie, Image<T1> const& pim, | 
|---|
|  | 1405 | //         int org_pim_x, int org_pim_y,            /* origine pave a copier */ | 
|---|
|  | 1406 | //         int pim_lpav_x, int pim_lpav_y,          /* largeur pave a copier */ | 
|---|
|  | 1407 | //         int org_copie_x, int org_copie_y,        /* origine copie         */ | 
|---|
|  | 1408 | //         double cutmin, double cutmax)            /* coupure pour max range*/ | 
|---|
|  | 1409 |  | 
|---|
|  | 1410 | if((pim_lpav_x <= 0) || (pim_lpav_x > pim.XSize())) pim_lpav_x=pim.XSize(); | 
|---|
|  | 1411 | if((pim_lpav_y <= 0) || (pim_lpav_y > pim.YSize())) pim_lpav_y=pim.YSize(); | 
|---|
|  | 1412 | try { | 
|---|
|  | 1413 | CopieImageF(copie, pim, oox, ooy, | 
|---|
|  | 1414 | pim_lpav_x, pim_lpav_y, | 
|---|
|  | 1415 | ocx, ocy, cutmin,cutmax); | 
|---|
|  | 1416 | }  catch(RangeCheckError) { | 
|---|
|  | 1417 | // $PLANCKCHECK$   if (merr != rangeCheckErr) THROW(merr);  // Re- $CHECK$ CMV+Reza 30/09/96 | 
|---|
|  | 1418 | } ENDTRY | 
|---|
|  | 1419 |  | 
|---|
|  | 1420 | copie.SetOrg( pim.XOrg()+org_pim_x-org_copie_x, pim.YOrg()+org_pim_y-org_copie_y); | 
|---|
|  | 1421 | } | 
|---|
|  | 1422 |  | 
|---|
|  | 1423 |  | 
|---|
|  | 1424 | /* Nouvelle-Fonction */ | 
|---|
|  | 1425 | template <class T2, class T1> | 
|---|
|  | 1426 | void CopiePave ( Image<T2>& pave , Image<T1> const& pim, | 
|---|
|  | 1427 | float xc, float yc, | 
|---|
|  | 1428 | double cutmin, double cutmax) | 
|---|
|  | 1429 | { | 
|---|
|  | 1430 | int ix, iy; | 
|---|
|  | 1431 |  | 
|---|
|  | 1432 | xc -= 0.5 * (float)(pave.XSize()-1); | 
|---|
|  | 1433 | yc -= 0.5 * (float)(pave.YSize()-1); | 
|---|
|  | 1434 | //  CopiePave tient compte de l'origine de l'image de depart   Reza 18/9/96 | 
|---|
|  | 1435 | xc -= pim.XOrg();     yc -= pim.YOrg(); | 
|---|
|  | 1436 |  | 
|---|
|  | 1437 | if ( xc >= 0.)  ix = (int)xc; | 
|---|
|  | 1438 | else ix = (int)(xc-1.0); | 
|---|
|  | 1439 | if ( yc >= 0.)  iy = (int)yc; | 
|---|
|  | 1440 | else iy = (int)(yc-1.0); | 
|---|
|  | 1441 | CopieImage(pave, pim, ix, iy, 0, 0, 0, 0, cutmin, cutmax ) ; | 
|---|
|  | 1442 | } | 
|---|
|  | 1443 |  | 
|---|
|  | 1444 |  | 
|---|
|  | 1445 | /* Nouvelle-Fonction */ | 
|---|
|  | 1446 | template <class T> | 
|---|
|  | 1447 | void RzCopieImage(Image<T>& copie, RzImage const& pim, | 
|---|
|  | 1448 | int org_pim_x , int org_pim_y, | 
|---|
|  | 1449 | int pim_lpav_x, int pim_lpav_y, | 
|---|
|  | 1450 | int org_copie_x, int org_copie_y, | 
|---|
|  | 1451 | double cutmin , double cutmax) | 
|---|
|  | 1452 | { | 
|---|
|  | 1453 | switch (pim.PixelType()) { | 
|---|
|  | 1454 | case kuint_2: { | 
|---|
|  | 1455 | ImageU2 src((RzImage&)pim); | 
|---|
|  | 1456 | CopieImage(copie, src, org_pim_x , org_pim_y, | 
|---|
|  | 1457 | pim_lpav_x, pim_lpav_y, org_copie_x, | 
|---|
|  | 1458 | org_copie_y, cutmin, cutmax ); | 
|---|
|  | 1459 | break; | 
|---|
|  | 1460 | } | 
|---|
|  | 1461 | case kint_2: { | 
|---|
|  | 1462 | ImageI2 src((RzImage&)pim); | 
|---|
|  | 1463 | CopieImage(copie, src, org_pim_x , org_pim_y, | 
|---|
|  | 1464 | pim_lpav_x, pim_lpav_y, org_copie_x, | 
|---|
|  | 1465 | org_copie_y, cutmin, cutmax ); | 
|---|
|  | 1466 | break; | 
|---|
|  | 1467 | } | 
|---|
|  | 1468 | case kint_4: { | 
|---|
|  | 1469 | ImageI4 src((RzImage&)pim); | 
|---|
|  | 1470 | CopieImage(copie, src, org_pim_x , org_pim_y, | 
|---|
|  | 1471 | pim_lpav_x, pim_lpav_y, org_copie_x, | 
|---|
|  | 1472 | org_copie_y, cutmin, cutmax ); | 
|---|
|  | 1473 | break; | 
|---|
|  | 1474 | } | 
|---|
|  | 1475 | case kr_4: { | 
|---|
|  | 1476 | ImageR4 src((RzImage&)pim); | 
|---|
|  | 1477 | CopieImage(copie, src, org_pim_x , org_pim_y, | 
|---|
|  | 1478 | pim_lpav_x, pim_lpav_y, org_copie_x, | 
|---|
|  | 1479 | org_copie_y, cutmin, cutmax ); | 
|---|
|  | 1480 | break; | 
|---|
|  | 1481 | } | 
|---|
|  | 1482 | case kr_8: | 
|---|
|  | 1483 | case kuint_4: | 
|---|
|  | 1484 | case kuint_1: | 
|---|
|  | 1485 | case kint_1: | 
|---|
|  | 1486 | cerr << " RzCopieImage(...) / Error, Unsupported image type (kr_8/ kuint_4/ kuint_1/ kint_1) " | 
|---|
|  | 1487 | << (int)pim.PixelType() << "\n"; | 
|---|
|  | 1488 | break; | 
|---|
|  | 1489 | default: | 
|---|
|  | 1490 | cerr << " RzCopieImage(...) / Error, Unknown image type !" <<  (int)pim.PixelType() << "\n"; | 
|---|
|  | 1491 | break; | 
|---|
|  | 1492 | } | 
|---|
|  | 1493 | } | 
|---|
|  | 1494 |  | 
|---|
|  | 1495 |  | 
|---|
|  | 1496 | /* Nouvelle-Fonction */ | 
|---|
|  | 1497 | template <class T> | 
|---|
|  | 1498 | void RzCopieImage(Image<T>& copie, RzImage const& pim) | 
|---|
|  | 1499 | { | 
|---|
|  | 1500 | switch (pim.PixelType()) { | 
|---|
|  | 1501 | case kuint_2: { | 
|---|
|  | 1502 | ImageU2 src((RzImage&)pim); | 
|---|
|  | 1503 | CopieImage(copie, src); | 
|---|
|  | 1504 | break; | 
|---|
|  | 1505 | } | 
|---|
|  | 1506 | case kint_2: { | 
|---|
|  | 1507 | ImageI2 src((RzImage&)pim); | 
|---|
|  | 1508 | CopieImage(copie, src); | 
|---|
|  | 1509 | break; | 
|---|
|  | 1510 | } | 
|---|
|  | 1511 | case kint_4: { | 
|---|
|  | 1512 | ImageI4 src((RzImage&)pim); | 
|---|
|  | 1513 | CopieImage(copie, src); | 
|---|
|  | 1514 | break; | 
|---|
|  | 1515 | } | 
|---|
|  | 1516 | case kr_4: { | 
|---|
|  | 1517 | ImageR4 src((RzImage&)pim); | 
|---|
|  | 1518 | CopieImage(copie, src); | 
|---|
|  | 1519 | break; | 
|---|
|  | 1520 | } | 
|---|
|  | 1521 | case kr_8: | 
|---|
|  | 1522 | case kuint_4: | 
|---|
|  | 1523 | case kuint_1: | 
|---|
|  | 1524 | case kint_1: | 
|---|
|  | 1525 | cerr << " RzCopieImage() / Error, Unsupported image type (kr_8/ kuint_4/ kuint_1/ kint_1) " | 
|---|
|  | 1526 | << (int)pim.PixelType() << "\n"; | 
|---|
|  | 1527 | break; | 
|---|
|  | 1528 | default: | 
|---|
|  | 1529 | cerr << " RzCopieImage() / Error, Unknown image type ! " <<  (int)pim.PixelType() << "\n"; | 
|---|
|  | 1530 | break; | 
|---|
|  | 1531 | } | 
|---|
|  | 1532 | } | 
|---|
|  | 1533 |  | 
|---|
|  | 1534 | /* Nouvelle-Fonction */ | 
|---|
|  | 1535 | template <class T> | 
|---|
|  | 1536 | void RzCopiePave(Image<T> & pave, RzImage const & pim, | 
|---|
|  | 1537 | float xc, float yc, | 
|---|
|  | 1538 | double cutmin, double cutmax) | 
|---|
|  | 1539 | { | 
|---|
|  | 1540 | int ix, iy; | 
|---|
|  | 1541 |  | 
|---|
|  | 1542 | xc -= 0.5 * (float)(pave.XSize()-1); | 
|---|
|  | 1543 | yc -= 0.5 * (float)(pave.YSize()-1); | 
|---|
|  | 1544 | //  RzCopiePave tient compte de l'origine de l'image de depart   Reza 18/9/96 | 
|---|
|  | 1545 | xc -= pim.XOrg();     yc -= pim.YOrg(); | 
|---|
|  | 1546 |  | 
|---|
|  | 1547 | if ( xc >= 0.)  ix = (int)xc; | 
|---|
|  | 1548 | else ix = (int)(xc-1.0); | 
|---|
|  | 1549 | if ( yc >= 0.)  iy = (int)yc; | 
|---|
|  | 1550 | else iy = (int)(yc-1.0); | 
|---|
|  | 1551 |  | 
|---|
|  | 1552 | RzCopieImage(pave, pim, ix, iy, 0, 0, 0, 0, cutmin, cutmax) ; | 
|---|
|  | 1553 | } | 
|---|
|  | 1554 |  | 
|---|
|  | 1555 |  | 
|---|
|  | 1556 | /* Nouvelle-Fonction */ | 
|---|
|  | 1557 | void RzPrintImage(RzImage & img) | 
|---|
|  | 1558 | { | 
|---|
|  | 1559 | switch (img.PixelType()) | 
|---|
|  | 1560 | { | 
|---|
|  | 1561 | case kuint_1: | 
|---|
|  | 1562 | { | 
|---|
|  | 1563 | ImageU1 src((RzImage&)img); | 
|---|
|  | 1564 | cout << src ; | 
|---|
|  | 1565 | break; | 
|---|
|  | 1566 | } | 
|---|
|  | 1567 | case kuint_2: | 
|---|
|  | 1568 | { | 
|---|
|  | 1569 | ImageU2 src((RzImage&)img); | 
|---|
|  | 1570 | cout << src ; | 
|---|
|  | 1571 | break; | 
|---|
|  | 1572 | } | 
|---|
|  | 1573 | case kint_2: | 
|---|
|  | 1574 | { | 
|---|
|  | 1575 | ImageI2 src((RzImage&)img); | 
|---|
|  | 1576 | cout << src ; | 
|---|
|  | 1577 | break; | 
|---|
|  | 1578 | } | 
|---|
|  | 1579 | case kint_4: | 
|---|
|  | 1580 | { | 
|---|
|  | 1581 | ImageI4 src((RzImage&)img); | 
|---|
|  | 1582 | cout << src ; | 
|---|
|  | 1583 | break; | 
|---|
|  | 1584 | } | 
|---|
|  | 1585 | case kr_4: | 
|---|
|  | 1586 | { | 
|---|
|  | 1587 | ImageR4 src((RzImage&)img); | 
|---|
|  | 1588 | cout << src ; | 
|---|
|  | 1589 | break; | 
|---|
|  | 1590 | } | 
|---|
|  | 1591 | case kr_8: | 
|---|
|  | 1592 | case kuint_4: | 
|---|
|  | 1593 | case kint_1: | 
|---|
|  | 1594 | cerr << " RzPrintImage() / Error, Unsupported image type (kr_8/kuint_4/ kint_1) " | 
|---|
|  | 1595 | << (int)img.PixelType() << "\n"; | 
|---|
|  | 1596 | break; | 
|---|
|  | 1597 | default: | 
|---|
|  | 1598 | cerr << " RzPrintImage() / Error, Unknown image type " <<  (int)img.PixelType() << "\n"; | 
|---|
|  | 1599 | break; | 
|---|
|  | 1600 | } | 
|---|
|  | 1601 | } | 
|---|
|  | 1602 |  | 
|---|
|  | 1603 |  | 
|---|
|  | 1604 | // ********** INSTANCES | 
|---|
|  | 1605 | #if defined(__xlC) || defined(__aCC__) | 
|---|
|  | 1606 | void instancetempcimage(int n) | 
|---|
|  | 1607 | { | 
|---|
|  | 1608 | // #pragma define_template | 
|---|
|  | 1609 | /* Cette fonction sert uniquement a forcer le compilo a instancier les | 
|---|
|  | 1610 | classes/fonctions template   */ | 
|---|
|  | 1611 |  | 
|---|
|  | 1612 | int m = n-50; | 
|---|
|  | 1613 | ImageU1  iu1(n,n), xiu1(m,m); | 
|---|
|  | 1614 | ImageU2  iu2(n,n), xiu2(m,m); | 
|---|
|  | 1615 | ImageI2  ii2(n,n), xii2(m,m); | 
|---|
|  | 1616 | ImageI4  ii4(n,n), xii4(m,m); | 
|---|
|  | 1617 | ImageR4  ir4(n,n), xir4(m,m); | 
|---|
|  | 1618 | RzImage  rzi(kr_4, n, n); | 
|---|
|  | 1619 |  | 
|---|
|  | 1620 | cout << iu1; | 
|---|
|  | 1621 | cout << iu2; | 
|---|
|  | 1622 | cout << ii2; | 
|---|
|  | 1623 | cout << ii4; | 
|---|
|  | 1624 | cout << ir4; | 
|---|
|  | 1625 |  | 
|---|
|  | 1626 | CopieImageF(iu2, xiu2, 50, 50); | 
|---|
|  | 1627 | CopieImageF(iu2, xii2, 50, 50); | 
|---|
|  | 1628 | CopieImageF(iu2, xii4, 50, 50); | 
|---|
|  | 1629 | CopieImageF(iu2, xir4, 50, 50); | 
|---|
|  | 1630 | CopieImageF(ii2, xiu2, 50, 50); | 
|---|
|  | 1631 | CopieImageF(ii2, xii2, 50, 50); | 
|---|
|  | 1632 | CopieImageF(ii2, xii4, 50, 50); | 
|---|
|  | 1633 | CopieImageF(ii2, xir4, 50, 50); | 
|---|
|  | 1634 | CopieImageF(ii4, xiu2, 50, 50); | 
|---|
|  | 1635 | CopieImageF(ii4, xii2, 50, 50); | 
|---|
|  | 1636 | CopieImageF(ii4, xii4, 50, 50); | 
|---|
|  | 1637 | CopieImageF(ii4, xir4, 50, 50); | 
|---|
|  | 1638 | CopieImageF(ir4, xiu2, 50, 50); | 
|---|
|  | 1639 | CopieImageF(ir4, xii2, 50, 50); | 
|---|
|  | 1640 | CopieImageF(ir4, xii4, 50, 50); | 
|---|
|  | 1641 | CopieImageF(ir4, xir4, 50, 50); | 
|---|
|  | 1642 |  | 
|---|
|  | 1643 | CopieImage(iu2, xiu2); | 
|---|
|  | 1644 | CopieImage(iu2, xii2); | 
|---|
|  | 1645 | CopieImage(iu2, xii4); | 
|---|
|  | 1646 | CopieImage(iu2, xir4); | 
|---|
|  | 1647 | CopieImage(ii2, xiu2); | 
|---|
|  | 1648 | CopieImage(ii2, xii2); | 
|---|
|  | 1649 | CopieImage(ii2, xii4); | 
|---|
|  | 1650 | CopieImage(ii2, xir4); | 
|---|
|  | 1651 | CopieImage(ii4, xiu2); | 
|---|
|  | 1652 | CopieImage(ii4, xii2); | 
|---|
|  | 1653 | CopieImage(ii4, xii4); | 
|---|
|  | 1654 | CopieImage(ii4, xir4); | 
|---|
|  | 1655 | CopieImage(ir4, xiu2); | 
|---|
|  | 1656 | CopieImage(ir4, xii2); | 
|---|
|  | 1657 | CopieImage(ir4, xii4); | 
|---|
|  | 1658 | CopieImage(ir4, xir4); | 
|---|
|  | 1659 |  | 
|---|
|  | 1660 | CopieImage(iu2, xiu2, 50, 50); | 
|---|
|  | 1661 | CopieImage(iu2, xii2, 50, 50); | 
|---|
|  | 1662 | CopieImage(iu2, xii4, 50, 50); | 
|---|
|  | 1663 | CopieImage(iu2, xir4, 50, 50); | 
|---|
|  | 1664 | CopieImage(ii2, xiu2, 50, 50); | 
|---|
|  | 1665 | CopieImage(ii2, xii2, 50, 50); | 
|---|
|  | 1666 | CopieImage(ii2, xii4, 50, 50); | 
|---|
|  | 1667 | CopieImage(ii2, xir4, 50, 50); | 
|---|
|  | 1668 | CopieImage(ii4, xiu2, 50, 50); | 
|---|
|  | 1669 | CopieImage(ii4, xii2, 50, 50); | 
|---|
|  | 1670 | CopieImage(ii4, xii4, 50, 50); | 
|---|
|  | 1671 | CopieImage(ii4, xir4, 50, 50); | 
|---|
|  | 1672 | CopieImage(ir4, xiu2, 50, 50); | 
|---|
|  | 1673 | CopieImage(ir4, xii2, 50, 50); | 
|---|
|  | 1674 | CopieImage(ir4, xii4, 50, 50); | 
|---|
|  | 1675 | CopieImage(ir4, xir4, 50, 50); | 
|---|
|  | 1676 |  | 
|---|
|  | 1677 | CopiePave(iu2, xiu2, (float)25., (float)25.); | 
|---|
|  | 1678 | CopiePave(iu2, xii2, (float)25., (float)25.); | 
|---|
|  | 1679 | CopiePave(iu2, xii4, (float)25., (float)25.); | 
|---|
|  | 1680 | CopiePave(iu2, xir4, (float)25., (float)25.); | 
|---|
|  | 1681 | CopiePave(ii2, xiu2, (float)25., (float)25.); | 
|---|
|  | 1682 | CopiePave(ii2, xii2, (float)25., (float)25.); | 
|---|
|  | 1683 | CopiePave(ii2, xii4, (float)25., (float)25.); | 
|---|
|  | 1684 | CopiePave(ii2, xir4, (float)25., (float)25.); | 
|---|
|  | 1685 | CopiePave(ii4, xiu2, (float)25., (float)25.); | 
|---|
|  | 1686 | CopiePave(ii4, xii2, (float)25., (float)25.); | 
|---|
|  | 1687 | CopiePave(ii4, xii4, (float)25.,(float) 25.); | 
|---|
|  | 1688 | CopiePave(ii4, xir4, (float)25., (float)25.); | 
|---|
|  | 1689 | CopiePave(ir4, xiu2, (float)25., (float)25.); | 
|---|
|  | 1690 | CopiePave(ir4, xii2, (float)25., (float)25.); | 
|---|
|  | 1691 | CopiePave(ir4, xii4, (float)25., (float)25.); | 
|---|
|  | 1692 | CopiePave(ir4, xir4, (float)25., (float)25.); | 
|---|
|  | 1693 |  | 
|---|
|  | 1694 | RzCopieImage(iu2, rzi, 50, 50); | 
|---|
|  | 1695 | RzCopieImage(ii2, rzi, 50, 50); | 
|---|
|  | 1696 | RzCopieImage(ii4, rzi, 50, 50); | 
|---|
|  | 1697 | RzCopieImage(ir4, rzi, 50, 50); | 
|---|
|  | 1698 |  | 
|---|
|  | 1699 | RzCopieImage(iu2, rzi); | 
|---|
|  | 1700 | RzCopieImage(ii2, rzi); | 
|---|
|  | 1701 | RzCopieImage(ii4, rzi); | 
|---|
|  | 1702 | RzCopieImage(ir4, rzi); | 
|---|
|  | 1703 |  | 
|---|
|  | 1704 | RzCopiePave(iu2, rzi, (float)25., (float)25.); | 
|---|
|  | 1705 | RzCopiePave(ii2, rzi, (float)25., (float)25.); | 
|---|
|  | 1706 | RzCopiePave(ii4, rzi, (float)25., (float)25.); | 
|---|
|  | 1707 | RzCopiePave(ir4, rzi, (float)25., (float)25.); | 
|---|
|  | 1708 |  | 
|---|
|  | 1709 | return; | 
|---|
|  | 1710 | } | 
|---|
|  | 1711 |  | 
|---|
|  | 1712 | #endif | 
|---|
|  | 1713 |  | 
|---|
|  | 1714 | #ifdef __CXX_PRAGMA_TEMPLATES__ | 
|---|
|  | 1715 | #pragma define_template Image<uint_1> | 
|---|
|  | 1716 | #pragma define_template Image<uint_2> | 
|---|
|  | 1717 | #pragma define_template Image<int_2> | 
|---|
|  | 1718 | #pragma define_template Image<int_4> | 
|---|
|  | 1719 | #pragma define_template Image<r_4> | 
|---|
|  | 1720 |  | 
|---|
|  | 1721 | // pour supprimer les message Warning: Unresolved: | 
|---|
|  | 1722 | //                                     __ls__XR7ostreamRC10Image__TUc | 
|---|
|  | 1723 |  | 
|---|
|  | 1724 | ostream& operator << (ostream& s, ImageU1 const& pim) | 
|---|
|  | 1725 | { | 
|---|
|  | 1726 | cout << "operator << (ostream, ImageU1) Not implemented ..." << endl; | 
|---|
|  | 1727 | return(s); | 
|---|
|  | 1728 | } | 
|---|
|  | 1729 |  | 
|---|
|  | 1730 | // CopieImageF | 
|---|
|  | 1731 | #pragma define_template CopieImageF < uint_1 , uint_1 > | 
|---|
|  | 1732 | #pragma define_template CopieImageF < uint_1 , uint_2 > | 
|---|
|  | 1733 | #pragma define_template CopieImageF < uint_1 , int_2 > | 
|---|
|  | 1734 | #pragma define_template CopieImageF < uint_1 , int_4 > | 
|---|
|  | 1735 | #pragma define_template CopieImageF < uint_1 , r_4 > | 
|---|
|  | 1736 |  | 
|---|
|  | 1737 | #pragma define_template CopieImageF < uint_2 , uint_2 > | 
|---|
|  | 1738 | #pragma define_template CopieImageF < uint_2 , int_2 > | 
|---|
|  | 1739 | #pragma define_template CopieImageF < uint_2 , int_4 > | 
|---|
|  | 1740 | #pragma define_template CopieImageF < uint_2 , r_4 > | 
|---|
|  | 1741 |  | 
|---|
|  | 1742 | #pragma define_template CopieImageF < int_2 , uint_2 > | 
|---|
|  | 1743 | #pragma define_template CopieImageF < int_2 , int_2 > | 
|---|
|  | 1744 | #pragma define_template CopieImageF < int_2 , int_4 > | 
|---|
|  | 1745 | #pragma define_template CopieImageF < int_2 , r_4 > | 
|---|
|  | 1746 |  | 
|---|
|  | 1747 | #pragma define_template CopieImageF < int_4 , uint_2 > | 
|---|
|  | 1748 | #pragma define_template CopieImageF < int_4 , int_2 > | 
|---|
|  | 1749 | #pragma define_template CopieImageF < int_4 , int_4 > | 
|---|
|  | 1750 | #pragma define_template CopieImageF < int_4 , r_4 > | 
|---|
|  | 1751 |  | 
|---|
|  | 1752 | #pragma define_template CopieImageF < r_4 , uint_2 > | 
|---|
|  | 1753 | #pragma define_template CopieImageF < r_4 , int_2 > | 
|---|
|  | 1754 | #pragma define_template CopieImageF < r_4 , int_4 > | 
|---|
|  | 1755 | #pragma define_template CopieImageF < r_4 , r_4 > | 
|---|
|  | 1756 |  | 
|---|
|  | 1757 | // CopieImage | 
|---|
|  | 1758 | #pragma define_template CopieImage < uint_2 , uint_2 > | 
|---|
|  | 1759 | #pragma define_template CopieImage < uint_2 , int_2 > | 
|---|
|  | 1760 | #pragma define_template CopieImage < uint_2 , int_4 > | 
|---|
|  | 1761 | #pragma define_template CopieImage < uint_2 , r_4 > | 
|---|
|  | 1762 |  | 
|---|
|  | 1763 | #pragma define_template CopieImage < int_2 , uint_2 > | 
|---|
|  | 1764 | #pragma define_template CopieImage < int_2 , int_2 > | 
|---|
|  | 1765 | #pragma define_template CopieImage < int_2 , int_4 > | 
|---|
|  | 1766 | #pragma define_template CopieImage < int_2 , r_4 > | 
|---|
|  | 1767 |  | 
|---|
|  | 1768 | #pragma define_template CopieImage < int_4 , uint_2 > | 
|---|
|  | 1769 | #pragma define_template CopieImage < int_4 , int_2 > | 
|---|
|  | 1770 | #pragma define_template CopieImage < int_4 , int_4 > | 
|---|
|  | 1771 | #pragma define_template CopieImage < int_4 , r_4 > | 
|---|
|  | 1772 |  | 
|---|
|  | 1773 | #pragma define_template CopieImage < r_4 , uint_2 > | 
|---|
|  | 1774 | #pragma define_template CopieImage < r_4 , int_2 > | 
|---|
|  | 1775 | #pragma define_template CopieImage < r_4 , int_4 > | 
|---|
|  | 1776 | #pragma define_template CopieImage < r_4 , r_4 > | 
|---|
|  | 1777 |  | 
|---|
|  | 1778 | // CopiePave | 
|---|
|  | 1779 | #pragma define_template CopiePave < uint_2 , uint_2 > | 
|---|
|  | 1780 | #pragma define_template CopiePave < uint_2 , int_2 > | 
|---|
|  | 1781 | #pragma define_template CopiePave < uint_2 , int_4 > | 
|---|
|  | 1782 | #pragma define_template CopiePave < uint_2 , r_4 > | 
|---|
|  | 1783 |  | 
|---|
|  | 1784 | #pragma define_template CopiePave < int_2 , uint_2 > | 
|---|
|  | 1785 | #pragma define_template CopiePave < int_2 , int_2 > | 
|---|
|  | 1786 | #pragma define_template CopiePave < int_2 , int_4 > | 
|---|
|  | 1787 | #pragma define_template CopiePave < int_2 , r_4 > | 
|---|
|  | 1788 |  | 
|---|
|  | 1789 | #pragma define_template CopiePave < int_4 , uint_2 > | 
|---|
|  | 1790 | #pragma define_template CopiePave < int_4 , int_2 > | 
|---|
|  | 1791 | #pragma define_template CopiePave < int_4 , int_4 > | 
|---|
|  | 1792 | #pragma define_template CopiePave < int_4 , r_4 > | 
|---|
|  | 1793 |  | 
|---|
|  | 1794 | #pragma define_template CopiePave < r_4 , uint_2 > | 
|---|
|  | 1795 | #pragma define_template CopiePave < r_4 , int_2 > | 
|---|
|  | 1796 | #pragma define_template CopiePave < r_4 , int_4 > | 
|---|
|  | 1797 | #pragma define_template CopiePave < r_4 , r_4 > | 
|---|
|  | 1798 |  | 
|---|
|  | 1799 | //RzCopieImage | 
|---|
|  | 1800 | #pragma define_template RzCopieImage < uint_2 > | 
|---|
|  | 1801 | #pragma define_template RzCopieImage < int_2 > | 
|---|
|  | 1802 | #pragma define_template RzCopieImage < int_4 > | 
|---|
|  | 1803 | #pragma define_template RzCopieImage < r_4 > | 
|---|
|  | 1804 |  | 
|---|
|  | 1805 | //RzCopiePave | 
|---|
|  | 1806 | #pragma define_template RzCopiePave < uint_2 > | 
|---|
|  | 1807 | #pragma define_template RzCopiePave < int_2 > | 
|---|
|  | 1808 | #pragma define_template RzCopiePave < int_4 > | 
|---|
|  | 1809 | #pragma define_template RzCopiePave < r_4 > | 
|---|
|  | 1810 |  | 
|---|
|  | 1811 |  | 
|---|
|  | 1812 | #endif | 
|---|
|  | 1813 |  | 
|---|
|  | 1814 |  | 
|---|
|  | 1815 | #if defined(ANSI_TEMPLATES) | 
|---|
|  | 1816 | template class Image<uint_1>; | 
|---|
|  | 1817 | template class Image<uint_2>; | 
|---|
|  | 1818 | template class Image<int_2>; | 
|---|
|  | 1819 | template class Image<int_4>; | 
|---|
|  | 1820 | template class Image<r_4>; | 
|---|
|  | 1821 |  | 
|---|
|  | 1822 | #if !defined(__aCC__)     // HP - aCC a du mal avec les fonctions templates | 
|---|
|  | 1823 |  | 
|---|
|  | 1824 | template void CopieImageF<uint_2, uint_2>(Image<uint_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1825 | template void CopieImageF<uint_2,  int_2>(Image<uint_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1826 | template void CopieImageF<uint_2,  int_4>(Image<uint_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1827 | template void CopieImageF<uint_2,    r_4>(Image<uint_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1828 | template void CopieImageF< int_2, uint_2>(Image< int_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1829 | template void CopieImageF< int_2,  int_2>(Image< int_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1830 | template void CopieImageF< int_2,  int_4>(Image< int_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1831 | template void CopieImageF< int_2,    r_4>(Image< int_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1832 | template void CopieImageF< int_4, uint_2>(Image< int_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1833 | template void CopieImageF< int_4,  int_2>(Image< int_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1834 | template void CopieImageF< int_4,  int_4>(Image< int_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1835 | template void CopieImageF< int_4,    r_4>(Image< int_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1836 | template void CopieImageF<   r_4, uint_2>(Image<   r_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1837 | template void CopieImageF<   r_4,  int_2>(Image<   r_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1838 | template void CopieImageF<   r_4,  int_4>(Image<   r_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1839 | template void CopieImageF<   r_4,    r_4>(Image<   r_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1840 |  | 
|---|
|  | 1841 | template void CopieImage<uint_2, uint_2>(Image<uint_2>&, Image<uint_2> const&); | 
|---|
|  | 1842 | template void CopieImage<uint_2,  int_2>(Image<uint_2>&, Image< int_2> const&); | 
|---|
|  | 1843 | template void CopieImage<uint_2,  int_4>(Image<uint_2>&, Image< int_4> const&); | 
|---|
|  | 1844 | template void CopieImage<uint_2,    r_4>(Image<uint_2>&, Image<   r_4> const&); | 
|---|
|  | 1845 | template void CopieImage< int_2, uint_2>(Image< int_2>&, Image<uint_2> const&); | 
|---|
|  | 1846 | template void CopieImage< int_2,  int_2>(Image< int_2>&, Image< int_2> const&); | 
|---|
|  | 1847 | template void CopieImage< int_2,  int_4>(Image< int_2>&, Image< int_4> const&); | 
|---|
|  | 1848 | template void CopieImage< int_2,    r_4>(Image< int_2>&, Image<   r_4> const&); | 
|---|
|  | 1849 | template void CopieImage< int_4, uint_2>(Image< int_4>&, Image<uint_2> const&); | 
|---|
|  | 1850 | template void CopieImage< int_4,  int_2>(Image< int_4>&, Image< int_2> const&); | 
|---|
|  | 1851 | template void CopieImage< int_4,  int_4>(Image< int_4>&, Image< int_4> const&); | 
|---|
|  | 1852 | template void CopieImage< int_4,    r_4>(Image< int_4>&, Image<   r_4> const&); | 
|---|
|  | 1853 | template void CopieImage<   r_4, uint_2>(Image<   r_4>&, Image<uint_2> const&); | 
|---|
|  | 1854 | template void CopieImage<   r_4,  int_2>(Image<   r_4>&, Image< int_2> const&); | 
|---|
|  | 1855 | template void CopieImage<   r_4,  int_4>(Image<   r_4>&, Image< int_4> const&); | 
|---|
|  | 1856 | template void CopieImage<   r_4,    r_4>(Image<   r_4>&, Image<   r_4> const&); | 
|---|
|  | 1857 |  | 
|---|
|  | 1858 | template void CopieImage<uint_2, uint_2>(Image<uint_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1859 | template void CopieImage<uint_2,  int_2>(Image<uint_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1860 | template void CopieImage<uint_2,  int_4>(Image<uint_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1861 | template void CopieImage<uint_2,    r_4>(Image<uint_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1862 | template void CopieImage< int_2, uint_2>(Image< int_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1863 | template void CopieImage< int_2,  int_2>(Image< int_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1864 | template void CopieImage< int_2,  int_4>(Image< int_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1865 | template void CopieImage< int_2,    r_4>(Image< int_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1866 | template void CopieImage< int_4, uint_2>(Image< int_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1867 | template void CopieImage< int_4,  int_2>(Image< int_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1868 | template void CopieImage< int_4,  int_4>(Image< int_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1869 | template void CopieImage< int_4,    r_4>(Image< int_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1870 | template void CopieImage<   r_4, uint_2>(Image<   r_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1871 | template void CopieImage<   r_4,  int_2>(Image<   r_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1872 | template void CopieImage<   r_4,  int_4>(Image<   r_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1873 | template void CopieImage<   r_4,    r_4>(Image<   r_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1874 |  | 
|---|
|  | 1875 | template void CopiePave<uint_2, uint_2>(Image<uint_2>&, Image<uint_2> const&, float, float, double, double); | 
|---|
|  | 1876 | template void CopiePave<uint_2,  int_2>(Image<uint_2>&, Image< int_2> const&, float, float, double, double); | 
|---|
|  | 1877 | template void CopiePave<uint_2,  int_4>(Image<uint_2>&, Image< int_4> const&, float, float, double, double); | 
|---|
|  | 1878 | template void CopiePave<uint_2,    r_4>(Image<uint_2>&, Image<   r_4> const&, float, float, double, double); | 
|---|
|  | 1879 | template void CopiePave< int_2, uint_2>(Image< int_2>&, Image<uint_2> const&, float, float, double, double); | 
|---|
|  | 1880 | template void CopiePave< int_2,  int_2>(Image< int_2>&, Image< int_2> const&, float, float, double, double); | 
|---|
|  | 1881 | template void CopiePave< int_2,  int_4>(Image< int_2>&, Image< int_4> const&, float, float, double, double); | 
|---|
|  | 1882 | template void CopiePave< int_2,    r_4>(Image< int_2>&, Image<   r_4> const&, float, float, double, double); | 
|---|
|  | 1883 | template void CopiePave< int_4, uint_2>(Image< int_4>&, Image<uint_2> const&, float, float, double, double); | 
|---|
|  | 1884 | template void CopiePave< int_4,  int_2>(Image< int_4>&, Image< int_2> const&, float, float, double, double); | 
|---|
|  | 1885 | template void CopiePave< int_4,  int_4>(Image< int_4>&, Image< int_4> const&, float, float, double, double); | 
|---|
|  | 1886 | template void CopiePave< int_4,    r_4>(Image< int_4>&, Image<   r_4> const&, float, float, double, double); | 
|---|
|  | 1887 | template void CopiePave<   r_4, uint_2>(Image<   r_4>&, Image<uint_2> const&, float, float, double, double); | 
|---|
|  | 1888 | template void CopiePave<   r_4,  int_2>(Image<   r_4>&, Image< int_2> const&, float, float, double, double); | 
|---|
|  | 1889 | template void CopiePave<   r_4,  int_4>(Image<   r_4>&, Image< int_4> const&, float, float, double, double); | 
|---|
|  | 1890 | template void CopiePave<   r_4,    r_4>(Image<   r_4>&, Image<   r_4> const&, float, float, double, double); | 
|---|
|  | 1891 |  | 
|---|
|  | 1892 |  | 
|---|
|  | 1893 | template void RzCopieImage<uint_2>(Image<uint_2> &, RzImage const &, int, int, int, int, int, int, double, double); | 
|---|
|  | 1894 | template void RzCopieImage< int_2>(Image< int_2> &, RzImage const &, int, int, int, int, int, int, double, double); | 
|---|
|  | 1895 | template void RzCopieImage< int_4>(Image< int_4> &, RzImage const &, int, int, int, int, int, int, double, double); | 
|---|
|  | 1896 | template void RzCopieImage<   r_4>(Image<   r_4> &, RzImage const &, int, int, int, int, int, int, double, double); | 
|---|
|  | 1897 |  | 
|---|
|  | 1898 | template void RzCopieImage<uint_2>(Image<uint_2> &, RzImage const &); | 
|---|
|  | 1899 | template void RzCopieImage< int_2>(Image< int_2> &, RzImage const &); | 
|---|
|  | 1900 | template void RzCopieImage< int_4>(Image< int_4> &, RzImage const &); | 
|---|
|  | 1901 | template void RzCopieImage<   r_4>(Image<   r_4> &, RzImage const &); | 
|---|
|  | 1902 |  | 
|---|
|  | 1903 | template void RzCopiePave<uint_2>(Image<uint_2> &, RzImage const &, float, float, double, double); | 
|---|
|  | 1904 | template void RzCopiePave< int_2>(Image< int_2> &, RzImage const &, float, float, double, double); | 
|---|
|  | 1905 | template void RzCopiePave< int_4>(Image< int_4> &, RzImage const &, float, float, double, double); | 
|---|
|  | 1906 | template void RzCopiePave<   r_4>(Image<   r_4> &, RzImage const &, float, float, double, double); | 
|---|
|  | 1907 |  | 
|---|
|  | 1908 | #endif   // Pb avec HP aCC | 
|---|
|  | 1909 |  | 
|---|
|  | 1910 | #endif | 
|---|
|  | 1911 |  | 
|---|
|  | 1912 |  | 
|---|
|  | 1913 | #ifdef __GNU_TEMPLATES__ | 
|---|
|  | 1914 | template class Image<bool>; | 
|---|
|  | 1915 | template class Image<uint_1>; | 
|---|
|  | 1916 | template class Image<uint_2>; | 
|---|
|  | 1917 | template class Image<int_2>; | 
|---|
|  | 1918 | template class Image<int_4>; | 
|---|
|  | 1919 | template class Image<r_4>; | 
|---|
|  | 1920 |  | 
|---|
|  | 1921 |  | 
|---|
|  | 1922 | template void CopieImageF(Image<uint_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1923 | template void CopieImageF(Image<uint_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1924 | template void CopieImageF(Image<uint_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1925 | template void CopieImageF(Image<uint_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1926 | template void CopieImageF(Image< int_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1927 | template void CopieImageF(Image< int_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1928 | template void CopieImageF(Image< int_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1929 | template void CopieImageF(Image< int_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1930 | template void CopieImageF(Image< int_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1931 | template void CopieImageF(Image< int_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1932 | template void CopieImageF(Image< int_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1933 | template void CopieImageF(Image< int_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1934 | template void CopieImageF(Image<   r_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1935 | template void CopieImageF(Image<   r_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1936 | template void CopieImageF(Image<   r_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1937 | template void CopieImageF(Image<   r_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1938 |  | 
|---|
|  | 1939 | template void CopieImage(Image<uint_2>&, Image<uint_2> const&); | 
|---|
|  | 1940 | template void CopieImage(Image<uint_2>&, Image< int_2> const&); | 
|---|
|  | 1941 | template void CopieImage(Image<uint_2>&, Image< int_4> const&); | 
|---|
|  | 1942 | template void CopieImage(Image<uint_2>&, Image<   r_4> const&); | 
|---|
|  | 1943 | template void CopieImage(Image< int_2>&, Image<uint_2> const&); | 
|---|
|  | 1944 | template void CopieImage(Image< int_2>&, Image< int_2> const&); | 
|---|
|  | 1945 | template void CopieImage(Image< int_2>&, Image< int_4> const&); | 
|---|
|  | 1946 | template void CopieImage(Image< int_2>&, Image<   r_4> const&); | 
|---|
|  | 1947 | template void CopieImage(Image< int_4>&, Image<uint_2> const&); | 
|---|
|  | 1948 | template void CopieImage(Image< int_4>&, Image< int_2> const&); | 
|---|
|  | 1949 | template void CopieImage(Image< int_4>&, Image< int_4> const&); | 
|---|
|  | 1950 | template void CopieImage(Image< int_4>&, Image<   r_4> const&); | 
|---|
|  | 1951 | template void CopieImage(Image<   r_4>&, Image<uint_2> const&); | 
|---|
|  | 1952 | template void CopieImage(Image<   r_4>&, Image< int_2> const&); | 
|---|
|  | 1953 | template void CopieImage(Image<   r_4>&, Image< int_4> const&); | 
|---|
|  | 1954 | template void CopieImage(Image<   r_4>&, Image<   r_4> const&); | 
|---|
|  | 1955 |  | 
|---|
|  | 1956 | template void CopieImage(Image<uint_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1957 | template void CopieImage(Image<uint_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1958 | template void CopieImage(Image<uint_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1959 | template void CopieImage(Image<uint_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1960 | template void CopieImage(Image< int_2>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1961 | template void CopieImage(Image< int_2>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1962 | template void CopieImage(Image< int_2>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1963 | template void CopieImage(Image< int_2>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1964 | template void CopieImage(Image< int_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1965 | template void CopieImage(Image< int_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1966 | template void CopieImage(Image< int_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1967 | template void CopieImage(Image< int_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1968 | template void CopieImage(Image<   r_4>&, Image<uint_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1969 | template void CopieImage(Image<   r_4>&, Image< int_2> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1970 | template void CopieImage(Image<   r_4>&, Image< int_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1971 | template void CopieImage(Image<   r_4>&, Image<   r_4> const&, int, int, int, int, int, int, double, double); | 
|---|
|  | 1972 |  | 
|---|
|  | 1973 | template void CopiePave(Image<uint_2>&, Image<uint_2> const&, float, float, double, double); | 
|---|
|  | 1974 | template void CopiePave(Image<uint_2>&, Image< int_2> const&, float, float, double, double); | 
|---|
|  | 1975 | template void CopiePave(Image<uint_2>&, Image< int_4> const&, float, float, double, double); | 
|---|
|  | 1976 | template void CopiePave(Image<uint_2>&, Image<   r_4> const&, float, float, double, double); | 
|---|
|  | 1977 | template void CopiePave(Image< int_2>&, Image<uint_2> const&, float, float, double, double); | 
|---|
|  | 1978 | template void CopiePave(Image< int_2>&, Image< int_2> const&, float, float, double, double); | 
|---|
|  | 1979 | template void CopiePave(Image< int_2>&, Image< int_4> const&, float, float, double, double); | 
|---|
|  | 1980 | template void CopiePave(Image< int_2>&, Image<   r_4> const&, float, float, double, double); | 
|---|
|  | 1981 | template void CopiePave(Image< int_4>&, Image<uint_2> const&, float, float, double, double); | 
|---|
|  | 1982 | template void CopiePave(Image< int_4>&, Image< int_2> const&, float, float, double, double); | 
|---|
|  | 1983 | template void CopiePave(Image< int_4>&, Image< int_4> const&, float, float, double, double); | 
|---|
|  | 1984 | template void CopiePave(Image< int_4>&, Image<   r_4> const&, float, float, double, double); | 
|---|
|  | 1985 | template void CopiePave(Image<   r_4>&, Image<uint_2> const&, float, float, double, double); | 
|---|
|  | 1986 | template void CopiePave(Image<   r_4>&, Image< int_2> const&, float, float, double, double); | 
|---|
|  | 1987 | template void CopiePave(Image<   r_4>&, Image< int_4> const&, float, float, double, double); | 
|---|
|  | 1988 | template void CopiePave(Image<   r_4>&, Image<   r_4> const&, float, float, double, double); | 
|---|
|  | 1989 |  | 
|---|
|  | 1990 |  | 
|---|
|  | 1991 | template void RzCopieImage(Image<uint_2> &, RzImage const &, int, int, int, int, int, int, double, double); | 
|---|
|  | 1992 | template void RzCopieImage(Image< int_2> &, RzImage const &, int, int, int, int, int, int, double, double); | 
|---|
|  | 1993 | template void RzCopieImage(Image< int_4> &, RzImage const &, int, int, int, int, int, int, double, double); | 
|---|
|  | 1994 | template void RzCopieImage(Image<   r_4> &, RzImage const &, int, int, int, int, int, int, double, double); | 
|---|
|  | 1995 |  | 
|---|
|  | 1996 | template void RzCopieImage(Image<uint_2> &, RzImage const &); | 
|---|
|  | 1997 | template void RzCopieImage(Image< int_2> &, RzImage const &); | 
|---|
|  | 1998 | template void RzCopieImage(Image< int_4> &, RzImage const &); | 
|---|
|  | 1999 | template void RzCopieImage(Image<   r_4> &, RzImage const &); | 
|---|
|  | 2000 |  | 
|---|
|  | 2001 | template void RzCopiePave(Image<uint_2> &, RzImage const &, float, float, double, double); | 
|---|
|  | 2002 | template void RzCopiePave(Image< int_2> &, RzImage const &, float, float, double, double); | 
|---|
|  | 2003 | template void RzCopiePave(Image< int_4> &, RzImage const &, float, float, double, double); | 
|---|
|  | 2004 | template void RzCopiePave(Image<   r_4> &, RzImage const &, float, float, double, double); | 
|---|
|  | 2005 |  | 
|---|
|  | 2006 | #endif | 
|---|
|  | 2007 |  | 
|---|