matlab2013b
提出一种新的多重分形图象去噪算法,讨论了基于小波极大模的多重 分形谱估计算法.在此基础上推导了图像取噪声的谱移位算子.该方法没有对噪声的类型提出任何假设条件,而是通过定义一个变换算子对每一点的 Hausdorf指数进行处理,使处理后的图象的Hausdorf指数接近于2,从而取得最佳效果.实验结果表明,该方法在去除噪声的同时可很好地保留了 原始图像的纹理信息.
算法流程图如图所示:
部分程序如下:
登录后复制
clc;clear;close all;warning off;addpath 'FUNC\'sel = 0;%1:计算多重分形谱;0:分类%%%读取三个图片I1s = imread('图像\D10.gif');I1 = imresize(I1s,[512,512]);I2s = imread('图像\D05.gif');I2 = imresize(I2s,[512,512]);figure;subplot(121);imshow(I1);title('图片1');subplot(122);imshow(I2);title('图片2');%%%分成多个子图片[M,N] = size(I1);sub_length = 64;n1 = floor(M/sub_length);n2 = floor(N/sub_length);DF = zeros(1,n1*n2); for num_image = 1:2 k=1; for i=1:n1 for j=1:n2 x_start = (i-1)*sub_length+1; x_end = i*sub_length; y_start = (j-1)*sub_length+1; y_end = j*sub_length; if num_image == 1 sub_image = I1(x_start:x_end,y_start:y_end); imwrite(sub_image,['save_images\1\I_',num2str(k),'.jpg']); end if num_image == 2 sub_image = I2(x_start:x_end,y_start:y_end); imwrite(sub_image,['save_images\2\I_',num2str(k),'.jpg']); end %保存分割的多个子图片 k = k + 1; end endend%%%对保存的多张图片读取并调用WTMM方法求图像的多重分形谱,对得到的结果保存其特征值if sel == 1 k = 1; for i=1:2*n1*n2; if i<=n1*n2 k = i; folder = 'save_images\1\'; lists = dir('save_images\1\*.jpg'); end if i<=2*n1*n2 & i>n1*n2 k = i - n1*n2; folder = 'save_images\2\'; lists = dir('save_images\2\*.jpg'); end i %read an image I = imread(fullfile(folder,lists(k).name)); %调用分形函数 [qt,rt,ft,fft,Dt,feature_data] = func_Wavelet_multifractal(I); q{i} = qt; r{i} = rt; f{i} = ft; ff{i} = fft; D{i} = Dt; Feature{i} = feature_data; end save result.mat q r f ff D Feature K = 120; figure; plot(r{K},f{K},'b-o'); xlabel('奇异指数a'); ylabel('多重分行谱f(a)') grid on; figure; plot(q{K}+2,D{K},'b-o'); xlabel('q'); ylabel('D(q)') grid on; figure plot(q{K},r{K},'b-o'); title('q和阿尔法a'); xlabel('权重因子q'); ylabel('奇异指数a'); grid on; figure; plot(q{K},f{K},'b-o'); title('q和f(a) '); xlabel('权重因子q'); ylabel('多重分行谱f(a)'); grid on;end %%%调用分类器对特征参数进行分类if sel == 0 load result.mat %q r f ff Feature K = 120; figure; plot(r{K},f{K},'b-o'); xlabel('奇异指数a'); ylabel('多重分行谱f(a)') grid on; figure; plot(q{K}+2,D{K},'b-o'); xlabel('q'); ylabel('D(q)') grid on; figure plot(q{K},r{K},'b-o'); title('q和阿尔法a'); xlabel('权重因子q'); ylabel('奇异指数a'); grid on; figure; plot(q{K},f{K},'b-o'); title('q和f(a) '); xlabel('权重因子q'); ylabel('多重分行谱f(a)'); grid on; for i = 1:length(Feature) P(i) = Feature{i}(3); end T = [1*ones(1,length(Feature)/2),2*ones(1,length(Feature)/2)]; t1 = clock; %计时开始 net = fitnet(65); net.trainParam.epochs = 1000; %设置训练次数 net.trainParam.goal = 0.0001; %设置性能函数 net.trainParam.show = 1; %每10显示 net.trainParam.Ir = 0.005; %设置学习速率 net = train(net,P,T); %训练BP网络 datat = etime(clock,t1); Nets = net; view(Nets); figure; plot(P,'b-*'); y = sim(net,P); figure; stem(y,'r-*');hold on plot(T,'b-','LineWidth',2);hold on legend('预测数据','实际数据'); title('输出1为第一类,输出2为第二类(即可对比实际的健康部分和肿瘤部分)'); disp('预测正确率'); error = 0; for i = 1:length(y) if i <= length(y)/2 if y(i) > 1.5 error = error + 1; end else if y(i) < 1.5 error = error + 1; end end end 1-error/length(y)end 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.177.178.179.180.181.182.183.184.185.186.187.188.189.190.191.192.193.194.195.196.197.198.199.200.201.
所利用的测试数据为:
通过多重分形谱仿真,得到如下的仿真结果:
然后进行分类,得到如下的仿真结果:
神经网络参数如下所示:
前面得到的特征数据集如下所示:
得到的分类结果如下所示:
上面蓝色的表示两类图片,1表示第一个图片,2表示第二个图片。
红色部分表示对64个子图进行分类,通过统计计算,可以得到的分类的正确率达到了:
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删