function varargout = dian(varargin)
% DIAN M-file for dian.fig
% DIAN, by itself, creates a new DIAN or raises the existing
% singleton*.
%
% H = DIAN returns the handle to a new DIAN or the handle to
% the existing singleton*.
%
% DIAN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DIAN.M with the given input arguments.
%
% DIAN('Property','Value',...) creates a new DIAN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before dian_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to dian_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help dian
% Last Modified by GUIDE v2.5 15-May-2007 12:06:11
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @dian_OpeningFcn, ...
'gui_OutputFcn', @dian_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 dian is made visible.
function dian_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 dian (see VARARGIN)
% Choose default command line output for dian
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes dian wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = dian_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)
% 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)
%fbp.m for faridani's code;
%Parallel-beam filtered backprojection algorithm
% for the standard lattice
% Last revision: August 29, 2001
%specify input parameters here
p=200; %number of view angles between 0 and pi
q=64; %q=1/d, d = detector spacing
MX=128; MY = 128; %matrix dimensions
roi=[-1,1,-1,1]; %roi=[xmin xmax ymin ymax]
% roi=[-0.5,0.5,-0.5,0.5]; %region of interest where
%reconstruction is computed
circle = 1; % If circle = 1 image computed only inside
% circle inscribed in roi.
%Specify parameters of ellipses for mathematical phantom.
% xe = vector of x-coordinates of centers
% ye = vector of y-coordinates of centers
% ae = vector of first half axes
% be = vector of second half axes
% alpha = vector of rotation angles (degrees)
% rho = vector of densities
xe=[0 0 0.22 -0.22 0 0 0 -0.08 0 0.06 0.5538];
ye=[0 -0.0184 0 0 0.35 0.1 -0.1 -0.605 -0.605 -0.605 -0.3858];
ae=[0.69 0.6624 0.11 0.16 0.21 0.046 0.046 0.046 0.023 0.023 0.0333];
be=[0.92 0.874 0.31 0.41 0.25 0.046 0.046 0.023 0.023 0.046 0.206];
alpha=[0 0 -18 18 0 0 0 0 0 0 -18];
rho= [1 -0.98 -0.02 -0.02 0.01 0.01 0.01 0.01 0.01 0.01 0.03];
%end of input section
b=pi*q; rps=1/b;
alpha = alpha*pi/180;
if MX > 1
hx = (roi(2)-roi(1))/(MX-1);
xrange = roi(1) + hx*[0:MX-1];
else
hx = 0; xrange = roi(1);
end
if MY > 1
hy = (roi(4)-roi(3))/(MY-1);
yrange = flipud((roi(3) + hy*[0:MY-1])');
else
hx = 0; yrange = roi(3);
end
center = [(roi(1)+roi(2)), (roi(3)+roi(4))]/2;
x1 = ones(MY,1)*xrange; %x-coordinate matrix
x2 = yrange*ones(1,MX); %y-coordinate matrix
if circle == 1
re = min([roi(2)-roi(1),roi(4)-roi(3)])/2;
chi = ((x1-center(1)).^2 + (x2-center(2)).^2 <= re^2); %char. fct of roi;
else
chi = isfinite(x1);
end
% chi= logical(ones(16384,1));
x1 = x1(chi); x2 = x2(chi);
P = zeros(MY,MX); Pchi = P(chi);
%P= zeros(128,200);
h = 1/q;
s = h*[-q:q-1];
% s= h*[-32:0.5:31.5];
bs = [-2*q:2*q-1]/(q*rps);
wb = slkernel(bs)/(rps^2); %compute discrete convolution kernel.
pp= 0;
for j = 1:p % j=1:200;
phi = (pi*(j-1)/p);
theta = [cos(phi);sin(phi)];
RF = Rad(theta,phi,s,xe,ye,ae,be,alpha,rho); %compute line integrals
% P(:,j)=RF';
% end
% convolution
C = conv(RF,wb);
Q = h*C(2*q+1:4*q); Q(2*q+1)=0;
% interpolation and backprojection
Q = [real(Q)';0];
t = theta(1)*x1 + theta(2)*x2;
k1 = floor(t/h);
u = (t/h-k1);
k = max(1,k1+q+1); k = min(k,2*q);
Pupdate = ( (1-u).*Q(k)+u.*Q(k+1));
% Pupdate = Q(k);
% Pchi=Pchi+ Pupdate;
Pchi= Pchi + Pupdate;
end % j-loop
P(chi) = Pchi*(2*pi/p);
P(chi)= Pchi* (2*pi/p);
pmin = min(min(P));
pmax = max(max(P));
figure,window3(pmin,0.15,roi,P); title('q=64,p=200');% view the computed image
%figure,window3(-0.07,0.07,roi,P); title('q=64,p=200')
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton1.
function pushbutton1_ButtonDownFcn(hObject, eventdata, handles)
% 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 pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
p=phantom('Modified Shepp-Logan',256);
subplot('position',[0.55 0.2 0.25 0.35 ]);imshow(p);
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
- 1
- 2
- 3
- 4
前往页