#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include "ppm.h"

#include "nrutil.h"

#define DEBUG  1

void mglin(double **u, int n, int ncycle);
void nrerror(char error_text[]);
float *vector(long nl, long nh);
int *ivector(long nl, long nh);
unsigned char *cvector(long nl, long nh);
unsigned long *lvector(long nl, long nh);
double *dvector(long nl, long nh);
float **matrix(long nrl, long nrh, long ncl, long nch);
double **dmatrix(long nrl, long nrh, long ncl, long nch);

enum {NORMALIZE, USEMAXMIN};
enum {MASK_OFF, MASK_ON};

void imageNormalize(double ** u, double **out, int width, int height, int maxminflag, double maxMin[2]);
//void setGradient(Image *image, Image *mask, double ** u, int flag, Image * edgeimage, Image * maskimage, Image * horimage, Image * verimage);
void setGradient(Image *image, Image *mask, double ** u, int flag, Image * edgeimage, Image * maskimage,
				 Image * hor_red, Image * hor_redblur, Image * hor_blue, Image * hor_blueblur,
				 Image * ver_red, Image * ver_redblur, Image * ver_blue, Image * ver_blueblur);

void setGradient(Image *image, Image *mask, double ** u, int flag, Image * edgeimage, Image * maskimage);
void setMask(Image *mask, double ** u);
int compare( const void *elem1, const void *elem2 );
void saveArrayAsImage(double ** u, double ** uOut, u_char * resultpixel, int arrayWidth, int arrayHeight, char *fileName, int maxminflag, double maxMin[2]);
