CodePudding user response:
Filtering algorithm has a problem or there is something wrong with the inverse filtering algorithm, a pole or something, see if there is something wrong with your algorithm,CodePudding user response:
This is the inverse filtering the CPP program, and is there a problem? Can you help me to change?BOOL WINAPI DIBInverseFilter (Cdib * pDib)
{
BYTE * lpSrc;//a pointer to the source image
LONG lWidth;//the width of the image
LONG lHeight; The height of the images//
LONG lLineBytes;//image bytes per
//get the width and height of the image
Csize SizeDim;
SizeDim=pDib - & gt; GetDimensions ();
LWidth=SizeDim. Cx;
LHeight=SizeDim. Cy;
//get the size of the actual Dib image
Csize sizeRealDim;
SizeRealDim=pDib - & gt; GetDibSaveDim ();
LLineBytes=SizeRealDim. Cx;//calculate the image of the number of bytes per line
LPBYTE lpDIBBits=pDib - & gt; M_lpImage;//the image data pointer
//loop variable
Long I;
Long j;
Double tempre tempim, a, b, c, d;//temp
//the actual width and height of the Fourier transform
LONG lW=1;
LONG LH=1;
Int wp=0;
Int HP=0;
//that discrete Fourier change the width and height of integer power of 2
While (lW * 2 & lt;=lLineBytes)
{
LW=lW * 2;
Wp++;
}
While (lH * 2 & lt;=lHeight)
{
LH=lH * 2;
Hp++;
}
Complex
Complex
Double MaxNum;//image normalization factor
//input degraded images the length and width must be integer times of 2
If (lW!=(int) lLineBytes)
{
return false;
}
If (lH!=(int) lHeight)
{
return false;
}
//array allocate space for time domain and frequency domain
pCTSrc=https://bbs.csdn.net/topics/new complex
PCTH=new complex
pCFSrc=https://bbs.csdn.net/topics/new complex
PCFH=new complex
//the degraded image array in time domain data
for(j=0; J
for(i=0; i
//points to the degraded image bottom line j, the pixel pointer
IlpSrc=https://bbs.csdn.net/topics/(unsigned char *) lpDIBBits + lLineBytes * j + I;
PCTSrc [lLineBytes * j + I]=complex
PCFSrc [lLineBytes * j + I]=complex
If (i<5 & amp; & J<5)
{
PCTH [lLineBytes * j + I]=complex
}
The else
{
PCTH [lLineBytes * j + I]=complex
}
PCFH [lLineBytes * j + I]=complex
}
}
//call Fourier transform function, Fourier transform was carried out on the degraded images
: : DIBFFT_2D (pCTSrc, lLineBytes lHeight, pCFSrc);
//call Fourier transform function, the point spread function of Fourier transform
: : DIBFFT_2D (pCTH, lLineBytes lHeight, pCFH);
//frequency domain division by
for(i=0; i
A=pCFSrc [I]. Real ();
B=pCFSrc [I]. Image ();
C=pCFH [I]. Real ();
D=pCFH [I]. Image ();
//if the frequency value is too small, not be considered
If (c * * c + d d> Le - 3)
{
Tempre=(a * c + b * d)/(c * * d c + d);
Tempim=(b * c - a * d)/(c * * d c + d)
}
PCFSrc [I]=complex
}
//call the inverse Fourier transform function, inverse Fourier transform of restored image
IFFT_2D (pCFSrc pCTSrc, lLineBytes lHeight,);
MaxNum=300;//determine the normalization factor
//into the restored image
for(j=0; J
for(i=0; i
lpSrc=https://bbs.csdn.net/topics/(unsigned char *) lpDIBBits + lLineBytes * j + I;
* lpSrc=https://bbs.csdn.net/topics/(unsigned char) (pCTSrc [r]. (lLineBytes) * j + I real () * 255.0/MaxNum);
}
}
//release of storage space
The delete pCTSrc;
The delete pCTH;
The delete pCFSrc;
The delete pCFH;
return true;