#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "sopnamsp.h"
#include "ctimer.h"
#include "imageop.h"

#include "piup.h"

RzImage * PIUserProc_1(ImageR4& myimg, int xp, int yp, int dx, int dy,
                       char * arg1, char * arg2)
{
printf("**** PIUserProc_1 Pave[%d*%d] en (%d,%d) %s %s  Filtrage passe-bas 3*3 \n",
       dx, dy, xp, yp, arg1, arg2);
ImageR4 filt(3,3);
ImageR4 * out;

// Definition du filtre passe-bas
int i,j;
for(i=0; i<3; i++)
  for(j=0; j<3; j++)  filt(i,j) = 0.1;
filt(1,1) = 0.2;

filt.PrintImage();
out = new ImageR4(myimg.XSize(), myimg.YSize());
TIMEF ;
FilterImage(&myimg, out, &filt); 
return((RzImage*)out);
}
 
RzImage * PIUserProc_2(ImageR4& myimg, int xp, int yp, int dx, int dy,
                       char * arg1, char * arg2)
{
printf("**** PIUserProc_2 Pave[%d*%d] en (%d,%d) %s %s  Ombre 3*3 \n",
       dx, dy, xp, yp, arg1, arg2);
printf(" PIUserProc_2(%d %d %s %s)  Ombre 3*3 \n", xp, yp, arg1, arg2);
ImageR4 filt(3,3);
ImageR4 * out;

// Definition du filtre ombre
int i,j;
filt(0,0) = filt(1,1) = filt(2,2) = 0.;
filt(0,1) = filt(1,2) = -1.;
filt(1,0) = filt(2,1) = 1.;
filt(0,2) = -2.;
filt(2,0) = 2.;
filt.PrintImage();
out = new ImageR4(myimg.XSize(), myimg.YSize());
TIMEF ;
FilterImage(&myimg, out, &filt); 
return((RzImage*)out);
}

 
RzImage * PIUserProc_3(ImageR4& , int xp, int yp, int dx, int dy,
                       char * arg1, char * arg2)
{
printf("PIUserProc_3 Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
       dx, dy, xp, yp, arg1, arg2);
return(NULL);
}
