📄 img.h
字号:
#ifndef __IMG_H_
#define __IMG_H_
#ifdef __cplusplus
extern "C" {
#endif
/*--------------------------------------------------------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#include "memchk.h"
#include "global.h"
/*--------------------------------------------------------------------------------------------*/
#ifndef MAX_GREY
#define MAX_GREY 255
#endif
#ifndef MIN_GREY
#define MIN_GREY 0
#endif
/*--------------------------------------------------------------------------------------------*/
typedef struct ImageStruct{
int YSize;
int XSize;
unsigned char *Pixel;
} Image;
typedef struct LImageStruct{
int YSize;
int XSize;
int *Pixel;
} LImage;
typedef struct FImageStruct{
int YSize;
int XSize;
Real *Pixel;
} FImage;
/* color image */
typedef struct CoImageStruct{
int YSize[3];
int XSize[3];
int color;
Image *C[3];
unsigned char *Pixel[3]; //
} CoImage;
/* color image */
typedef struct LCoImageStruct{
int YSize[3];
int XSize[3];
int color;
LImage *C[3];
int *Pixel[3]; //
} LCoImage;
/* floating point color image */
typedef struct FCoImageStruct{
int YSize[3];
int XSize[3];
int color;
FImage *C[3];
Real *Pixel[3];
} FCoImage;
/*--------------------------------------------------------------------------------------------*/
Image *ImageAlloc(int XSize, int YSize);
LImage *LImageAlloc(int XSize, int YSize);
FImage *FImageAlloc(int XSize, int YSize);
/*--------------------------------------------------------------------------------------------*/
void ImageDealloc(Image *img);
void LImageDealloc(LImage *img);
void FImageDealloc(FImage *img);
/*--------------------------------------------------------------------------------------------*/
Image *ImageReadRaw(int xsize, int ysize, char *filename);
LImage *LImageReadRaw(int xsize, int ysize, char *filename);
FImage *FImageReadRaw(int xsize, int ysize, char *filename);
/*--------------------------------------------------------------------------------------------*/
int ImageWriteRaw(Image *img, char *filename);
int LImageWriteRaw(LImage *img, char *filename);
int FImageWriteRaw(FImage *img, char *filename);
/*--------------------------------------------------------------------------------------------*/
/* PGM images */
Image *ImageReadPGM(char *PGMFileName);
LImage *LImageReadPGM(char *PGMFileName);
FImage *FImageReadPGM(char *PGMFileName);
/*--------------------------------------------------------------------------------------------*/
int ImageWritePGM(Image *img, char *PGMFileName);
int LImageWritePGM(LImage *img, char *PGMFileName);
int FImageWritePGM(FImage *img, char *PGMFileName);
/*--------------------------------------------------------------------------------------------*/
/* load image from buffers */
void ImageLoad(Image *img, unsigned char *in);
void LImageLoad(Image *img, int *in);
void FImageLoad(FImage *img, Real *in);
/*--------------------------------------------------------------------------------------------*/
void ImageUnload(Image *img, unsigned char *in);
void LImageUnload(Image *img, int *in);
void FImageUnload(FImage *img, Real *in);
/*--------------------------------------------------------------------------------------------*/
void ImageCopy(Image *pDest, Image *pSrc);
void FImageCopy(FImage *pDest, FImage *pSrc);
void LImageCopy(LImage *pDest, LImage *pSrc);
/*--------------------------------------------------------------------------------------------*/
void LImageToImage(Image *pDest, LImage *pSrc);
void FImageToImage(Image *pDest, FImage *pSrc);
/*--------------------------------------------------------------------------------------------*/
void ImageToFImage(FImage *pDest, Image *pSrc);
void ImageToLImage(LImage *pDest, Image *pSrc);
/*--------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------*/
/* 24 bits color Image */
CoImage *CoImageAlloc(int XSize[3], int YSize[3], int color);
LCoImage *LCoImageAlloc(int XSize[3], int YSize[3], int color);
FCoImage *FCoImageAlloc(int XSize[3], int YSize[3], int color);
/*--------------------------------------------------------------------------------------------*/
void CoImageDealloc(CoImage *img);
void LCoImageDealloc(LCoImage *img);
void FCoImageDealloc(FCoImage *img);
/*--------------------------------------------------------------------------------------------*/
CoImage *CoImageReadRaw(int XSize[3], int YSize[3], int color, int interleave, char *filename);
LCoImage *LCoImageReadRaw(int XSize[3], int YSize[3], int color, int interleave, char *filename);
FCoImage *FCoImageReadRaw(int XSize[3], int YSize[3], int color, int interleave, char *filename);
/*--------------------------------------------------------------------------------------------*/
CoImage *CoImageReadRawWithSkip(int XSize[3], int YSize[3], int color, int interleave,
int skip_count, char *filename);
LCoImage *LCoImageReadRawWithSkip(int XSize[3], int YSize[3], int color, int interleave,
int skip_count, char *filename);
FCoImage *FCoImageReadRawWithSkip(int XSize[3], int YSize[3], int color, int interleave,
int skip_count, char *filename);
/*--------------------------------------------------------------------------------------------*/
int CoImageWriteRaw(CoImage *img, int interleave, char *filename);
int LCoImageWriteRaw(LCoImage *img, int interleave, char *filename);
int FCoImageWriteRaw(FCoImage *img, int interleave, char *filename);
/*--------------------------------------------------------------------------------------------*/
CoImage *CoImageReadPPM(char *PPMFileName);
LCoImage *LCoImageReadPPM(char *PPMFileName);
FCoImage *FCoImageReadPPM(char *PPMFileName);
/*--------------------------------------------------------------------------------------------*/
int LCoImageWritePPM(LCoImage *ppm, char *CoFileName);
int CoImageWritePPM(CoImage *ppm, char *CoFileName);
int FCoImageWritePPM(FCoImage *ppm, char *CoFileName);
/*--------------------------------------------------------------------------------------------*/
void CoImageCopy(CoImage *pDest, CoImage *pSrc);
void LCoImageCopy(LCoImage *pDest, LCoImage *pSrc);
void FCoImageCopy(FCoImage *pDest, FCoImage *pSrc);
/*--------------------------------------------------------------------------------------------*/
void LCoImageToCoImage(CoImage *pDest, LCoImage *pSrc);
void FCoImageToCoImage(CoImage *pDest, FCoImage *pSrc);
/*--------------------------------------------------------------------------------------------*/
void CoImageToLCoImage(LCoImage *pDest, CoImage *pSrc);
void CoImageToFCoImage(FCoImage *pDest, CoImage *pSrc);
/*--------------------------------------------------------------------------------------------*/
/* KLT */
void FCoImageKLTMatrix(FCoImage *img, int M[3], int T[3][3], int precision);
void FCoImageForwardKLT(FCoImage *img, int M[3], int T[3][3], int precision);
void FCoImageInverseKLT(FCoImage *img, int M[3], int T[3][3], int precision);
/*--------------------------------------------------------------------------------------------*/
/* Error handler */
void ImageError(char *fmt, ...);
void ImageWarning(char *fmt, ...);
/*--------------------------------------------------------------------------------------------*/
int ImageType(char *filename, int *XSize, int *YSize);
/*--------------------------------------------------------------------------------------------*/
/* Comparison */
double ImageCompareMSE(Image *img1, Image *img2);
double ImageCompareSNR(Image *img1, Image *img2);
double ImageComparePSNR(Image *img1, Image *img2);
double ImageCompareMAD(Image *img1, Image *img2);
double ImageFileCompareMSE(char *PGMFileName1, char *PGMFileName2);
double ImageFileComparePSNR(char *PGMFileName1, char *PGMFileName2);
double ImageFileCompareMAD(char *PGMFileName1, char *PGMFileName2);
double ImageFileCompareSNR(char *PGMFileName1, char *PGMFileName2);
double FImageCompareMSE(FImage *img1, FImage *img2);
double FImageComparePSNR(FImage *img1, FImage *img2);
/*--------------------------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
/*--------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------*/
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -