读入图片和利用haar算子对图像进行小波降噪的结果,编程如下: - function [XDEN,cfsDEN,dimCFS] = func_denoise_dw2d(X)
- % X: 图像矩阵数据
- % XDEN: 图像去噪矩阵数据
- % cfsDEN: 分解向量
- % dimCFS: 对应的数据缓存矩阵
- wname = 'haar'; % 小波名称
- level = 2; % 2级小波
- % 去噪参数设置
- sorh = 's'; % Specified soft or hard thresholding
- thrSettings = [...
- 4.405464908006699 4.078667960675236 ; ...
- 4.405464908006699 4.078667960675236 ; ...
- 4.405464908006699 4.078667960675236 ...
- ];
- roundFLAG = true;
- % 使用WDENCMP函数降噪
- [coefs,sizes] = wavedec2(X,level,wname);
- [XDEN,cfsDEN,dimCFS] = wdencmp('lvd',coefs,sizes, ...
- wname,level,thrSettings,sorh);
- if roundFLAG , XDEN = round(XDEN); end % 取整
- if isequal(class(X),'uint8') , XDEN = uint8(XDEN); end % 数据类型转换
复制代码
|