模拟的r射线,不用考虑散射了。
function []=spheresource()
h=input('source to collimator:');
H=input('source to detector:');
r=input('hole diameter:');
d1=input('pinhole1 parameter(x y axis):');
d2=input('pinhole2 parameter:');
d3=input('pinhole3 parameter:');
d4=input('pinhole4 parameter:');
%h is distanse source to collimator,H is source to detector
%dx is center of the hole to y axis
%dy is center of the hole to x axis
%spheresource(5,20,3,3,4)
%spheresource(5,20,-3,3,4)
%spheresource(5,20,2.5 ,2.5,-2.5 ,2.5,2.5,-2.5,-2.5,-2.5,4)
N=80;%256可调分辨率
I64=zeros(N,N); %预定义平面164的灰度值为O
[m,n]=meshgrid(linspace(-N/2,N/2-1,N));%确定坐标系及坐标原点的位置
% h=1;H=2;
% dx=5;
% r=5;
r1=r*H/h; %圆半径大小控制变量(单位pixel)
a1=d1(1)*H/h; %圆心位置控制变量
b1=d1(2)*H/h; %圆心位置控制变量
D1=((m+a1).^2+(n+b1).^2).^(1/2); %圆函数关系式
i=find(D1<=r1); %单下标寻址实现语句,find()函数足条件D<-r的像素点的单下标值
I64(i)=0.2; %按要求为像素点赋值
r2