You are on page 1of 12

FUNDAMENTALS OF IMAGING TECHNIQUES, IMAGE REGISTRATION AND DIGITAL

IMAGE PROCESSING
ELEN3008: Biomedical Measurement, Instrumentation and Imaging
Basheq Tarifi (1696842)

School of Electrical & Information Engineering, University of the Witwatersrand, Private Bag 3, 2050, Johannesburg, South Africa

Abstract: Fundamental concepts regarding imaging is presented, including functional and structural biomedical imaging techniques
such as x-ray, computed tomography, magnetic resonance imaging and nuclear medicine. Image registration and its importance
in the field of biomedical imaging is also discussed. Some basic digital image processing is carried out using MATLAB, including
processing of image format, conversion between different representations and manipulation of image histograms.

Key words: ELEN3008, biomedical imaging, image registration, histogram, image processing, MATLAB

1. INTRODUCTION 2.1 X-ray Imaging

It is now the age of healthcare where medical imag- X-rays are produced by a source and then pass
ing is integral to the diagnosis and treatment of dis- through a person to be detected by specific
ease - making it pertinent and essential to the field equipment.”X-rays” are actually gamma rays with en-
of biomedical engineering. The ability to assess both ergies in the range of 20 − 150keV [4]. The only dif-
the physiological and anatomical condition of the ference between x-rays and normal gamma rays is the
body without directly seeing the internal structure origin – gamma rays are usually produced by natural
has made the job of health practitioners much easier, decay whereas x-rays are produced in an x-ray tube.
has advanced medical research and has saved countless Therefore, x-ray imaging is a transmission based imag-
lives[1]. In short, it has dramatically altered medical ing technique. X-rays are produced by accelerating a
practice and healthcare as a whole. beam of electrons to hit a metal surface. The x-ray
tube consists of a cathode, which serves as the source
There are many imaging techniques which use differ- of the electrons, and an anode. There is a large po-
ent methods and mediums, depending on what it is tential difference between 15kVp and 150kVp that is
that the medical practitioner wants to image and what applied from the anode to the cathode, also known
the suspected diagnosis is. Each of these techniques as the kVp . The cathode is heated and at a suffi-
have certain uses and limitations, more of which will cient temperature, electrons have enough energy to
be discussed in this paper. break away. These electrons experience an attractive
force towards the anode due to the potential differ-
Where in the past, medical images may have been pro- ence. At the anode, the accelerated electrons pene-
duced on film, the future of imaging lies in the digital trate the metal surface and lose their kinetic energy,
world[1]. As such, it is important to understand how which is emitted as x-rays. The intensity of the x-ray,
digital images work, the composition and structure of I, is proportional to the potential difference that was
these images, as well as the different techniques of dig- applied across the anode and cathode, i.e. I ∝ (kVp )2 .
ital image processing. Since digital images can be rep- This beam of x-rays is then passed through a collima-
resented by matrices and the processing may involve tor which shapes it and ensures that it is directed to
matrix manipulation, computers and software such as the area which needs to be imaged by only allowing
MATLAB or Octave lend themselves well to the field beams with the correct direction to pass through it
of digital image processing[2]. [4].

2. IMAGING TECHNIQUES As the x-rays pass through the body, they interact
with tissues and attenuate. The differential attenua-
Imaging techniques can be categorised in multiple tions due to unlike tissue is what causes the contrast
ways – either as structural imaging techniques, which that is present on x-ray images [4]. X-rays that pass
image the anatomical structure of the body, or as func- through the body can have different levels of interac-
tional imaging techniques, which image the physiolog- tion. There are some that are transmitted with no
ical function of the body. When dealing with radia- interactions; these are known as primary radiation.
tion, imaging techniques can also be classified accord- Other x-rays undergo compton scattering and coher-
ing to the source of energy that is detected. Trans- ent scattering, which are mechanisms of interaction
mission based imaging involves externally produced with tissue – these may change trajectories as they
energy passing through the body and detected. Emis- pass through the body and are called secondary ra-
sion based imaging, the energy or radiation that is diation. Those x-rays that are absorbed completely
detected is produced inside the body [3]. do not reach the detector constitute absorbed radia-
tion [4]. X-rays are absorbed due to the photoelectric cal applications. Tumours, cysts, injured tissue and
effect. These phenomena result in an effective atten- blood clots are easily viewed using CT. Different soft
uation that differs between tissues. The intensity of tissues are also distinguishable when using CT and
the x-ray after it passes through the body is given by this eliminates the need for many invasive procedures
which are often costly and require hospitalisation. CT
I = I0 e−µx (1) finds uses in radiation therapy as well [3]. There are
where I, I0 and x represent the intensity of the beam not many disadvantages to CT scanning today – in
at position x, the initial intensity and the distance the past they may have taken long but with modern
the beam has travelled, respectively. µ represents the computers, the process is quick. The only downside
attenuation coefficient, which is the combined effect of to computed tomography is that the radiation dose is
the aforementioned phenomena and is a constant for a much higher than that of a conventional x-ray [4].
specific tissue [4]. The x-rays are finally detected by a
detecting film or ionising chamber, and x-ray images 2.3 Magnetic Resonance Imaging
are produced [3].
Magnetic resonance imaging, or MRI, is a structural
The high contrast and high resolution images that are imaging technique which also has functional applica-
produced by x-rays, as well as the relatively small ra- tions. It exploits the fact that roughly 60% of a per-
diation dose required are some advantages of x-ray son’s body mass is hydrogen. Since a hydrogen nu-
imaging [3]. There is also permanent record of the cleus consists of just one proton, a tiny magnetic field
image. However, there are also some disadvantages; is produced when the nucleus spins. If hydrogen is
x-rays are unable to discern depth and real-time imag- placed in a large static magnetic field it will spin like a
ing is not possible. These qualities make x-rays ideal gyroscope at a specific frequency. The magnetic fields
for dental, chest and bone imagery but not suitable for used in MRI are typically more than 10 000 times more
the imaging of soft tissue and areas where there are intense than the Earth’s magnetic field [4]. The spin-
tissues with similar attenuation coefficients [3]. Note ning of the nucleus is also known as precession and
that the spatial resolution of x-rays is proportional to the frequency at which it precesses is called the Lar-
the width of the x-ray beam, as well as the distance mor frequency, which is unique to every material and
between the source and the detector. The signal to proportional to the magnetic field. Although every hy-
noise ratio is proportional to the kVp , the size of the drogen atom precesses at the Larmor frequency, they
patient and a number of other factors [4]. are not precessing in phase. For imaging purposes, a
weak radiofrequency (RF) rotating pulse is applied in
2.2 Computed Tomography a direction perpendicular to the static magnetic field.
This radiofrequency pulse is of the Larmor frequency
Computed Tomography, commonly known as CT and excites the protons, which aligns the phases so
scanning, was invented to address the shortfalls of that the majority have coherent precession. This co-
conventional x-ray imaging and to allow us to con- herent precession produces a measurable voltage [4].
struct 3D images from 2D scans. Computed tomogra-
phy combines x-ray detection with image reconstruc- When the RF pulse is removed, the hydrogen protons
tion techniques in order to create planar “slices” of revert back to their initial equilibrium state. How-
the body [4]. If multiple scans are done, they can be ever, in order to do so, they need to release the energy
layered to generate a 3D reconstruction. Since CT which they absorbed. This energy emission is the volt-
is an extension of x-ray imaging, it is also a struc- age signal that is measured in MRI. The time it takes
tural imaging transmission technique. With regards to revert back to its original magnetic moment is de-
to the method, a collimated beam of x-rays is directed pendent on two time constants – T1 , the longitudinal
through the section (or “slice”) of the body that needs relaxation constant and T2 , the transversal relaxation
to be imaged. This beam is very narrow and is sent to constant [3]. These constants are used to discrimi-
a specific detection site on the detector, which mea- nate different types of tissue and in the process of
sures the absorption. The collimator and detector sys- image construction. In addition to the strong mag-
tem is then incrementally rotated around the body netic field, weaker graded magnetic fields are applied
and at each increment, an x-ray beam is transmitted such that the magnetic field the body experiences has
and an absorption measurement is attained. This pro- a gradient in the three spatial directions. This results
cess is repeated until the system is rotated 180◦ . Af- in spatial information being encoded into the signals
ter all the absorption measurements are collected, the that are measured – for example, since the frequency
computer then uses the information to reconstruct the of precession is dependent on the magnetic field, every
planar cross-section using methods such as backpro- point will have a different Larmor frequency and the
jection and iterative techniques [3]. Post-processing is signal measured will be different. In order to create
also performed to colour code and highlight features the image, the signal that is measured is digitised and
of the cross section. an inverse Fourier transform is performed in order to
convert the signal to the spatial domain [4]. Once the
Computed tomography has a vast number of medi- image is formed, computers can be used to introduce
highlights between different types of tissue. It takes used depends on which element bonds well with the
considerable skill to adjust the equipment such that chemical substrate needed. These radiotracers are of-
different tissues are distinguishable [3]. ten inhaled, injected into the bloodstream or ingested
orally by the patient (once again, this is dependent
MRI is used extensively in detecting disease and plan- on the area of the body in question). An uptake of
ning for surgical procedures. It is used to image most chemical substrate above normal levels is often an in-
of the body, including the brain, abdomen, heart, dicator of disease. For example, cancer cells require
large vessels, breast, bones, soft tissue, joints, carti- a much higher level of glucose – this shows up in a
lage, muscle, the head and the neck. It can be used nuclear medicine image [4].
for both children and adults and can also detect can-
cer pathologies, tumours, and haemorrhages[3]. MRI Once the radiotracer is introduced into the body, the
has high spatial resolution (approximately 1 mm) and radioactive element decays. The decay is usually in
three-dimensional imaging capabilities, which make it the form of γ (gamma) rays which are emitted in all
a favourable imaging technique. However, MRI is directions [4]. Note that these γ rays are no different
much slower compared to other imaging techniques in form to the γ rays produced by an X-ray source, and
and this makes it susceptible to movements of the pa- so they undergo the same attenuation in the body due
tient. The equipment is also extremely expensive and to Compton scattering, coherent scattering and the
hence less common when compared to other imaging photoelectric effect. The detection is done by what is
systems. The signal to noise ratio is affected by the called a “gamma camera”, which is placed around the
strength of the magnetic field as well as the relaxation area to be imaged. This gamma camera consists of
constants. The spatial resolution is inversely propor- a collimator, which only allows γ rays close to 90◦ to
tional to the number of data points acquired, as well pass through it. This allows for the position of the γ
the width of the RF pulse applied [4]. ray to be determined (since the γ rays from other parts
which had angled trajectories will not pass through).
Functional MRI (fMRI) is an application of MRI The now parallel γ rays then come into contact with
which allows the detection of brain activity, scintillation crystals, which are special substances that
which manifest as changes in blood flow, cerebral emit photons when energised. The photons are in
metabolism, oxygenation or volume. Since oxy- turn converted to an electrical signal by photomul-
genated and deoxygenated blood react differently to tiplier tubes. The image is then formed by analysing
magnetic fields, measuring the change of magnetic sus- the spatial distributions as well as the magnitudes of
ceptibility of blood is a common means of detection in the signals formed by the photomultiplier tubes. The
fMRI. fMRI has been used to study and map areas of spatial resolution of nuclear medicine images depends
the brain linked with stimuli and high level cognition, on the gamma camera as well as the interactions of γ
and can be used to image a brain in real-time [3]. rays in the body [4]. The geometry of the collimator
and the thickness of scintillation crystals used can de-
2.4 Nuclear Medicine crease spatial resolution. The signal to noise ratio is
affected by the amount of of γ rays produced, which in
Unlike the methods that have been discussed up to turn is depends on the amount of radioactive material
this point, nuclear medicine does not produce a map introduced into the body. However, there is an upper
of the anatomical structure of the body. Instead, it limit to this as the radiation dose can not be exceeded
images the distribution of radioactive substances that [4].
were purposely introduced into the body. The use of
nuclear medicine lies in the fact that many diseases are Nuclear medicine also has the ability to produce three
initiated by or affect the physiological and biochemical dimensional images by using the principle of tomogra-
processes that occur within the body. These changes phy [4]. This technique combines nuclear medicine
may damage tissue and lead to decreased organ func- and certain procedures from CT scanning and is
tion with time – examples include oedema (swelling called Single Photon Emission Computed Tomogra-
due to excess fluid), and tumours (both growth and phy (SPECT). The basic difference between SPECT
metastasis). As such, nuclear medicine forms an im- and normal CT is that the γ rays are emitted from
portant part of clinical diagnosis since it can detect within the body [1]. A rotating gamma camera is
these early changes in the body before they do dam- used to obtain data from around the patient and then
age. It does this by imaging the uptake and biodis- image reconstruction methods are used to generate
tribution of radiotracers that are administered to the cross sectional images of the internal distribution of
patient. These radiotracers are actually compounds radiotracers. SPECT provides much higher contrast
which consist of chemical substrates which are linked and resolution when compared with the images pro-
to a small amount of a radioactive element [3]. The duced by conventional nuclear medicine [1]. SPECT
choice of chemical substrate depends on the part of and nuclear medicine find major clinical applications
the body which needs to be imaged – for example, if in the measurement of blood perfusion in the brain,
it is the kidney then a chemical which passes through the diagnosis of tumors, and the assessment of cardiac
the kidney will be chosen. The radioactive element function [4].
Another application of nuclear medicine is known as 3.2 Uses in Medical Imaging
Positron Emission Tomography (PET). PET scan-
ning is similar to SPECT in that tomography is In many imaging techniques such as CT, PET,
used to image physiological function, not anatom- SPECT and fMRI, two dimensional “slices” or cross
ical structure [4]. The main difference is that in sectional images of the body are taken. They are taken
PET, the radiotracer used emits positrons, not γ rays at multiple positions such that many two dimensional
(as with SPECT and conventional nuclear medicine). images can be layered to produce a three dimensional
Positrons are anti-matter versions of electrons, i.e. recreation. Image registration is required for this, in
they have the structure of electrons but they have a order to map every image together and form a coher-
positive charge instead of negative. When this emitted ent three dimensional image. Since nuclear medicine
positron collides with an electron from the body, there (PET or SPECT) just images the distribution of ra-
is an annihilation reaction. Annihilation reactions re- diotracers within the body, a CT scan is often done be-
sult from the collision of matter with anti-matter. 2 forehand or simultaneously and used as a background
γ rays are produced from this reaction, each with an to the PET/SPECT image that is produced. This pro-
energy of 511 keV [4]. The reaction can be written as vides anatomical context for the physiological function
follows: that is imaged [5].

As explained in Section 2.3, fMRI is often used to as-


e− + e+ → 2γ (2) sess the activity of the brain. For such activities, im-
age registration is critical. During the fMRI process,
the patient is asked to perform an activity over and
The two γ rays travel at 180◦ to each other and both over and the brain function is assessed by taking 3D
need to be detected. As such, a PET detection sys- MR images of the brain. The brain activity manifests
tem consists of a complete ring of scintillation crystals as signals on the fMR image and in order to maximise
around the patient [4]. Since the γ rays will be emitted this signal and produce accurate results, many images
at the same time and they travel at the speed of light, need to be taken and registered [6].
they will be both be detected by the camera within a
very small time window. The location of the two scin- 3.3 Methods of Image Registration
tillation crystals which detect the γ rays act as the end
points of the line on which the annihilation reaction There are many methods of image registration, some
occured – this forms the basis for localisation of the of which are listed here.
signal (as opposed to using a collimator as in SPECT
and conventional nuclear medicine). This makes PET 3.3.1 Point based registration: This form of regis-
more accurate and efficient than SPECT. PET finds tration relies on pairs of corresponding points that can
uses mainly in oncology, cardiology and neurology [3]. be detected either by the algorithm or by a person be-
It produces high contrast and high resolution images forehand. The registration algorithm then attempts to
but has disadvantages in the form of cost and the dif- perform a geometric transformation that would map
ficulty in producing positron-emitting radiotracers [4]. the corresponding points together [5].

3. IMAGE REGISTRATION
3.3.2 Surface based registration: The surfaces and
3.1 Definition boundaries of an anatomical object or structure is a
easily characterized geometrical feature that can be
One of the most important image processing tech- used for the mapping of images in medical image reg-
niques in the context of biomedical engineering is im- istration. Surface-based image registration methods
age registration. Image registration is a method of involve determining corresponding surfaces in differ-
aligning or fusing two or more images from the same ent images and their surroundings and then comput-
scene [2]. These images may have been taken at differ- ing the transformation that would align the surfaces
ent times or in different conditions. Image registration in the best way [5].
finds many uses in medical imaging – for example, to
combine images taken by different instruments such as
3.3.3 Intensity based registration: This method of
PET and CT. The images may have also been taken
registration attempts to fuse images based on the in-
at different points in time, an example of which is
tensity values of pixels alone, without looking at the
to monitor the growth of a tumour. A more tech-
image itself. These algorithms measure the similarity
nical definition of image registration is that it is the
of intensity distributions and compute a transforma-
determination of geometric transformations of images
tion based off this. A major advantage of intensity
that would align the point of view of an object with
based registration is that it requires much less human
corresponding points of view of the same object in a
interaction beforehand than is required for surface and
different image, to provide an enhanced visualisation
point based registration [5].
of the scene [2].
Table 1: Comparison of different image formats

File Size (kB)


Image
JPEG GIF BMP
FlourescentCells 56.1 170 768
Cell Debris 455 1587.2 4700.16

(a) FluorescentCells.jpg (b) CellDebris.JPG

Figure 1: Sample images used

4. DIGITAL IMAGE PROCESSING (a) Binary (b) Greyscale

All image processing was carried out on MATLAB Figure 2: Different representations of CellDebris.jpg
and performed on sample images that were provided
by Professor Aharonson, the course co-ordinator for
ELEN3008 (Biomedical Measurement, Instrumenta- pression but are limited to 8 bit (256) colours. BMP
tion and Imaging) at the University of the Witwa- images are not commonplace - they are actually un-
tersrand, Johannesburg. compressed images (which obviously implies no loss of
information)[7]. A comparison of the file sizes is shown
The images in Figure 1 were used for the image pro- in Table 1. It can be seen that the BMP images have
cessing in Section 4.1 and Section 4.2, the code of the largest file size due to them being uncompressed,
which can be found in Appendix A. whereas the JPEG files are the smallest due to them
using lossy compression.
4.1 Image Formats
There are also other formats such as TIFF and PNG
There are many different digital formats and each one that may be used instead of JPEG, GIF and BMP[7].
was invented for a particular reason – some formats
take up less storage space than others, whereas others 4.2 Image Representation
might be able to display more colours[7]. The follow-
ing image manipulation processes were carried out on Digital images have multiple methods of representa-
Figure 1a and Figure 1b in MATLAB. The images tion. Binary images, also known as black and white
were first opened and displayed as figures. They are images, are represented by an m × n array of 0’s and
JPEG (Joint Photographic Experts Group) images, 1’s (0 and 1 represent black and white, respectively)
which is the most commonly used image format due where m × n is the resolution of the image and each
to its high compression rates and the ability to dis- cell represents one pixel. Binary images are commonly
play many colours (approximately 16 million). When used as masks in photo editing or when analysis is
it comes to compression, there are two modes; lossless done using basic shapes. They are very low on stor-
compression and lossy compression. Lossless compres- age and are ideal for representing simple shapes. Opti-
sion maintains all image information - the original cal recognition and text interpreting applications also
image can be reconstructed exactly. The algorithm utilise binary images[8]. Greyscale images are repre-
looks for efficient ways to represent the image while sented by an ×n array of integers which correspond
maintaining accuracy and quality - one way of achiev- to different intensities of grey (from black to white).
ing this is to search for recurring patterns and replace Greyscale images are used when there is no need for
every occurrence with an abbreviation, which will in colour, such as a newspaper article or a manuscript
turn reduce the size of the file[7]. Lossy compression, (colour is much more expensive)[2]. Medical imaging
on the other hand, will accept compromises in accu- such as MRI or CT scanning often produces greyscale
racy in order to achieve even smaller file sizes. For images since they provide a useful middle ground be-
example, it might look for similar colours in the image tween binary images, which cannot represent complex
and store colour information at a lower resolution than image characteristics, and colour images, which may
the image itself[7]. JPEG images use lossy compres- add an unwanted level of complexity. MATLAB can
sion and are able to be compressed at varying levels be used for interconversion between image types – Bi-
[2]. nary and Greyscale versions of CellDebris.JPG (Fig-
ure 1b) can be seen in Figure 2.
In order to investigate the differences between im-
age file formats, the JPEG images in 1a and 1b Colour images have a number of representations –
were saved as GIF (Graphics Interchange Format) and RGB, Indexed and HSV images[2]. All three of these
BMP (bitmap) images. GIF images use lossless com- can produce images that are identical. An RGB (Red,
Table 2: Staining of endothelial cell in Fluorescent-
Cells.jpg

Stain Structure Fluorophore Used


Red Actin Filaments TRITC
Green Microtubules FITC
Blue Nuclei DAPI

(a) Red (b) Green (c) Blue

Figure 3: RGB components of FluorescentCells.jpg Figure 4: HSV Colour Cone. Image adapted from
‘Introduction to Color Theory’ [10]

Green, Blue) image is an m × n × 3 matrix of colour


pixels, where each colour pixel consists of elements
from a red, a green and a blue colour channel (hence
a “depth” of 3 in the matrix). The red, green and
blue channels can each be thought of as greyscale im-
ages, which will produce the colour image when fed
to the red, green and blue inputs of a screen and
layered[2]. The number of colours depend on the num-
ber of bits used to represent the values in each element (a) Hue (b) Saturation
of the matrix. If it is 8 bits, then the RGB image will
have (28 )3 colours (approximately 16 million). The
RGB components of an image can be separated using
MATLAB – an example of this is shown in Figure 3,
where the components of FluorescentCells.jpg (Figure
1a) are shown. According to the webpage that the
image was found on, the image is showing endothe-
lial cells – it was taken using an imaging technique (c) Value
called fluorescence microscopy where specific biologi-
cal structures are highlighted using special compounds Figure 5: HSV components of CellDebris.JPG
called fluorophores[9]. The structures which are high-
lighted in the image and the fluorophores used to do
so can be seen in Table 2. This image is a Wikimedia
Commons image and is in the public domain, which HSV (Hue, Saturation, Value) images describe colours
means that anyone may use it without crediting the in a way that is akin to how people perceive colour[10].
creator. The hue of the colour refers to which pure colour it
consists of. It is a number between 0 and 1 and repre-
Indexed images consist of two components – an m × n sents how far around the colour wheel in Figure 4 the
data matrix and a colour map. The colour map is a pure colour is. The saturation refers to how ‘pure’ the
c×3 matrix, which each row representing a colour (the colour is, and is a number from 0 to 1 representing how
three columns correspond to the red, green and blue close to the centre of the wheel in Figure 4 the colour
components). As such, the indexed image will have c is – 0 being the pure hue and 1 being pure white. Fi-
colours. The data matrix contains a integer between nally, the value refers to how dark the colour is, and
0 an (c − 1)) which points to a corresponding row represents a number on the long axis of the cone. A
of the colour map matrix (it acts as an index, hence value of 0 is completely black, with the darkness de-
the name)[2]. Indexed images are useful when there creasing as the value decreases. The value property
is a need for a limited amount of colours since the is also called the lightness[10]. HSV images are rep-
colour map can be tailor-made to include a certain resented digitally by a 3D matrix, with each element
range of colours – MATLAB comes with predefined having a hue, a saturation and a value. The separated
colour maps, for example, ‘autumn’, ‘prism’, ‘jet’ and HSV components of CellDebris.JPG (Figure 1b) can
more[2]. be seen in Figure 5
(a) Original Image (b) Image after equalisa-
tion

Figure 6: Sample image pollen.jpg

(c) Original histogram


Figure 7: An image histogram for a 4 bit image
(K=16). The image in question has 10 pixels with
an intensity of 2. Adapted from ‘Principles of Digital
Image Processing’ [11].

4.3 Image Histograms

In order to understand image histograms, the image in


Figure 6 was used to perform image processing related
to histograms. All processing was done in MATLAB,
the code of which can be found in Appendix B.

Image histograms are used to graphically show sta-


tistical data of an image so that inferences about the
image can be made easily. An image histogram de-
scribes the frequency distribution of the intensity val- (d) Histogram after equalisation
ues that occur within an image. At each intensity,
the value is defined as the number of pixels in the im- Figure 8: Histogram equalisation – the sample image
age that have that intensity. The intensity values are pollen.jpg is shown before and after equalisation, with
in the range [0, K − 1]Z, where K is the number of the corresponding histograms
different intensity values (for a typical 8 bit greyscale
image is K = 28 = 256)[11]. The concept of an im-
age histogram can be understood from Figure 7 which which leads to a picture with better contrast and ex-
shows an image histogram for a 4 bit image. Image posure. Thus, histogram equalisation improves the
histograms allow conclusions about qualities such as overall quality of an image. However, since we are
exposure and contrast of the image to be made but dealing with discrete frequencies and intensity values,
since they contain no information about the spatial it is sometimes not possible to obtain a truly uniform
arrangement of pixels, the original image can not be histogram (especially when there are individual peaks
reconstructed from the histogram itself[11]. In fact, in the histogram)[11]. Histogram equalisation can be
multiple images may have the same image histogram. performed on MATLAB and is demonstrated in Fig-
ure 8 – it is clear that the equalised image has much
better contrast and image quality. The algorithm used
Histogram equalisation is a process whereby an im- for the equalisation can be found in Appendix B as
age is modified so that the image histogram has an well. Histogram equalisation on an RGB image would
approximately equal distribution of intensity values, be done by first separating it into the three colour
components, then performing histogram equalisation REFERENCES
on each component and finally combining the compo-
nents into one RGB image again. [1] J. D. Bronzino. The Biomedical Engineering
Handbook: Medical Devices and Systems. USA:
The matrix of CellDebris.jpg can be plotted as a 3D CRC Press, third ed., 2006.
image, where the x and y indexes act as the x and [2] R. Gonzalez, R. E. Woods, and S. L. Eddins. Dig-
y axes and the intensity values act as the function. ital Image Processing Using MATLAB , pp. 27–
Rotating the 3D graph in MATLAB gives a sense of 28,305–308,318–335. USA: Gatesmark Publish-
the top surface of the structure but not the rest of ing, second ed., 2009.
it. If the equalised image is plotted as a 3D graph, [3] J. D. Enderle and J. D. Bronzino. Introduction
it gives a much clearer sense of the structure because to Biomedical Engineering, pp. 997–998,1019–
the intensities are more evenly spread. It has better 1030,1071–1074,1098–1099. USA: Elsevier, third
contrast and the structure itself is moree visible. ed., 2012.
[4] A. Webb. Introduction to Biomedical Imaging,
Thresholding an image is an operation that maps all pp. 1–15,23–25,57–60,73–100. USA: John Wiley
pixels with intensity values below a certain threshold and Sons, first ed., 2003.
value to a fixed intensity value, and all pixels with in- [5] C. Maurer, J. Fitzpatrick, and D. L. G. Hill.
tensity values above or equal to the threshold value Handbook of Medical Imaging, Volume 2. Medi-
to a different fixed intensity value[11]. This is demon- cal Image Processing and Analysis, chap. 8. UK,
strated in Figure 9. A common application of thresh- 2000.
olding is to convert an image to a binary image, which [6] P. J. Kostelec and S. Periaswamy. “Image Reg-
was done in Section 4.1. When binarizing an 8 bit istration for MRI.” Modern Signal Processing,
greyscale image, the threshold value would be 128 and vol. 46.
the two fixed intensity values would be 0 and 255 [11]. [7] R. Matthews. “Digital Image File Types
Explained.” URL http://users.wfu.edu/
matthews/misc/graphics/formats/formats.
html. Department of Physics, Wake Forest
University. [Accessed: 2019-02-04].
[8] R. Owens. “Binary Images.” URL http:
//homepages.inf.ed.ac.uk/rbf/CVonline/
LOCAL_COPIES/OWENS/LECT2/node3.html.
University of Edinburgh. [Accessed: 2019-02-04].
[9] Pinterest. “Discover ideas about Fluorescence
Figure 9: Thresholding of an image. The image his- Microscopy.” URL https://za.pinterest.
tograms are shown with the threshold value and the com/pin/29273466297770010/. [Accessed:
two fixed intensity values. Image adapted from ‘Prin- 2019-02-04].
ciples of Digital Image Processing’ [11]. [10] J. W. Shipman. “Introduction to Color The-
ory.” URL http://infohost.nmt.edu/tcc/
help/pubs/colortheory/web/hsv.html. New
5. CONCLUSION
Mexico Tech. [Accessed: 2019-02-04].
There are many different imaging techniques that are [11] W. Burger and M. J. Burge. Principles of Digital
used today – some of them image the anatomical Image Processing, pp. 37–50,57–59,63–66. UK:
structure and others image the physiological function Springer, first ed., 2009.
of the body. These imaging techniques are used in
many fields of medicine and may even be used in con-
juction in order to achieve better results. Image regis-
tration has multiple uses and is often implemented in
imaging or when linking the results of different imag-
ing techniques.

Digital image processing is very important since the


outputs of imaging systems are increasingly digital.
As such, factors such as the image format and the
image representation used are important to know and
understand. MATLAB can be used to process and
change these factors. It can also edit as other qualities
of the image such as the image histogram, performing
histogram equalisation and other functions.
Appendix

A General Image Processing Code

The following code performs basic image processing such as changing of file formats, interconversion between
different forms of image representation, separation of RGB into colour channels and more.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BASHEQ TARIFI ( 1 6 9 6 8 4 2 ) %
% ELEN3008 Assignment 1 %
% Q u e s t i o n 1 Code %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%read i n images
i m g F l u o C e l l s = imread ( ’ F l u o r e s c e n t C e l l s . j p g ’ ) ;
i m g C e l l D e b r i s = imread ( ’ C e l l D e b r i s . j p g ’ ) ;

%d i s p l a y images
figure ;
imshow ( i m g F l u o C e l l s )
t i t l e ( ’ Fluore scentC ells . jpg ’ ) ;

figure ;
imshow ( i m g C e l l D e b r i s )
t i t l e ( ’ CellDebris . jpg ’ ) ;

%c o n v e r s i o n o f images t o bmp
i m w r i t e ( i m g F l u o C e l l s , ’ F l u o r e s c e n t C e l l s b m p . bmp ’ ) ;
i m w r i t e ( i m g C e l l D e b r i s , ’ C e l l D e b r i s b m p . bmp ’ ) ;
%c o n v e r s i o n o f images t o g i f
[ indFC , map ] = r g b 2 i n d ( i m g F l u o C e l l s , 2 5 6 ) ;
i m w r i t e ( indFC , map , ’ F l u o r e s c e n t C e l l s g i f . g i f ’ ) ;
[ indCD , map ] = r g b 2 i n d ( i m g C e l l D e b r i s , 2 5 6 ) ;
i m w r i t e ( indCD , map , ’ C e l l D e b r i s g i f . g i f ’ ) ;

%d i s p l a y i n g RGB components o f F l u o r e s c e n t C e l l s . j p g
b l a c k = zeros ( s i z e ( i m g F l u o C e l l s , 1 ) , s i z e ( i m g F l u o C e l l s , 2 ) , ’ u i n t 8 ’ ) ;
i m g F l u o C e l l s r e d = c a t ( 3 , i m g F l u o C e l l s ( : , : , 1 ) , black , b l a c k ) ;
i m g F l u o C e l l s g r e e n = c a t ( 3 , black , i m g F l u o C e l l s ( : , : , 2 ) , b l a c k ) ;
i m g F l u o C e l l s b l u e = c a t ( 3 , bla ck , black , i m g F l u o C e l l s ( : , : , 3 ) ) ;
figure ;
subplot ( 2 , 3 , 1 ) , imshow ( i m g F l u o C e l l s ( : , : , 1 ) )
t i t l e ( ’ Red component ’ ) ;
subplot ( 2 , 3 , 2 ) , imshow ( i m g F l u o C e l l s ( : , : , 2 ) )
t i t l e ( ’ Green component ’ ) ;
subplot ( 2 , 3 , 3 ) , imshow ( i m g F l u o C e l l s ( : , : , 3 ) )
t i t l e ( ’ Blue component ’ ) ;
subplot ( 2 , 3 , 4 ) , imshow ( i m g F l u o C e l l s r e d )
t i t l e ( ’ Red , c o l o r i s e d ’ ) ;
subplot ( 2 , 3 , 5 ) , imshow ( i m g F l u o C e l l s g r e e n )
t i t l e ( ’ Green , c o l o r i s e d ’ ) ;
subplot ( 2 , 3 , 6 ) , imshow ( i m g F l u o C e l l s b l u e )
t i t l e ( ’ Blue , c o l o r i s e d ’ ) ;

%d i s p l a y i n g HSV components o f C e l l D e b r i s . j p g

h s v C e l l D e b r i s = rgb2hsv ( i m g C e l l D e b r i s ) ;
b l a c k h s v = zeros ( s i z e ( h s v C e l l D e b r i s , 1 ) , s i z e ( h s v C e l l D e b r i s , 2 ) , ’ d o u b l e ’ ) ;
figure ;
subplot ( 1 , 3 , 1 ) , imshow ( c a t ( 3 , h s v C e l l D e b r i s ( : , : , 1 ) , b l a c k h s v , b l a c k h s v ) )
t i t l e ( ’ Hue ’ ) ;
subplot ( 1 , 3 , 2 ) , imshow ( c a t ( 3 , b l a c k h s v , h s v C e l l D e b r i s ( : , : , 2 ) , b l a c k h s v ) )
title ( ’ Saturation ’ ) ;
subplot ( 1 , 3 , 3 ) , imshow ( c a t ( 3 , b l a c k h s v , b l a c k h s v , h s v C e l l D e b r i s ( : , : , 3 ) ) )
t i t l e ( ’ I n t e n s i t y Value ’ ) ;

%c o n v e r t t o b i n a r y g r a y s c a l e and d i s p l a y
grayCellDebris = rgb2gray ( imgCellDebris ) ;
figure ;
imshow ( g r a y C e l l D e b r i s )
t i t l e ( ’ Cell Debris − Grayscale ’ ) ;

%c o n v e r t t o b i n a r y and d i s p l a y
bwCellDebris = imbinarize ( grayCellDebris ) ;
figure ;
imshow ( b w C e l l D e b r i s )
t i t l e ( ’ C e l l D e b r i s − Binary ( Black and White ) ’ ) ;

%c o n v e r t t o i n d e x e d and d i s p l a y
[ i n d C e l l D e b r i s , cdmap ] = r g b 2 i n d ( i m g C e l l D e b r i s , 2 5 6 ) ;
figure ;
imshow ( i n d C e l l D e b r i s , cdmap ) ;
t i t l e ( ’ C e l l D e b r i s Indexed ’ ) ;
B Image Histogram Processing Code

This piece of code diaplays image histograms and performs histogram equalisation without the built in function.
It also displays 3D graphs of the images.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BASHEQ TARIFI ( 1 6 9 6 8 4 2 ) %
% ELEN3008 Assignment 1 %
% Q u e s t i o n 2 Code %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%read image
i m g P o l l e n = imread ( ’ P o l l e n . j p g ’ ) ;
figure ;

%d i s p l a y h i s t o g r a m o f o r i g i n a l image
imhist ( imgPollen ) ;
xlabel ( ’ Gray L e v e l ’ ) ;
ylabel ( ’ Number o f p i x e l s ’ ) ;
ylim ( [ 0 , 9 ∗ 1 0 ˆ 4 ] ) ;
t i t l e ( ’ Image Histogram o f P o l l e n . j p g ’ ) ;

%HISTOGRAM EQUALISATION [ 1 ]
%g e t w i d t h and h e i g h t
width = s i z e ( imgPollen , 2 ) ;
h e i g h t = s i z e ( imgPollen , 1 ) ;
r e s = width ∗ h e i g h t ; %t o t a l number o f p i x e l s
hist = imhist ( imgPollen ) ;
prob = h i s t / r e s ; %p r o b a b i l i t y d i s t r

c p r o b = prob ;
for x = 2 : s i z e ( c prob , 1 )
c p r o b ( x ) = c p r o b ( x−1) + c p r o b ( x ) ;
end %c a l c u l a t e c u m u l a t i v e p r o b a b i l i t y d i s t r

c p r o b = round ( 2 5 5 ∗ ( c p r o b ) ) ; %c o n v e r t t o 8 b i t

e q i m g P o l l e n = u i n t 8 ( zeros ( h e i g h t , width ) ) ; %e q u a l i s e d image

for m=1: h e i g h t
f o r n=1: width
temp = i m g P o l l e n (m, n ) ;
e q i m g P o l l e n (m, n)= c p r o b ( temp +1); %mapping
end
end

f i g u r e ; %d i s p l a y e q u a l i s e d image
imshow ( e q i m g P o l l e n ) ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f i g u r e ; %e q u a l i s e d h i s t o g r a m
imhist ( eq imgPollen ) ;
xlabel ( ’ Gray L e v e l ’ ) ;
ylabel ( ’ Number o f p i x e l s ’ ) ;
ylim ( [ 0 , 9 ∗ 1 0 ˆ 4 ] ) ;
t i t l e ( ’ E q u a l i z e d Image Histogram o f P o l l e n . j p g ’ ) ;

map img = i m g P o l l e n ;
map eq img = e q i m g P o l l e n ;
figure ;
mesh( map img ) ;
figure ;
mesh( map eq img ) ;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% REFERENCES %
% [ 1 ] W. Burger and M. J . Burge . P r i n c i p l e s o f D i g i t a l %
% Image P r o c e s s i n g . UK: S p r i n g e r , f i r s t ed . , 2 0 0 9 . %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

You might also like