//************************************************************
//	Copyright (c) 1993
// 	Realise par l'equipe d'Analyse d'Images
//	Laboratoire de Traitement du Signal et Instrumentation
//	Universite de Saint-Etienne
//	France
//************************************************************

#ifndef R
#define R
#include <stdio.h>
#include "image.h"

typedef enum
	{
	P_PERIOD,
	P_CONST,	
        P_MIROIR
	} Prolongement;

#ifndef max
#define max(x,y) (((x)<(y))? (y):(x))
#endif
#ifndef min
#define min(x,y) (((x)<(y))?(x):(y))
#endif

// fichier r.c

Image   		 SeuilleInfR(Image imS,Image imD,Reel vinf,Reel val);
Image   		 SeuilleSupR(Image imS,Image imD,Reel vsup,Reel val);
Image	  		 SeuilleInterR(Image imS,Image imD,Reel v1,Reel v2,Reel val);
Image        TransfereR(Image imS, Image imD);
Image        NiveauR(Image imS, Image imD, Reel valeur);
int          MoyenneR(Image imS, Reel *moy);
int          MinMaxR(Image imS, Reel *min, Reel *max);
Image        EtaleR(Image imS, Image imD, Reel min, Reel max);
Image 		 EcreteR(Image imaS,Image imaD,int sup,Reel crete);
Image        DecaleR(Image imS, Image imD, int dx, int dy);
Image        ExtraitFenetreR(Image imS, Image imD);
Image 		 PlaceFenetreR(Image imS1,Image imS2,Image imD,int taille,Reel seuil);
Image 		 IntersecteR(Image imS1,Image imS2,Image imD);
Image        AbsR(Image imS, Image imD);
Image        AddR(Image imS1, Image imS2, Image imD);
Image        MaxR(Image imS1, Image imS2, Image imD);
Image        ExtraitDroiteR(Image imS, Image imD, int x1, int y1, int x2, int y2);

Image        ModuleR(Image imS, Image imD);
Image        PhaseR ( Image imS, Image imD );
Image		 ImagR(Image imS, Image imD);
Image        ConstAddR(Image imS, Image imD, Reel cte);
Image        ConstMultR(Image imS, Image imD, Reel cte);
Image        SoustrR(Image imS1, Image imS2, Image imD);
Image        MultR(Image imS1, Image imS2, Image imD);
Image        DivR(Image imS1, Image imS2, Image imD);
Image 		 SqRtR(Image imS,Image imD);
Image 		 CarreR(Image imS,Image imD);
Image        UnSurR(Image imS, Image imD);
Image        LogR(Image imS, Image imD);
Image        ExpR(Image imS, Image imD);
Image 		 Norme1R(Image imS,Image imD);
Image 		 Norme2R(Image imS,Image imD);
Image 		 CepstreR(Image imS,Image imD);
Image		 	 HistoR(Image imaS,Image imaD,Reel min,Reel max,Reel l);
int          Moment4R (Image imS,Reel * mom1,Reel * mom2,Reel * mom3,Reel * mom4);
int 		 	 FMoment4R(Image image,FILE *text);
Image 		 MoyenneAnnulaireR(Image imaS,Image imaD,int cx,int cy);
Image 		 RayonsR(Image imS,Image imD,int cx,int cy,float da);
Image 		 SommeColonneR(Image imS,Image imD);
Image 		 ExtraitTrameR(Image imS,Image imD,int pair);
Image 		 EntrelaceR(Image imS1,Image imS2,Image imD);
int 			 LitPointR(Image imS, Point *point, Reel *valeur);
int 			 EcritPointR(Image imS, Point *point, Reel valeur);
int 			 LitLigneR(Image imS,int py, Reel *valeur);
int 			 EcritLigneR(Image imS,int py, Reel *valeur);
int			 PosMinMaxR(Image imS, Point *posMin, Point *posMax, Reel *min, Reel *max);
int 		 FPosMinMaxR(Image imS, FILE *text);
Image 		 Max1DirR(Image imS,Image imD);
Image 		 Max4DirR(Image imS,Image imD);
//Image 		 PicR(Image imaS,Image imaLD,int nO,float nSigma);
//int 		 FPicR(Image imS, FILE *text,int nO,float nSigma);
Image	     CircR ( Image imS, Image profil,Image imD );
Image        AlterneSigneR ( Image imS, Image imD );
Image 	ConvolueR (Image imS1,Image imS2,Image imD);
Image 	CorreleR (Image imS1,Image imS2,Image imD);
Image 	AutoConvolueR (Image imS,Image imD);
Image 	AutoCorreleR (Image imS,Image imD);

//Image 		 GenereBruitR(Image imD,int x,int y,Reel sigma ,int distr); incompatible unix
Image 		 MireSinusR ( Image imD,int x,int y,int periode,Reel angle);
Image  		 CircProfilR ( Image profil, Image imD, int taille);
Image 		 TransCourbeImageLR(Image imLS,Image imD);
Image 		 TransImageCourbeLR(Image imS,Image imLD);
Image 		 RempliR(Image imaS,Image imaD, int germex,int germey, Reel b, Reel c);

//Image 		 CumulSR(Image imS,Image imD);
Image 		 SegmentR (Image imaS,Image imaD,int p1x,int p1y,int p2x,int p2y,Reel val);
Image 		 CercleR (Image imaS,Image imaD,int ox,int oy,int r,Reel val);

Image        RehausseR(Image imS1,Image imD,Reel val);

// fichier morphor.c

Image        DilateCroixR ( Image imS, Image imD );
Image        DilateCarreR ( Image imS, Image imD );
Image        DilateNFoisR ( Image imS, Image imD, int N );
Image        ErodeCroixR ( Image imS, Image imD );
Image        ErodeCarreR ( Image imS, Image imD );
Image        ErodeNFoisR ( Image imS, Image imD, int N );
Image 		 OuvreNR(Image imaS,Image imaD,int n);
Image 		 FermeNR(Image imaS,Image imaD,int n);
Image 		 ReconstruitR(Image imS,Image imMarqueur,Image imD);
int TestImageConstR(Image imS);
Image EbarbuleR(Image imaS,Image imaD,int n);
Image AmincitR(Image imaS,Image imaD,int n);
Image Amincit2R(Image imS1,Image imD,int n);
Image AmincitCondR(Image imS1,Image imS2,Image imD,int n);
Image AmincitCond2R(Image imS1,Image imS2,Image imD,int n);
Image EpaissitR(Image imaS,Image imaD,int n);
Image Epaissit2R(Image imS1,Image imD,int n);
Image EpaissitCondR(Image imS1,Image imS2,Image imD,int n);
Image EpaissitCond2R(Image imS1,Image imS2,Image imD,int n);
Image CarteGeodR(Image imaS,Image imaD,int n);
Image EffaceBordR(Image imaS,Image imaD);

//fichier sepmorfo.cpp
Image SepareR(Image imS1,Image imD,float concav,int maxi);
Image Separe2R(Image imS1,Image imS2,Image imD,float gris,float concav,int maxi);
Image SepareSelectR(Image imS1,Image imD,float concav,int maxi);
Image SepareSelect2R(Image imS1,Image imS2,Image imD,float gris,float concav,int maxi);





// fichier geomr.c

Image	SymetrieR (Image imaS, Image imaD, int sym);
Image	ScrollXYR(Image imS, Image imD, int dx, int dy);
Image	RotationR ( Image imaS, Image imaD, float teta);
Image	RotaPiSur2R ( Image imaS, Image imaD);
Image	TranspositionR ( Image imaS, Image imaD);
Image 	DecalYR(Image imS, Image imD, int dy);
Image 	DecalXR(Image imS, Image imD, int dx);
Image	AnamorXR ( Image imaS,  Image imaD, float py );
Image	AnamorYR ( Image imaS,  Image imaD, float py );
Image AnamorXYR(Image imS,Image imD,float coeffx,float coeffy);
Image AnamorQuadR(Image imS,Image imD,int ordre);


// fichier convolr.c

Image EcritTableauR ( Image imaF, Reel *tableau, int tx, int ty);
Image ConvoluR ( Image imaS, Image imaF, Image imaD);
Image ConvolueDirR(Image imS, Image imD,char * filtre,Prolongement prolong);
Image ConvolutionMtR(Image imaS, Image imaD, Reel *filtre,int tx,int ty);
Image ConvolMoyenneR (Image imaS,Image imaD, int type);
Image ConvolLaplaceR (Image imaS,Image imaD);
Image ConvolContrastR (Image imaS,Image imaD);
Image ConvolReliefR (Image imaS,Image imaD);
Image ConvolGradDiagR (Image imaS,Image imaD);
Image ConvolGradHorR(Image imaS,Image imaD);
Image ConvolGradVerR(Image imaS,Image imaD);

Image  MedianR ( Image source, Image dest);
Image  GradientKirschR ( Image source, Image dest);
Image  GradientSobelR ( Image source, Image dest);

Image CorrelDirecteR(Image imS1,Image imS2,Image imD,Reel reducX,Reel reducY);
Image DepouilleCorrelR (Image imS,Image Imd);
/*Image ConvolMoyenne2R_cg(Image imS,Image imD,int w,int n); */



// Fichier fenetres.c
Image FiltreGaussR (Image imS,Image imD,Reel sigma);
Image FiltreHammingR (Image imS,Image imD);
Image FiltreBlackmanR (Image imS,Image imD);


#endif
