Introduction Medical Image Processing Summary H4-8
209 views 4 purchases
Course
Introductie Medische Beeldbewerking (X_432630)
Institution
Vrije Universiteit Amsterdam (VU)
Book
An Introduction to Digital Image Processing with MATLAB
This is a summary for the course "Introduction Medical Imaging" in the minor "Biomedical Imaging" at the VU. A summary of chapters 4 to 8 of the book Introduction to Digital Image Processing with MATLAB® (by McAndrew, A.). The relevant lectures of the course are also included in the text.
4.1 Introduction
Any image-processing operation transforms the gray values of the pixels. Image-processing
operations can be divided into three classes based on the information required to perform the
transformation. From the most complex to the simplest, they are as follows:
1. Transforms. A transform represents the
pixel values in some other equivalent form.
Transforms allow for some very efficient
and powerful algorithms.
2. Neighborhood processing. To change the
gray level of a given pixel we only need to
know the value of the gray levels in a small
neighborhood of pixels around the given
pixel.
3. Point operations. A pixel’s gray value is
changed without any knowledge of its
surroundings.
Although point operations are the simplest, they contain some of the most powerful and
widely used image processing operations. They are especially useful in image pre-processing,
where an image is required to be modified before the main job is attempted.
4.2 Arithmetic Operations
Arithmetic operations act by applying a simple function 𝑦 = 𝑓(𝑥) to each gray value in the
image. Thus 𝑓(𝑥) is a function which maps the range 0 … 255 onto itself. Simple functions
include adding or subtracting a constant value to each pixel or multiplying each pixel by a
constant.
In each case we may have to fiddle the output slightly in order to ensure that the results are
integers in the 0 … 255 range. We can do this by first rounding the result to obtain an integer,
and then clipping the values by setting:
255 𝑖𝑓 𝑦 > 255,
𝑦←{
0 𝑖𝑓 𝑦 < 0.
Figure 2.2 shows the result of adding or
substracting 128 from each pixel in the
image. When we add 128, all gray values
of 127 or greater will be mapped to 255.
When we substract 128, all gray values of
127 or less will be mapped to 0. Adding a
constant will lighten an image and
substracting a constant will darken it.
Arithmetic operations can’t be performed
on unit8 data type, because this type is only used for data storage. So, first we need to turn the
matrix of type unit8 into a matrix of type double. We can transform the matrix in and out of
double or use the imadd or imsubtract function to add or subtract a value.
,b1 = uint8(double(b)+128);
b1 = imadd(b,128);
We can also perform lightening or darkening of an image by multiplication. To implement
these functions we use the immultiply or imdivide function.
If we compare darkening by subtraction and multiplication we see a lot of information has
been lost by the subtraction process. This is because with subtraction all pixels with gray
values 128 or less have become zero. A similar loss of information also occurs with addition.
Complement
The complement of a grayscale image is its photographic negative.
If an image matrix m is of type double and thus its gray values are in the range 0.0 to 1.0, we
can obtain its negative with the command: 1-m.
If the image is binary, we can use: ~m.
If the image is of type uint8, the best approach is the imcomplement function:
bc = imcomplement(b);.
Special effects can be obtained by complementing only part of the image. For example, by
taking the complement of pixels of gray value 128 or less and leaving the other pixels
untouched. The effect of these functions is called solarization.
4.3 Histograms
Given a grayscale image, its histogram consists of its gray levels; that is, it is a graph
indicating the number of times each gray level occurs in the image.
• In a dark image, the gray levels are clustered at the lower end.
• In a uniformly bright image, the gray levels are clustered at the upper end.
• In a well-contrasted image, the gray levels are well spread out over much of the range.
We can view the histogram of an image in MATLAB by using the imhist function,
p = imread(‘pout.tif’);
imshow(p), figure, imhist(p), axis tight
where the axis tight command ensures the axes are scaled so that all the histogram bars fit
entirely within the figure.
Given a poorly contrasted image, we would like to enhance its contrast by spreading out its
histogram. There are two ways of doing this: histogram stretching or histogram equalization.
4.3.1 Histogram Stretching (Contrast Stretching)
We can stretch out gray levels in the center of the range by applying a piecewise linear
function. An example is given in Figure 2.9 which has the effect of stretching the gray levels
5-9 to gray levels 2-14, according to equation,
14 − 2
𝑗= (𝑖 − 5) + 2
9−5
where i is the original gray level and j is its result after the transformation. Or basically:
𝑏𝑖+1 − 𝑏𝑖
𝑦= (𝑥 − 𝑎𝑖 ) + 𝑏𝑖
𝑎𝑖+1 − 𝑎𝑖
where a indicates the range of gray levels that need to be stretched to a range of gray levels b.
, Gray levels outside this range are either left alone (as in this case) or transformed according to
the linear functions at the ends. This yields an image with greater contrast than the original.
Use of imadjust
To perform histogram stretching in MATLAB, the imadjust
function may be used. In its simplest incarnation, the
command imadjust(im,[a,b],[c,d])stretches the image
according to the function shown in Figure 2.10. Because
imadjust is designed to work equally well on images of type
double, uint8, or uint16, the values a, b, c and d must be
between 0 and 1. The function automatically converts the
image (if needed) to be of type double.
Note that imadjust does not work quite in the same way as shown in Figure 2.10. Pixel values
less than a are all converted to c, and pixel values greater than b are all converted to d. If
either [a,b]or[c,d] are chosen to be [0,1], the abbreviation[]may be used. Thus, for
example, the command imadjust(im,[],[])does nothing, and the command
imadjust(im,[],[1,0])inverts the gray values of the image to produce a result similar to
a photographic negative.
The imadjust function has one other optional parameter: the gamma value, which describes
the shape of the function between coordinates (𝑎, 𝑐) and (𝑏, 𝑑). Use of the gamma value alone
can be enough to substantially change the appearance of the image. If gamma is equal to 1,
which is the default, then a linear mapping is used. However, values less than 1 produce a
function that is concave downward, and values greater than 1 produce a figure that is concave
upward. The imadjust stretching function can be viewed with the plot function.
A piecewise linear-stretching function
We can easily write our own function to perform piecewise linear stretching. To do this, we
make use of the find function to find the pixel values in the image between ai and ai+1.
Because the line between the coordinates (𝑎𝑖 , 𝑏𝑖 ) and (𝑎𝑖+1 , 𝑏𝑖+1 ) has the equation,
𝑏 −𝑏
𝑦 = 𝑎𝑖+1 −𝑎𝑖 (𝑥 − 𝑎𝑖 ) + 𝑏𝑖 ,
𝑖+1 𝑖
the heart of our function will be the lines:
pix = find(im >= a(i) & im < a(i+1));
out(pix) = (im(pix)-a(i))*(b(i+1)-b(i))/(a(i+1)-a(i)+b(i);
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller sle8. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.74. You're not tied to anything after your purchase.