Bangladesh University of Engineering and Technology
Bangladesh University of Engineering and Technology
Project summary:
In this project, we had aimed to take the image of a curve and find its
equation, differential graph and also integrate it. For this, we had used
image processing techniques and known numerical methods of data
collection and data analysis.
The result of the data analysis and the graphs are shown in a Graphic
User Interface(GUI).
2) Order of the function to be found is also taken was input. We also take
a threshold value as an input which is the threshold value at which a
grayscale image is converted into a binary image
Processing:
1) The image taken as input is converted into a grayscale image within
the code . Then, using the threshold value that we had set, the grayscale
image is converted into a binary image. The binary image is then
complimented and the holes present in the image are filled through
morphological operations. Then, to ‘clean up’ the remaining noise in the
image, further morphological operations are done through matlab
functions.
3) The extracted points include the X positions and the Y positions of the
curve. However, since the image of the curve has a width, hence for a
particular x value, we get multiple y values. Hence, through numerical
analysis, we take unique x values and y values from the curve to get a one
to one relationship between x and y. The unique y value for a particular x
value is calculated by averaging the mid position of the topmost and
bottom most y value for the particular x value.
4) Thus, the extracted data points are then rescaled using the “scale”
value that we had inputted. The scale value has a maximum value of 100.
The curve is always plotted within the limits of the scale value.
5) The rescaled x and y values are then passed to a curve fitter function
that we had made to find a coefficient one dimensional matrix which
represents the coefficients of the various powers of ‘x’ of the polynomial
function that we desire to find.
7) The graphs equation for the image is found using the coefficient matrix.
8) Using the origin inputted, we find another coefficient matrix and thus
plot a shifted curve of the image. The equation of the shifted curve is also
shown.
Output:
The results of all the analysis and processing are shown in the graphical
user interface.
Flow-chart:
Insert Image: This button takes an input image (jpg) from the storage of
the user.
Input Panel:
Threshold: This slider takes an input between 0.25 and 0.5 which is set as
the threshold value to convert the image to a binary image. The higher the
threshold value, the less dark portion is also being black in the binary
image. The recommended threshold value is 0.43 in this case. The edit
box beside the slider shows the value of the slider. The user may also use
the edit box for input.
Order:This slider sets the order for the equation the user wants. Input
value may vary from 1 to 50. As usual, the user may enter his input
through the edit box beside it.
Scale: This slider sets the scale factor for the image. The user may scale
his input image from 10 to 100 in this case. But the scaling would be the
same for the x axis and y axis. The edit box may take input.
Output Panel:
Main Graph:The user would be able to see the curve of the raw image and
the fitted curve in the second axes window simultaneously by clicking
this button. Legend is added for better understanding.
Differential Graph: Clicking this button would show the differential curve
for the fitted curve.
Equation: This button would take the user to a second window where he
would be able to see the equation of the curve that has been obtained
through curve fitting. Clicking the “Home” button in that window or just
clicking “x” on the top right corner would bring him to the main window.
Coefficient Matrix: This would show the coefficient matrix of the fitted
curve in the second window. The user may scroll down for a larger matrix.
Integration Panel:
Lower: This edit box would take the lower limit for the required
integration from the user.
Upper: This would take the upper limit.
Integrate: After entering the lower and upper limit, the user would click
this button which would show the integration result in the region below
the button.
Restart: In case of any wrong input, the user may restart the application
using this button.
Exit: This button would close the application.
Two Axes Figure: Two axes figures have been used in our graphical user
interface. The first one only shows the input image. The second one
shows all other output graphs or images.
Description:
We created the Graphical User Interface using matlab guide. At first we
added pushbuttons, axes, sliders, edit boxes, static texts and renamed their
tags and strings according to our need. Then we put the required code in
the callback functions of the pushbuttons ,sliders and edit boxes. For
scrolling text we used uicontrol in the main code and showed the
scrolling text in another sub GUI. We kept the restart and exit button to
make it more user friendly.
Test Cases:
Case(a):
Graph:
Differential Graph:
Equation:
Coefficient matrix:
Integration:
Differential Graph:
Equation:
Coefficient matrix:
Integration:
Shifted graph w.r.t origin:
Equation:
Coefficient matrix:
Case(c):
Graph:
Differential Graph:
Equation:
Coefficient matrix:
Integration:
Equation:
Coefficient matrix:
Graph:
Differential Graph:
Equation:
Coefficient matrix:
Integration:
Shifted graph w.r.t origin:
Equation:
Coefficient matrix:
Discussion:
In our project, we had used curve fitting techniques for numerical
analysis. We had avoided using the Newton’s interpolation method or
Lagrange method as they are not very accurate over large data samples.
Again, with large data samples, Newton’s interpolation method or
Lagrange method may give polynomials that are not practical for use.
The whole project was done on Matlab and was implemented on GUI.
The aim of the project was originally to find the equation of the curve
from an image containing a curve. As a result, a user can find the
equation of the curve easily. The project is limited to one one functions.
Functions like the circle, ellipse, etc are not one one and their polynomial
representation is not simple due to the presence of square roots in their
original equations and hence are outside the scope of this project.
Conclusion:
We, thus had completed our project successfully using Matlab, Graphical
User Interface and the Image Processing Toolbox. The fitted curves we
had obtained was very close to the original curves and hence the equation
of the fitted curves were quite practical for use.