You are on page 1of 4

Ton Duc Thang University

Faculty of Information Technology

Numerical Analysis
Module code: 502041
Anh H. Vo

1 Introduction
This assignment will apply the basic concepts of Numerical Analysis to build a
real application for the image segmentation problem.

Figure 1: The illustration of the image segmentation by using the interpolation


polynomial function

The figure on the left hand side with the blue curve shows the polynomial
function f (x) of the input image, which it is computed by the frequency of
each unique intensity, and the the red curve describes the approximation of the
polynomial function g(x), which it is interpolated by the intensity x and the
frequency of x, denoted as y. Based on g(x), we are able to find the appropriate
thresholding value θ to get the image result on the right hand side.

2 Instruction
Suppose that given an arbitrary image I as a matrix which represents the in-
tensity at each pixel. As in Table 1. To illustrate matrix I as the polynomial
function f (x). We must compute the frequency of each unique intensity in
matrix I. In Table 2, y = n(x) which means the number of observation of x
intensity in matrix I In the next step, the values of x and y will be utilized to
find the approximation of polynomial function g(x) = a0 + a1 x + ... + an xn by

1
Ton Duc Thang University
Faculty of Information Technology

0 1 5 3 1 10 10 7 5 7
0 1 8 3 1 2 10 7 5 10
1 1 8 3 9 2 9 7 8 6

Table 1: Example of matrix I obtains by an input image

x 0 1 2 3 4 5 6 7 8 9 10
y 2 6 2 3 0 3 1 4 3 2 4

Table 2: The values of x and y which present the intensity value and the fre-
quency of each intensity in matrix I

using the interpolation methods. Besides, we also need the thresholding value θ
for segmenting regions of the input image. To do this, we must find the index-
ing j that at this point the value of the second derivative of the interpolation
ŷ vector is minimized. ŷ vector is computed from g(x) based on the following
equation:

ŷi = g(xi ) (1)


j = argmin{(| ŷi0 0
|) } (2)
i
j
θ= , where L means the maximum of intensity (3)
L−1
Finally, the segmentation of input image will be able to obtain by equation
below:

1 if x > θ
b(x) = (4)
0 otherwise
Remarks

0
0 2 4 6 8 10

Figure 2: The illustrate of the polynomial function f (x) of the input image

2
Ton Duc Thang University
Faculty of Information Technology

• To read an input image in python by OpenCV library:


>> I = cv2 . imread ( ’ l e n a . jpg ’ ) ;

Or Matlab
>> I = imread ( ’ l e n a . jpg ’ ) ;

Recall that the input image must be the grayscale image, if the input
image is the RGB image, you need to convert to the grayscale image in
Python as follows.
>> I = cv2 . c v t C o l o r ( I , cv2 .COLOR BRG2GRAY) ;

or Matlab
>> I = r g b 2 g r a y ( I ) ;

• In equation (2), the abs and sort functions could use to compute the
absolute value and sort of the values.

3 Requirements
Requirement 1: Write a simple program to find the approximation of the
polynomial function of the input image and then segment the image re-
gions based on the interpolation methods (Direct interpolation, Lagranian
interpolation, Newton’s divied difference interpolation).
1. Find x and y variables from the input image (1 point)
2. Write functions to find g(x) which approximates the polynomial func-
tion f (x) in terms of Direct interpolation, Lagranian interpolation,
Newton’s divied difference interpolation. (3 point)
3. Comparison of the relative errors when the approximation of the
polynomial function g(x) in various interpolation methods with n
degree is 3, 4, 5, 6, respectively. (2 point)
4. Find the index which shows the minimum value of the second deriva-
tive of ŷ. (1 point)
5. Select g(x) toward the best relative error from the previous require-
ment to show the segmentation of input image. (1 point)

Requirement 2: Write a brief report to illustrate the process following the


above requirements (2 point)

3
Ton Duc Thang University
Faculty of Information Technology

4 Submission
• Your report must be written carefully.
• You can be asked to explain about your report if necessary.
• If you cheat on this essay, you will receive zero point.

• The report StudentID.zip includes StudentID.pdf and S StudentID.py/.m


which will be compressed and submitted on course’s classroom.
• Deadline: 28/11/2021

You might also like