www.pudn.com > EZW_.rar > IMAGE.H


#ifndef __IMAGE_H_ 
#define __IMAGE_H_ 
 
/*---------------------------------------------------------------------------*/ 
/*---------------------------------------------------------------------------*/ 
/* Some of the code are from elsewhere. The PGM routines are taken from  
 * G. Daivs code. 
 * 
 * Mow-Song, Ng 2/9/2002 
 * msng@mmu.edu.my 
 * http://www.pesona.mmu.edu.my/~msng 
 * 
 * I do not claim copyright to the code, but if you use them or modify them, 
 * please drop me a mail. 
 * 
 */ 
/*---------------------------------------------------------------------------*/ 
/*---------------------------------------------------------------------------*/ 
 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/	 
/*  
 * $LOG 
 * ---- 
 * 
 * 
 * $TODO 
 * ---- 
 * - add color image format 
 * - add other file format (lofty dreams ;-) 
 */ 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/	 
 
 
/*---------------------------------------------------------------------------*/ 
/*---------------------------------------------------------------------------*/ 
#include  
#include  
#include  
#include  
#include  
#include "memchk.h" 
#include "global.h" 
 
/* external dependencies */ 
#include "mem.h" 
 
#ifndef MAX_GREY 
#define MAX_GREY 255 
#endif 
 
#ifndef MIN_GREY 
#define MIN_GREY 0 
#endif 
 
typedef struct IMAGESTRUCT{ 
   int ysize; 
   int xsize; 
   void *extraData;  /* pointer to additional data */ 
   unsigned char **pixel; 
	unsigned char *pixelLinear; 
} IMAGE, *PIMAGE; 
 
typedef struct LIMAGESTRUCT{ 
   int ysize; 
   int xsize; 
   void *extraData;  /* pointer to additional data */ 
   int **pixel; 
	int *pixelLinear; 
} LIMAGE, *PLIMAGE; 
 
typedef struct FIMAGESTRUCT{ 
   int ysize; 
   int xsize; 
   void *extraData;  /* pointer to additional data */ 
   double **pixel; 
	double *pixelLinear; 
} FIMAGE, *PFIMAGE; 
 
/* function prototypes */ 
/* 8 bit image */ 
PIMAGE ReadRawGreyFile(int xsize, int ysize, char *filename); 
int WriteRawGreyFile(PIMAGE pimage, char *filename); 
int ImageInitialize(int XSize, int YSize, PIMAGE pimage); 
PIMAGE ImageAlloc(int XSize, int YSize); 
int ImageBufferAlloc(PIMAGE pimage); 
void ImageBufferFree(PIMAGE pimage); 
void ImageFree(PIMAGE pimage); 
int CopyImage(PIMAGE pimageDest, PIMAGE pimageSrc); 
int SetImage(PIMAGE pimageSrc, unsigned char val); 
int ImageDynamicRange(PIMAGE pimage, unsigned char *MaxPixel, unsigned char *MinPixel); 
 
PFIMAGE ReadRawGreyFileToFloat(int xsize, int ysize, char *filename); 
int WriteFloatToRawGreyFile(PFIMAGE pfimage, char *filename); 
 
 
/* 32 bit image */ 
PLIMAGE ReadRaw32File(int xsize, int ysize, char *filename); 
int WriteRaw32File(PLIMAGE plimage, char *filename); 
int LImageInitialize(int XSize, int YSize, PLIMAGE plimage); 
PLIMAGE LImageAlloc(int XSize, int YSize); 
int LImageBufferAlloc(PLIMAGE plimage); 
void LImageBufferFree(PLIMAGE plimage); 
void LImageFree(PLIMAGE plimage); 
int CopyLImage(PLIMAGE plimageDest, PLIMAGE plimageSrc); 
 
/* floating point image */ 
PFIMAGE ReadRawFloatFile(int xsize, int ysize, char *filename); 
int WriteRawFloatFile(PFIMAGE pfimage, char *filename); 
int FImageInitialize(int XSize, int YSize, PFIMAGE pfimage); 
PFIMAGE FImageAlloc(int XSize, int YSize); 
int FImageBufferAlloc(PFIMAGE pfimage); 
void FImageBufferFree(PFIMAGE pfimage); 
void FImageFree(PFIMAGE pfimage); 
int CopyFImage(PFIMAGE pfimageDest, PFIMAGE pfimageSrc); 
 
/* Processing */ 
PFIMAGE Average2x2Image(PIMAGE pimageSrc, int type); 
PFIMAGE Average3x3Image(PIMAGE pimageSrc, int type); 
PFIMAGE Average3x3ImageFilter0(PIMAGE pimageSrc, int type); 
 
/* Conversion */ 
int CopyFImageToImage(PIMAGE pimageDest, PFIMAGE pfimageSrc); 
int CopyImageToFImage(PFIMAGE pfimageDest, PIMAGE pimageSrc); 
 
/* PGM */ 
PIMAGE ReadPGM(char *PGMFileName); 
PFIMAGE ReadPGMToFloat(char *PGMFileName); 
int WritePGM(PIMAGE pimage, char *PGMFileName); 
int WriteFloatToPGM(PFIMAGE pfimage, char *PGMFileName); 
unsigned int PGMGetVal (FILE* infile); 
void PGMSkipComments(FILE* infile, unsigned char *ch); 
 
/* Comparison */ 
double ImageCompareMSE(PIMAGE pimage1, PIMAGE pimage2); 
double ImageComparePSNR(PIMAGE pimage1, PIMAGE pimage2); 
 
double FImageCompareMSE(PFIMAGE pfimage1, PFIMAGE pfimage2); 
double FImageComparePSNR(PFIMAGE pfimage1, PFIMAGE pfimage2); 
 
/* color conversion */ 
void ycc2rgb(double y,double cb, double cr, double *r, double *g, double *b); 
void rgb2ycc(double r, double g, double b, double *y, double *cb, double *cr); 
 
/* bicubic interpolation */ 
PIMAGE RescaleImage(PIMAGE pimageSrc, int newWidth, int newHeight, double zeroVal); 
 
/* Error handler */ 
void ImageError(char *fmt, ...); 
void ImageWarning(char *fmt, ...); 
 
#endif 
 
/* image.h */