Lab7 PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Labwork7

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

LabWork7: Visualization of Medical Images


The main purpose of this lab is to keep working with Medical Images focusing on the visualization of
some CT images of the human body.

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.

- lateral cross- sections at position xc=60 pixels


sagCs=getPlanarCrossSection(I,[1,0,0],60);

- Frontal cross-sections at position yc=35 pixels


sagCs=getPlanarCrossSection(I,[0,1,0],35);

- Transversal cross-sections at position zc=90 pixels


sagCs=getPlanarCrossSection(I,[0,0,1],90);

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.

Lateral orthogonal planar projections


sagP=getPlanarProjection(I,[1,0,0],'max');
sagP=getPlanarProjection(I,[1,0,0],'mean);

Figure 2. From left to right. Lateral orthogonal planar projection applying the maximal value. Lateral
orthogonal planar projection applying the mean value.

Frontal orthogonal planar projections


sagP=getPlanarProjection(I,[0,1,0],'max');
sagP=getPlanarProjection(I,[0,1,0],'mean');
Figure 3. From left to right.
Frontal orthogonal planar
projection applying the
maximal value. Frontal
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

Transversal orthogonal planar projections


sagP=getPlanarProjection(I,[0,0,1],'max');
sagP=getPlanarProjection(I,[0,0,1],'mean');

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;

When it comes to the rotation angle phi, we know fromtrigonometry that:


phi=atan(iNormVec(1)/iNormVec(2));

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

if x2<68.5 & x2>67 & z2<5.5 & z2>4


z;x;x2;z2;
end

This way we get that:


(x, z) -> (67.099, 4.87) -> (68, 5)
(x, z) -> (67.2028, 4.172) -> (67, 4)
That is, the point (67, 5) is never achieved and it therefore
gets the value ’0’.
This however, needs to be fixed.
One possible solution (although not very precise) is to
perform median filtering of the image in two dimensions.
This way, each output pixel contains the median value in a 3-
by- 3 neighborhood around the corresponding pixel in the

Figure 6. The original image rotated 45 degrees.

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

Figure 7. Original rotated image and filtered image 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);

The result can be seen in Figure 8.

Figure 8. Rotated image. Only ’0’s have been filtered.

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).

You might also like