Professional Documents
Culture Documents
Lab7 PDF
Lab7 PDF
Lab7 PDF
Biomedical informatics
University of Ljubljana, Faculty of Electrical
Engineering
Autor:
dr. Tomaž Vrtovec Koldo Eizmendi Gallastegui
Laboratory of Imaging Technologies Registration number: 70081273
Academic year: 2018/2019
University of Ljubljana, Faculty of Electrical Engineering Koldo Eizmendi Gallastegui
Laboratory of Imaging Technologies
Biomedical informatics 2018/2019
Question 1
This first question asks to enclose the pictures of some othogonal planar cross-sections of the 3D
image. Just a little change needs to be made in the code written in the lab. In fact, depending on the
cross section asked, the inputs of the function getPlanarCrossSection() will need to be changed. The
orthogonal planar cross sections asked are the shown in Figure 1.
Figure 1. From left to right: lateral cross-sections at position xc=60 pixels. Frontal cross-sections at position
yc=35 pixels. Transversal cross-sections at position zc=90pixels.
1
University of Ljubljana, Faculty of Electrical Engineering Koldo Eizmendi Gallastegui
Laboratory of Imaging Technologies
Biomedical informatics 2018/2019
Question 2
This second question asks to enclose the pictures of lateral, frontal and transversal orthogonal planar
projections of the 3D image by applying the maximal and mean value for the point function PF. The
pictures and the code used shown below.
Figure 2. From left to right. Lateral orthogonal planar projection applying the maximal value. Lateral
orthogonal planar projection applying the mean value.
2
University of Ljubljana, Faculty of Electrical Engineering Koldo Eizmendi Gallastegui
Laboratory of Imaging Technologies
Biomedical informatics 2018/2019
Figure 4. From left to right. Transversal orthogonal planar projection applying the maximal value. Transversal
orthogonal planar projection applying the mean value.
Question 3
When applying the maximal value, minimal value, mean value, median value, standard deviation and
variance for the point function the most useful projections when visualizing CT images of the human
body depend on what we are looking for.
Maximal intensity projections basically consist on projecting the voxel with the highest attenuation
value on every view throughout the volume onto a 2D image. In other words, for each XY coordinate
only the pixel with the highest value along the Z axis is represented, so that in a single bidimensional
image all dense structures in a given volume can be observed. This method tends to display bones.
However, lower attenuation structures are not well visualized.
Minimun intensity projection, on the other hand, is somehow the contrary of the maximum intensity
projection. In fact, with this projection the voxel projected is the one with the lowest attenuation
value. It is therefore useful for analyzing hypodense structures.
A similar analysis can be done with the rest of the projection types.
In conclusion, we can say that depending on what we are looking for one type of projection or
another will be the most useful one.
3
University of Ljubljana, Faculty of Electrical Engineering Koldo Eizmendi Gallastegui
Laboratory of Imaging Technologies
Biomedical informatics 2018/2019
Question 4
This last question asks to compute the arbitrary frontal oblique planar projection defined by the
normal vector to a given projection plane. The following lines include the code used and some
further explanations about it, as well as the images achieved.
First of all, we have to take into account that the formula given in Lab07-instructions.pdf is in fact the
rotation matrix, that by definition rotates a given matrix around the point (0,0). In our case however,
we want to rotate the image around a rotation axis defined in the centre of the original image. It is
therefore necessary to first define the centre of the image and then make some changes in the
rotation matrix expression.
Let’ start defining the centre of the image. Even though at first sight it might seem that the centre
will simply be the point (X/2, Z/2) that’s not very precise. In fact, it can be proven that the real centre
will be (X/2+0.5, Z/2+0.5). That is, if we for example had a 4x4 matrix, the centre would not be the
point (2, 2), but the point (2.5, 2.5). This can be better seen in Figure 5.
Figure 5. A (8x5) matrix. It can be seen that the centre is not (4, 2.5).
Figure 5 represents a (8x5) matrix. It can be easily seen that the centre is not (4, 2.5) but (4.5, 3).
Once the centre is well defined, the rotation matrix needs to be rearranged and written in Matlab.
We finally get:
xcentre=X/2+0.5;
zcentre=Z/2+0.5;
x2=(xcentre-x)*cos(phi)-(zcentre-z)*sin(phi)+xcentre;
z2=(xcentre-x)*sin(phi)+(zcentre-z)*cos(phi)+zcentre;
Being iNormVec the normal vector given. Now the whole program will be shown and explained.
elseif iNormVec(3)==0
xcentre=X/2+0.5;
zcentre=Z/2+0.5;
oP=zeros(Z,X);
phi=atan(iNormVec(1)/iNormVec(2));
for z=1:Z
4
University of Ljubljana, Faculty of Electrical Engineering Koldo Eizmendi Gallastegui
Laboratory of Imaging Technologies
Biomedical informatics 2018/2019
for x=1:X
x2=round((xcentre-x)*cos(phi)-(zcentre-z)*sin(phi)+xcentre);
z2=round((xcentre-x)*sin(phi)+(zcentre-z)*cos(phi)+zcentre);
if x2<0 | x2>X
x2=[];
end
if z2<0 | z2>Z
z2=[];
end
if z2==0
z2=1;
end
if x2==0
x2=1;
end
oP(z2,x2)=feval(iFunc,iImage(:,x,z));
end
end
end
end
This code is basically the same one written in the lab with some changes. The expressions
aforementioned have been added and some other changes have also been made. The code contains
two main loops. This way every single position is rotated. Afterwards, with all the conditions added
some forbidden positions are somehow fixed. In fact, if the new point falls outside the limits or if any
of its indexes is 0 that position needs to be fixed.
The image achieved with this code is shown in Figure 6.
This figure has been achieved with an input normal vector (1,1,0). It can be seen that the rotation
and the limits have been correctly programed. However, there is something that is not working well.
In fact, there are many black pixels in the image, that is, the matrix has ’0’ values in places it should
have some other value.
The reason for that is simple. Those black points are point of the matrix that have not been achieved
with the rotation equation. In fact, when rounding the rotated points, some points of the matrix are
never achieved. Let’s take for example the point (x, z) = (67, 5).
If we take away the round() from the equation and we afterwards add the next code:
5
University of Ljubljana, Faculty of Electrical Engineering Koldo Eizmendi Gallastegui
Laboratory of Imaging Technologies
Biomedical informatics 2018/2019
input image. We then solve the problem of those black pixels, but we obviously lose resolution. In
fact, the new image achieved looks kind of distorted because ever single pixel has been interpolated.
The results obtained for the same normal vector are shown in Figure 7.
displayImage(oP,'Sagittal projection'); % original rotated image
oP2=medfilt2(oP); % filtered image
imshowpair(oP,oP2,'montage') % both images side by side
6
University of Ljubljana, Faculty of Electrical Engineering Koldo Eizmendi Gallastegui
Laboratory of Imaging Technologies
Biomedical informatics 2018/2019
The image achieved with the aforementioned filtering technique however, changes every single
pixel, ven those that are not 0. With the following code only pixels with 0 value will be filtered:
zeroMask = oP==0; % Mask of 0s
H = fspecial('average',[3 3]);
oP=roifilt2(H,oP,zeroMask);
Finally, the three rotations asked are shown in the Figure 9. The images have been achieved with the
aforementioned code, including the last filter discussed.
All in all, we can say that because of the rounding, some points of the matrix are never achieved, and
so, whenever an image is rotated, it is likely that some black points will interfere our image.
Depending on the specifications of the image a filtering such as the one shown in this report can be
useful to fix those bugs.
7
University of Ljubljana, Faculty of Electrical Engineering Koldo Eizmendi Gallastegui
Laboratory of Imaging Technologies
Biomedical informatics 2018/2019
Figure 9. From left to right. nx=(3.83, 9.24). nx=(1, 1, 0) . nx=(9.24, 3.83, 0).