Home > Back-end >  Inverse filtering for image restoration after the white spots, with what method can be removed?
Inverse filtering for image restoration after the white spots, with what method can be removed?

Time:10-09

Visual c + + code of 2008, after the inverse filtering image appeared white spots, how they can be removed and not affect the effect of recovery?

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 * pCTSrc, * PCTH;//used to store the source image and nuclear transformation time domain data
Complex * pCFSrc, * PCFH;//used to store the source image and nuclear transformation frequency domain data
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 [lHeight * lLineBytes];
PCTH=new complex [lHeight * lLineBytes];
pCFSrc=https://bbs.csdn.net/topics/new complex [lHeight * lLineBytes];
PCFH=new complex [lHeight * lLineBytes];
//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 ((double) * lpSrc, 0);
PCFSrc [lLineBytes * j + I]=complex (0.0, 0.0);
If (i<5 & amp; & J<5)
{
PCTH [lLineBytes * j + I]=complex (0.04, 0.0);
}
The else
{
PCTH [lLineBytes * j + I]=complex (0.0, 0.0);
}
PCFH [lLineBytes * j + I]=complex (0.0, 0.0);
}
}
//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 (tempre tempim);
}
//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{//points to recover image from the first line j, the pixels of a pointer 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;
  • Related