function varargout = chongjian(varargin)
% CHONGJIAN MATLAB code for chongjian.fig
% CHONGJIAN, by itself, creates a new CHONGJIAN or raises the existing
% singleton*.
%
% H = CHONGJIAN returns the handle to a new CHONGJIAN or the handle to
% the existing singleton*.
%
% CHONGJIAN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CHONGJIAN.M with the given input arguments.
%
% CHONGJIAN('Property','Value',...) creates a new CHONGJIAN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before chongjian_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to chongjian_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help chongjian
% Last Modified by GUIDE v2.5 22-Mar-2020 18:21:37
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @chongjian_OpeningFcn, ...
'gui_OutputFcn', @chongjian_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before chongjian is made visible.
function chongjian_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to chongjian (see VARARGIN)
axes(handles.axes1);
imshow([255]);
axes(handles.axes2);
imshow([255]);
axes(handles.axes3);
imshow([255]);
% Choose default command line output for chongjian
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes chongjian wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = chongjian_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
global tu
axes(handles.axes1)
[filename,pathname]=uigetfile({ ...
'*.*','All Files(*.*)';},...
'选择文件');
%
if isequal([filename,pathname],[0,0])
return
else
%读取图片
pic = fullfile(pathname,filename);
b = imread(pic);
imshow(b);%上面是打开图片的步骤,这一句是显示图片
tu=b;
title('原始图像');
%handle.axes1=b;
end
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
global tu
global tu2
P = tu;
[N,N]=size(P);
%先进行自定义radon变换------------------------------------------------------------
thm=45; %45度时会出现最大尺寸
pre = imrotate(P,thm);
[mmax,nmax] = size(pre);
s=1;
%创建一个180*nmax的空白图片,用以存储投影后的线状图片
Final = zeros(180/s,nmax);%这里180代表180角度,每个角度投影成为一条线
t = 1;
for theta = 1:s:179
Protate = imrotate(P,theta); %对原图旋转一个角度,求和(线积分)
Pf = sum(Protate,1);
[mreal,nreal]=size(Pf); %计算实际尺寸
%确定起始点
if (nmax - nreal)/2-floor((nmax - nreal)/2) == 0
From = floor((nmax - nreal)/2 + 1);%总点数为偶数时
else
From = floor((nmax - nreal)/2) + 1;%总点数为奇数时
end
%确定结束点
End = floor((nmax-nreal)/2) + nreal;
%将一个角度Radon变换后的线状图存入结果图像的某一行
Final(180/s-t,From:End) = Pf; %从最底下一行开始存起
%上移一行
t = t + 1;
end
%再逆时针旋转
R=imrotate(Final,90);
axes(handles.axes2);
imshow(R,[]);
title('投影图像');
z=2*ceil(norm(size(P)-floor((size(P)-1)/2)-1))+3;% radon变换默认平移点数/角度
e=floor((z-N)/2)+2;
R1=R(e:(N+e-1),:);
[mm,nn]=size(R1);
% subplot(2,3,4);
% imagesc(R1);
% title([int2str(mm),'*',int2str(nn),'正弦图']);
% colormap(gray);
% colorbar;
%滤波函数构造------------------------------------------------------------
g=1-N:N-1;
%Parzen滤波函数
for i=1:2*N-1
h(i)=(24*pi*g(i)*cos(pi*g(i))-96*sin(pi*g(i))-48*pi*g(i)*cos(pi*g(i)/2)+384*sin(pi*g(i)/2)-2*(pi^3)*(g(i)^3)-72*pi*g(i))/(4*(pi^5)*(g(i)^5));
end
h(N)=0.0435;
%将投影与滤波函数卷积----------------------------------------------------
G=zeros(N,180);
for m=1:180
for i=1:N
b=0;
for n=1:N
b=b+h(N+n-i)*R1(n,m);
G(i,m)=b;
end
end
end
%投影滤波后线性内插进行图像重建----------------------------------------------
a=zeros(N); %重建图像初始化,每个像素点像素值为0
ns=(N+1)/2;
for m=1:180 %遍历每个投影角度
r=pi/180; %将角度换为弧度
for i=1:N
for j=1:N %遍历原图的每一个像素点
Xrm=(i-ns)*cos(m*r)+(j-ns)*sin(m*r)+ns-1; %坐标转换
if Xrm<1
n=1; %内插运算整数值
t=abs(Xrm)-floor(abs(Xrm)); %内插运算小数值
else
n=floor(Xrm);
t=Xrm-floor(Xrm);
end
if n>N-1
n=N-1;
end
c=(1-t)*G(n,m)+t*G(n+1,m); %内插后的滤波投影值
a(N+1-j,i)=a(N+1-j,i)+c; %像素值的叠加
end
end
end
%将P、a的像素值变换到0-1之间
P=double(P);
P=P-min(min(P));
kk=max(max(P));
for i=1:N
for j=1:N
P(i,j)=P(i,j)/kk;
end
end
a=double(a);
a=a-min(min(a));
kkk=max(max(a));
for i=1:N
for j=1:N
a(i,j)=a(i,j)/kkk;
end
end
% subplot(2,3,5);
% imshow(a,[]); %重建图形的显示
tu2 = a;
% title('滤波反投影重建图像');
%重建图像质量评价--------------------------------------------------------
%计算归一化均方距离判据d;
ave=0;
for x=1:N
for y=1:N
ave=ave+P(x,y);
end
end
ave=ave/(N*N);
x1=0;
x2=0;
for x=1:N
for y=1:N
x1=x1+(P(x,y)-a(x,y))^2;
x2=x2+(P(x,y)-ave)^2;
end
end
evaluate_d=sqrt(double(x1/x2));
%计算归一化平均绝对距离判据 r;
x3=0;
x4=0;
for x=1:N
for y=1:N
x3=x3+abs(P(x,y)-a(x,y));
x4=x4+abs(P(x,y));
end
end
evaluate_r=x3/x4;
%计算最坏情况距离判据e
ns=floor(N/2)-1;
g=zeros(ns);
for x=1:ns
for y=1:ns
T=(P(2*x,2*y)+P(2*x+1,2*y)+P(2*x,2*y+1)+P(2*x+1,2*y+1))/4;
R=(a(2*x,2*y)+a(2*x+1,2*y)+a(2*x,2*y+1)+a(2*x+1,2*y+1))/4;
g(x,y)=abs(T-R);
end
end
evaluate_e=max(max(g));
%结果文本显示------------------------------------------------------------
% o=ones(500,1000);
% subplot(2,3,6);
% imshow(o,[]);
% s_title=['图像重建精度判据如下:'];
% text(0,0,s_title,'Fontsize',14);
% s=num2str(toc);
% s_one=['run time = ' s ' s;'];
% text(0,100,s_one,'FontSize',10);
% s=num2str(evaluate_d);
% s_two=['归一化均方距离判据d=' s ';'];
% text(0,200,s_two,'Fontsize',10);
% s=num2str(evaluate_r);
% s_three=['归一化平均绝对距离判据r=' s ';'];
% text(0,300,s_three,'Fontsize',10);
% s=num2str(evaluate_e);
% s_four=['最坏情况距离判据e=' s ';'];
% text(0,400,s_four,'Fontsize',10);
% toc
% hObject handle to pu
没有合适的资源?快使用搜索试试~ 我知道了~
【图像重建】 GUI投影法图像重建【含Matlab源码 861期】.zip
共8个文件
m:5个
jpg:2个
fig:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 141 浏览量
2024-06-21
11:56:29
上传
评论
收藏 72KB ZIP 举报
温馨提示
Matlab领域上传的代码均可运行,亲测可用,直接替换数据即可,适合小白; 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主或扫描博客文章底部QQ名片; 4.1 博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作 图像重建:ASTRA算法图像重建、BP神经网络图像重建、投影法图像重建、小波变换图像分解重建、字典学习KSVD图像低秩重建、主成分分析PCA图像重建、正则化图像去噪重建、离散余弦变换DCT图像重建、卷积神经网络的图像超分辨率重建
资源推荐
资源详情
资源评论
收起资源包目录
【图像重建】 GUI投影法图像重建【含Matlab源码 861期】.zip (8个子文件)
【图像重建】基于matlab GUI投影法图像重建【含Matlab源码 861期】
2.jpg 6KB
运行结果1.JPG 69KB
OMP.m 2KB
chongjian.m 9KB
runme.m 5KB
chongjian.fig 9KB
EM.m 1KB
duibi.m 3KB
共 8 条
- 1
资源评论
Matlab领域
- 粉丝: 3w+
- 资源: 3099
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功