function Q=M_SPA(img);
%test code for
%img=imread('RMB100_01.bmp');%256*256*3
%img=rgb2gray(img);
sigma=20;
imshow(img,[]);
title('original image');
img=double(img);
[r,c]=size(img);
block_size=8;
codebook_size=16;%256;
C=1.15;
sigma=20;
[r,c]=size(img);
img=img+randn(r,c)*sigma
imshow(img,[]);
title('noise_image');
%noise_img=img+randn(r,c)*sigma;
%img=noise_img;
%imshow(img,[]);
%title('noise_image');
%noise_img=img+noise;
%imshow(noise_img,[]);
%title('original noise_image');
patches=im2col(img,[block_size,block_size],'sliding');
%imshow(patches,[]);
%title('dictionary');
errGoal=C*sigma;
%A=OMP(patches,img,c);
%[D,coef]=MOD(img,codebook_size,errGoal);
[D,coef]=KSVD(img,codebook_size,errGoal);
imshow(D,[]);
title('dictionary');
length(find(coef>0))
length(find(coef<0))
length(find(coef==0))
[rows,cols]=find(coef==0)
%recpatches=D*coef;
img=D*coef;
recpatches=im2col(img,[block_size,block_size],'sliding');
%figure;
%imshow(uint8(D),[]);
%title('denoised image');
ind=1:size(patches,2);
[r,w]=size(img);
IMout=zeros(r,w);
Weight=zeros(r,w);
[rows,cols] = ind2sub(size(img)-block_size+1,ind);
for i=1:length(cols)
row=rows(i);
col=cols(i);
Patch_out=reshape(recpatches(:,i),block_size,block_size);
IMout(row:row+block_size-1,col:col+block_size-1)=...
IMout(row:row+block_size-1,col:col+block_size-1)+Patch_out;
Weight(row:row+block_size-1,col:col+block_size-1)=...
Weight(row:row+block_size-1,col:col+block_size-1)+ones(block_size);
end
denoise_img=IMout./Weight;
Q=fix(denoise_img)
figure;
imshow(Q,[]);
title('denoised image');
yychao1986
- 粉丝: 5
- 资源: 2
最新资源
- 上课教材ppt-数据库系统原理及MySQL应用教程(第二版)课件.zip
- usb gadget 学习资料
- 智能毕设项目开发基础教程
- 实用脚本工具:自动化编程基础教程
- LabVIEW编程入门与实践基础教程
- 嵌入式开发入门与实践基础教程
- JFinal-Python资源
- 胆小菇 Python Selenium 爬虫入门:批量将豆瓣书影标记设置为"仅自己可见"
- bboss-plugins-kafka
- iotucy-websocket
- 胆小菇 Python Selenium 爬虫入门:批量将豆瓣书影标记设置为"仅自己可见"
- StudentManageSystem-建立学生信息链表
- Sa-Token-java
- 基于Atlas 200I DK A2研究的机械臂目标检测系统-注意力机制
- ga_network_reconfiguration-遗传算法
- tomcat-tomcat
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
前往页