⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chenimage.h

📁 LDPC码的实现,包括编码器和解码器,使用了DCT.
💻 H
📖 第 1 页 / 共 2 页
字号:
// ChenImage.h

#ifndef _CHENIMG_H_
#define _CHENIMG_H_

#pragma warning( disable: 4996 )

// C/C++
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
using namespace std;

#ifndef GOOD_RETURN
	#define GOOD_RETURN 0
#endif
#ifndef BAD_RETURN
	#define BAD_RETURN 1
#endif
#ifndef RECORD_IPP_SUCCESS
	#define RECORD_IPP_SUCCESS(func, bSuccess) bSuccess = bSuccess && (func == GOOD_RETURN)
#endif
#ifndef RECORD_SUCCESS
	#define RECORD_SUCCESS(func, bSuccess) bSuccess = bSuccess && (func == GOOD_RETURN)
#endif
#ifndef SAFE_IPP_FUNC
	#define SAFE_IPP_FUNC(func) if (func != GOOD_RETURN) return BAD_RETURN
#endif
#ifndef SAFE_FUNC
	#define SAFE_FUNC(func) if (func != GOOD_RETURN) return BAD_RETURN
#endif

#ifndef MIN
	#define MIN(a,b) (a < b ? a : b) 
#endif
#ifndef MAX
	#define MAX(a,b) (a > b ? a : b) 
#endif
#ifndef CLIP
	#define CLIP(x,minVal,maxVal) MAX(minVal,MIN(x,maxVal))
#endif
#ifndef ROUND
	#define ROUND(x) (int)(x + 0.5)
#endif

#ifndef EPS
	#define EPS 1e-20
#endif
#ifndef LARGE
	#define LARGE 1000000000
#endif
#ifndef PI
	#define PI 3.14159
#endif

typedef unsigned char uchar;

static const char* KAKADU_BIN = "C:\\Users\\HP_Administrator\\Documents\\IVMS\\Libraries\\Kakadu\\Executables\\win32";


// Round the float value into short value
short ChenImage_RoundFloat(float fV);

/* -----------------------------------------------------------------------------
 * ChenImage_imageMeanStdDev
 * -----------------------------------------------------------------------------
 * Calculate the mean and standard deviation of an image.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const short* pSrc
 * 
 * Outputs:
 * float* pMean
 * float* pStdDev
 * -----------------------------------------------------------------------------
 */
int ChenImage_imageMeanStdDev(const int nWidth, const int nHeight, const short* pSrc, float* pMean, float* pStdDev);

/* -----------------------------------------------------------------------------
 * ChenImage_imageBlockMeanStdDev
 * -----------------------------------------------------------------------------
 * Calculate the mean and standard deviation of each block of an image.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const short* pSrc
 * const int nBlockSize
 * 
 * Outputs:
 * float* pMean
 * float* pStdDev
 * -----------------------------------------------------------------------------
 */
int ChenImage_imageBlockMeanStdDev(const int nWidth, const int nHeight, const short* pSrc, const int nBlockSize, float* pMean, float* pStdDev);

/* -----------------------------------------------------------------------------
 * ChenImage_imageMSE
 * -----------------------------------------------------------------------------
 * Calculate the MSE in matching between two images.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const short* pSrc1
 * const short* pSrc2
 * 
 * Outputs:
 * float* pMSE
 * -----------------------------------------------------------------------------
 */
int ChenImage_imageMSE(const int nWidth, const int nHeight, const short* pSrc1, const short* pSrc2, float* pMSE);

/* -----------------------------------------------------------------------------
 * ChenImage_imagePSNR
 * -----------------------------------------------------------------------------
 * Calculate the PSNR in matching between two images.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const short* pSrc1
 * const short* pSrc2
 * 
 * Outputs:
 * float* pPSNR
 * -----------------------------------------------------------------------------
 */
int ChenImage_imagePSNR(const int nWidth, const int nHeight, const short* pSrc1, const short* pSrc2, float* pPSNR);

/* -----------------------------------------------------------------------------
 * ChenImage_imageDistortionEpsilonSqr
 * -----------------------------------------------------------------------------
 * Calculate the distortion epsilon-squared used in image coding.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const short* pSrc
 * 
 * Outputs:
 * float* pEpsilonSqr
 * -----------------------------------------------------------------------------
 */
int ChenImage_imageDistortionEpsilonSqr(const int nWidth, const int nHeight, const short* pSrc, float* pEpsilonSqr);

/* -----------------------------------------------------------------------------
 * ChenImage_imagePMF
 * -----------------------------------------------------------------------------
 * Calculates the probability mass function of an image.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const short* pSrc
 *
 * Outputs:
 * float* pPMF -- 256 levels
 * -----------------------------------------------------------------------------
 */
int ChenImage_imagePMF(const int nWidth, const int nHeight, const short* pSrc, float* pPMF);

/* -----------------------------------------------------------------------------
 * ChenImage_diffImagePMF
 * -----------------------------------------------------------------------------
 * Calculates the probability mass function of a difference image.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const short* pSrc
 *
 * Outputs:
 * float* pPMF -- 511 levels
 * -----------------------------------------------------------------------------
 */
int ChenImage_diffImagePMF(const int nWidth, const int nHeight, const short* pSrc, float* pPMF);

/* -----------------------------------------------------------------------------
 * ChenImage_imageEntropy
 * -----------------------------------------------------------------------------
 * Calculates the ideal entropy of an image in bits/pixel.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const short* pSrc
 *
 * Outputs:
 * float* pEntropy
 * -----------------------------------------------------------------------------
 */
int ChenImage_imageEntropy(const int nWidth, const int nHeight, const short* pSrc, float* pEntropy);

/* -----------------------------------------------------------------------------
 * ChenImage_diffImageEntropy
 * -----------------------------------------------------------------------------
 * Calculates the ideal entropy of a difference image in bits/pixel.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const short* pSrc
 *
 * Outputs:
 * float* pEntropy
 * -----------------------------------------------------------------------------
 */
int ChenImage_diffImageEntropy(const int nWidth, const int nHeight, const short* pSrc, float* pEntropy);

/* -----------------------------------------------------------------------------
 * ChenImage_imageBlockMatch1D
 * -----------------------------------------------------------------------------
 * Performs optimal integer-pel horizontal-movement block matching between two 
 * images. Uses error metric of sum-of-absolute-differences (SAD) to find 
 * closest matching blocks. Blocks inside the second source image are 
 * horizontally shifted to match (fixed) blocks within the first source image.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const int nBlockSize
 * const int nMaxShift
 * const short* pSrc1
 * const short* pSrc2
 *
 * Outputs:
 * short* pShiftedImg -- shifted version of pSrc2
 * short* pResidual -- pSrc1 - pShifted2
 * short* pShifts -- optimal blockwise integer shifts of pSrc2
 * -----------------------------------------------------------------------------
 */
int ChenImage_imageBlockMatch1D(const int nWidth, const int nHeight, const int nBlockSize, const int nMaxShift, const short* pSrc1, const short* pSrc2, short* pShiftedImg, short* pResidual, short* pShifts); 

/* -----------------------------------------------------------------------------
 * ChenImage_imageBlockMatch1DDoubleHypothesisAdd
 * -----------------------------------------------------------------------------
 * Performs optimal integer-pel horizontal-movement block matching between one
 * image and linear combination of two other images.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const int nBlockSize
 * const int nMaxShift
 * const short* pSrc1 -- X
 * const short* pSrc2 -- Y1
 * const short* pSrc3 -- Y2
 * const float pWeights[2]
 *
 * Outputs:
 * short* pShiftedImg -- shifted version of pSrc2
 * short* pResidual -- pSrc1 - pShifted2
 * short* pShifts1 -- optimal blockwise integer shifts of pSrc2
 * short* pShifts2 -- optimal blockwise integer shifts of pSrc3
 * -----------------------------------------------------------------------------
 */
int ChenImage_imageBlockMatch1DDoubleHypothesisAdd(const int nWidth, const int nHeight, const int nBlockSize, const int nMaxShift, const short* pSrc1, const short* pSrc2, const short* pSrc3, const float* pWeights, short* pShiftedImg, short* pResidual, short* pShift1, short* pShifts2);

/* -----------------------------------------------------------------------------
 * ChenImage_imageBlockMatch1DDoubleHypothesisSwitch
 * -----------------------------------------------------------------------------
 * Performs optimal integer-pel horizontal-movement block matching between one
 * image and best choice (switch) among two other images.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const int nBlockSize
 * const int nMaxShift
 * const short* pSrc1 -- X
 * const short* pSrc2 -- Y1
 * const short* pSrc3 -- Y2
 *
 * Outputs:
 * short* pShiftedImg -- shifted version of pSrc2
 * short* pResidual -- pSrc1 - pShifted2
 * short* pShifts1 -- optimal blockwise integer shifts of pSrc2
 *						if not chosen, set to < -nMaxShift
 * short* pShifts2 -- optimal blockwise integer shifts of pSrc3
 * -----------------------------------------------------------------------------
 */
int ChenImage_imageBlockMatch1DDoubleHypothesisSwitch(const int nWidth, const int nHeight, const int nBlockSize, const int nMaxShift, const short* pSrc1, const short* pSrc2, const short* pSrc3, short* pShiftedImg, short* pResidual, short* pShifts1, short* pShifts2);

/* -----------------------------------------------------------------------------
 * ChenImage_imageBlockMatch1DDoubleHypothesisAddDynamicWeight
 * -----------------------------------------------------------------------------
 * Performs optimal integer-pel horizontal-movement block matching between one
 * image and linear combination (dynamic weight) of two other images.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const int nBlockSize
 * const int nMaxShift
 * const short* pSrc1 -- X
 * const short* pSrc2 -- Y1
 * const short* pSrc3 -- Y2
 *
 * Outputs:
 * short* pShiftedImg -- shifted version of pSrc2
 * short* pResidual -- pSrc1 - pShifted2
 * short* pShifts1 -- optimal blockwise integer shifts of pSrc2
 * short* pShifts2 -- optimal blockwise integer shifts of pSrc3
 * short* pWeights1 -- optimal weight for pSrc2
 *		index-to-value: 0 = 0.0, 1 = 0.5, 2 = 1.0
 * -----------------------------------------------------------------------------
 */
int ChenImage_imageBlockMatch1DDoubleHypothesisAddDynamicWeight(const int nWidth, const int nHeight, const int nBlockSize, const int nMaxShift, const short* pSrc1, const short* pSrc2, const short* pSrc3, short* pShiftedImg, short* pResidual, short* pShifts1, short* pShifts2, short* pWeights1);

/* -----------------------------------------------------------------------------
 * ChenImage_imageBlockMatch2D
 * -----------------------------------------------------------------------------
 * Performs optimal integer-pel block matching between two images. Uses error
 * metric of sum-of-absolute-differences (SAD) to find closest matching blocks.
 * Blocks inside the second source image are shifted to match (fixed) blocks
 * within the first source image.
 *
 * Inputs:
 * const int nWidth
 * const int nHeight
 * const int nBlockSize
 * const int nMaxShift
 * const short* pSrc1
 * const short* pSrc2
 *
 * Outputs:
 * short* pShifted
 * short* pResidual

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -