- #1
Fiboehh
- 3
- 0
Hello I'm a student engineer and I'm trying to find the weighted reconstruction matrix used for ART image reconstruction. The weighted matrix gives for each projections what pixels are influenced by a ray from a laser.
In attachment you see an image of what the problem is. The matrix must be rotated a given time for a given rotationangle each time. For this example it is 40 degrees and 8 times. I must calculate whenever a cell falls into the ray and give that cell a one. The cells outside the ray get a zero. So for every rotation i have to calculate which cells fall in the ray. I have the begin coordinates, and tried so to find out the next. But i don't what i do wrong, tried with poolcoordinates but i can't find it.
My second problem is with the detection, The ray is lineair but how can I calculate when the cell is in the ray. If its a rectangle its simple, but i can't find it when its oblique.
The coordinates are given and the all the distances in the second attachment. I really hope someone can help me.
Here the MATLAB code i already have:
In attachment you see an image of what the problem is. The matrix must be rotated a given time for a given rotationangle each time. For this example it is 40 degrees and 8 times. I must calculate whenever a cell falls into the ray and give that cell a one. The cells outside the ray get a zero. So for every rotation i have to calculate which cells fall in the ray. I have the begin coordinates, and tried so to find out the next. But i don't what i do wrong, tried with poolcoordinates but i can't find it.
My second problem is with the detection, The ray is lineair but how can I calculate when the cell is in the ray. If its a rectangle its simple, but i can't find it when its oblique.
The coordinates are given and the all the distances in the second attachment. I really hope someone can help me.
Here the MATLAB code i already have:
Code:
function f = reconmatrix( projections, angle , Lx ,Ly , Dx , Dy , HRD , HDS )
%%functie die reconstructiematrix berekent adhv bovenstaande parameters
% projecties: aantal projecties moeten gemaakt worden
%angle: de hoek waarover moet verdraaid worden
% Lx en Ly het aantal cellen in respec x en y lengte
% Dx en Dy de werkelijke afstand van 1 cel in respec x en y lengte
% HRD= half ray distance , halfe astand van de laserstraal
% HDS = half distance to source, halfe afstand laser - detector
%%Hulp variablen
if ( mod(Lx,2) == 0)
Mx = Lx/2;
else
Mx=(Lx+1)/2;
end
if ( mod(Ly,2) == 0)
My = Ly/2;
else
My=(Ly+1)/2;
end
dx=Dx/2;
dy=Dy/2;
siz=Lx*Ly;
w = zeros(projections,siz);
alfa=angle;
%opvullen alle projecties
for p=1:projections %aantal projectie keer berekenen
for j=0:(Lx-1)
for i=1:Lx
if i==1 % voor de eerste projectie
a = (-Mx+dx+(i-1)*Dx);
b = (My-dy-j*Dy);
else % voor de volgende projectie verder gaan met
a = x;
b = y;
end
len = a*a + b*b;
l = sqrt(len);
if a > 0
gamma = atand(b/a);
else if b >= 0
gamma = atand(b/a)+180;
else
gamma = atand(b/a)-180;
end
if a == 0 && b > 0
gamma = 90;
else
gamma = -90;
end
end
beta = gamma - alfa;
x = l * cosd(beta);
y = l * sind(beta);
if (x > (-1*HDS) ) && ( x < HDS ) && (y < HRD ) && (y > (-1*HRD))%controleren wanneer binnen rechthoek valt
w(p,i+j*Lx)= 1;
end
end
end
end