Vous êtes sur la page 1sur 3

Regler för laborationerna

• Rapporten för denna laboration får lämnas in senast torsdagen den 21a december 2006.
• Inlämningen av labbrapporterna sker genom att omvandla filerna till pdf-format och skicka
dem med e-post till: hamed.muhammed@gmail.com
• Labbhandledning ges under det schemalagda labbtillfället samt via e-post därefter.

Lab Exercise 4
1. Global & local thresholding
• Load the image img1.jpg into the MATLAB workspace.
• Segment the image using global thresholding. (2p)
• Segment the image using at least one local thresholding method. (2p)
• Present the results and describe the used methods. (2p)
• Show also how the MATLAB code looks like in each case. (2p)

2. Segmentation and seeded-region growing


You are provided with a CT scan of a pediatric bone tumor (CT_bone_tumor.jpg). The
hypo-intense area is the region of cancerous involvement located inside the annular region
(bone). Compute the area of the tumor using the following segmentation techniques: (a)
Manual Outlining, and (b) Seeded Region Growing.
• Manual Outlining: Use region of interest (ROI) functions in MATLAB (roipoly) to
achieve this. Your algorithm could be designed with the following general steps in mind:
a) Accept as input the outline (entered manually) (1p)
b) Generate a binary mask which delineates the tumor (1’s inside, 0’s outside) (1p)
c) Compute its area and basic statistics such as mean intensity and standard deviation (1p)
• Seeded Region Growing: Instead of outlining the tumor, use a MATLAB function to plant
a “seed” within the image. The algorithm would consist of the following steps:
a) Accept as input the coordinates for a “seed”- this is automatically included in the
region (1p)
b) Examine a 3x3 neighborhood of the seed for intensity values (2p)
c) If the intensity of the neighboring pixels is within 2*σ (σ=standard deviation), include
it in the growing region, if not exclude. (2p)
d) (Iterative step) Repeat steps b and c for every pixel in the current neighborhood until
no further pixels can be added to the region (3p)
e) Display the CT image with the tumor outline (overlay on image) (2p)
• Compare the following for the bone tumor as computed by the two methods:
1. Area (2p)
2. Standard deviation of intensity of the pixels (2p)
• Also compute the variability in your calculations by repeating the process multiple times
(at least three times) – what is a reasonable tolerance range for the area of the tumor as
calculated by manual outlining and seeded region growing techniques. How are the two
segmentation techniques different? (2p)

3. Segmentation and classification


• Load the following images (one at each time) into the MATLAB workspace: GreenFrog-
small.JPG , wolf-sheep-small.JPG , BigTumor-small.jpg
• Process these images using a number of texture, linear and/or non-linear filtering methods,
to be able to use the results as inputs to subsequent segmentation tasks. Use color (if
applicable and useful) and texture to differentiate between the different objects or classes

1
of objects in these images. (1p)
• Use the supervised approach to segment and classify the objects in each of the images by
combining each image with the corresponding filtering results which have the same sizes
as the corresponding original images. These filtering results are added as additional bands
to the corresponding original images before performing the supervised segmentation and
classification tasks. (6p)
• Estimate the area of each object in these images; e.g. the number of pixels belonging to the
region representing the object in the image. (6p)
• Present the results and describe the used methods. (3p)
• Show also how the used MATLAB code looks like for each case. (3p)

4. Segmentation and classification


The aim of this exercise is to let you experiment with a number of functions from the Image
Processing Toolbox in MATLAB. Your task is to create a short script that will count and
measure the size of a number of objects in an image. To complete the task, a number of
functions have to be combined. There are several ways to solve the problem and there is no
“perfect solution”.
Counting objects is a fairly common problem in image analysis. Often the segmentation is
difficult, due to non-uniform illumination, shadows, blur, reflections etc. The problems here
are that some objects are slightly overlapping or partially hidden (but still possible to
identify). Some of the objects also contain bright pixels that should be counted as part of the
object. Those difficulties must be taken into consideration when solving the assignment.
• Load the image coins.jpg into the MATLAB workspace.
• Suggest (and use) a sequence of functions that solves the task of segmenting all of the
coins in the image. Include an explanation for every function saying why that particular
function was needed. (6p)
• Show the final segmentation result. (1p)
• Show a histogram showing the distribution of object sizes. Either area or radius could be
used as a size measure. (3p)
• Discuss the errors and limitations in your final method. (2p)
• As you can see, the objects are coins. Therefore, count the total amount of money using
your algorithm. (2p)
Some useful MATLAB functions
To get familiar with the tools you need to complete the task, you can try the functions listed
below. Use the MATLAB Help window to find the details of the functions and their use. All
listed functions are not needed to solve the task, but you should be able to solve the task
with these functions only. You are however very welcome to use any other functions you
may want to try.
It could be a good idea to start working with a small sub-image of coins.tif, for example
Ismall=I(1:50,301:350); This will make it easier to look at the actual intensity values to
figure out what the functions do. The intensity values are shown if you just write the image
name, leaving out the ;
• im2bw(I,T); Threshold the image at level T, creating a binary image.
• graythresh(I); Find a suitable intensity threshold based on the image histogram.
• imopen(I,se), imclose(I,se), imdilate(I,se), imerode(i,se); Open, close,
dilate or erode the image I using a structuring element se.

2
• Idist=bwdist(I,’type’); Distance transform a binary image using different types of
metrics. Here, in each object-pixel, we get the distance to the closest background-pixel. To
view the result, use imshow(mat2gray(Idist));
• watershed(I); Watershed segmentation. Can be applied to the distance transform.
Think of the grey-level image as a landscape. Let water rise from the bottom of each valley
(the water from each valley is given its own label). As soon as the water from two valleys
meet, build a dam, or watershed. These watersheds will then define the borders between
different regions. Example of watershed on a binary image with “round” objects: (a)
original image, (b) distance transformed image, (c) distance coded as intensity, (d) Result of
watershed segmentation.

• and(A,B), or(A,B), xor(A,B), not(A); Logical operations between binary images.


• Ilabel=bwlabel(I,nb); Labeling of a binary image. nb is the neighborhood, and can be
4 or 8 in 2D. The result can be viewed as a color image writing
imshow(label2rgb(Ilabel,’spring’));

• F=regionprops(Ilabel, ’feature’); Extract different features from an image with


labeled objects. See the MATLAB Help for description of features. If the feature is ’Area’,
an array of area values is created by writing A=[F.Area], and a histogram is created by
writing hist(A).
If the distance transform is used for segmentation, its maxima can be extracted as a measure
of maximum radius. This measure will give a correct measure of radius also for partly
overlapping objects and objects cut by the image borders.
• imextendedmax(I,h); Finds local maxima of height h as compared to the local
surroundings. If h=1, the local maxima will be found. The Extended-maxima transform can,
for example, be applied to the distance image.
• If=conv2(I,f); Filters a 2D image with a filter f. To smooth the image, a 3x3 mean filter
can be created writing. f=[1 1 1;1 1 1;1 1 1]./9; The resulting image will be larger
than the original (one pixel in all directions if a 3x3 filter is used), and these edges must be
cut away before for example logical operations between the result and the original image can
be performed. Resize the image by cutting away the edges by writing I=I(2:end-1,
2:end-1); (in the case of using a 3x3 filter).

• medfilt2(I); Median filtering using a 3x3 neighborhood filter.


• bwmorph(I,’operation’); Implementation of a number of different morphological
operations, such as skeletonization, top-hat transformation etc.

Vous aimerez peut-être aussi