资源简介
通过bayes收缩得到收缩函数的阈值,以此对小波高频分量进行去噪
代码片段和文件信息
#include
#include
#include
#include
#define wieth 512
#define height 512
#define filter_lenth 16//滤波器长度
#define dcp_class 4//小波分解级数
#define k1 0.01
#define k2 0.03
#define L 255
#define sigma_w 1.5
#define pi 3.1415
#define patch_size 3
#define ssim_size 5
#define Gmax 255
#define noise_stadard 30
double GauseNoise(double var_noise);
double shrinkage_soft(double input_shrinkage_softdouble input_shrinkage_soft_lemda);
void dcp(double *start_position_dep_depint data_lenth_dcp);
void recs(double *start_position_recsint data_lenth_recs);
unsigned char Trans(double input_Trans);
//void med_make(double *start_position_medint datalenth_med_make);//从小到大排序
void main()
{
static unsigned char Image[height][wieth]Imagec[height][wieth]ImagecR[height][wieth];
static float Imagexf[height][wieth]Imageyf[height][wieth]omega[2*ssim_size+1][2*ssim_size+1];
static double ImageRow[wieth]ImageColume[height]ImagefReconstruction[height][wieth]Imagef_Decomposition[height][wieth]Imagef[height][wieth]Imagec_dcp_disp[height][wieth]med[height*wieth/4];
int ijxyuvdcp_numberheight_dcpwieth_dcpheight_recswieth_recsheight_denoiwieth_denoi;
double max_phimin_phimax_detailmin_detaillemdasigma_y_estsigma_x_estmax_coefsum_coefsigma_noise_estmediantemp_doublesumabc;
float sigma_xmu_xsigma_ymu_ysigma_xywic1c2sum_ssimmssimsum_omega;
FILE *fp1*fp2*fp3*fp4;
fopen_s(&fp1“f:\\image\\wavelet\\lena512.raw““rb“);
fread(Image1wieth*heightfp1);
for(i=0;i for(j=0;j {
Imagef[i][j]=(double)(Image[i][j]+GauseNoise(noise_stadard));
Imagec[i][j]=Trans(Imagef[i][j]);
}
fopen_s(&fp4“f:\\image\\wavelet\\lena512noise_db4.raw““wb“);
fwrite(Imagec1wieth*heightfp4);
for(i=0;i for(j=0;j {
Imagef_Decomposition[i][j]=Imagef[i][j];
ImagefReconstruction[i][j]=0;
}
height_dcp=height;
wieth_dcp=wieth;
/////////////////
//以下为分解
for(dcp_number=1;dcp_number<=dcp_class;dcp_number++)
{
for(i=0;i {
for(j=0;j ImageRow[j]=Imagef_Decomposition[i][j];
dcp(ImageRowwieth_dcp);
for(j=0;j {
Imagef_Decomposition[i][j]=ImageRow[j];
ImageRow[j]=0;
}
}
for(j=0;j {
for(i=0;i ImageColume[i]=Imagef_Decomposition[i][j];
dcp(ImageColumeheight_dcp);
for(i=0;i {
Imagef_Decomposition[i][j]=ImageColume[i];
ImageColume[i]=0;
}
}
///////////////////////////////////////////////////////
//以下为每一级分解后的标定,便于显示
for(i=0;i for(j=0;j Imagec_dcp_disp[i][j]=fabs(Imagef_Decomposition[i][j]);
max_phi=min_phi=Imagec_dcp_disp[0][0];
max_detail=min_detail=0;
for(i=0;i
- 上一篇:用C语言对图像加高斯噪声
- 下一篇:C语言版BM3D算法
评论
共有 条评论