-
Notifications
You must be signed in to change notification settings - Fork 1
/
project_main.m
45 lines (38 loc) · 1.19 KB
/
project_main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function coord = project_main(imgFile)
I = imread(imgFile);
figure, imshow(I), title('original image');
image = rgb2gray(I);
%% Preprocess
imgFile = preprocess(imgFile);
I = imread(imgFile);
figure, imshow(I), title('original image preprocessed');
image = rgb2gray(I);
%% User Input
% ask user for axis type
ylinear = input('Enter 1 for linear y axis, 0 for log axis: ');
%% Detect Axes
[origin,xaxis,yaxis] = detect_axis(image);
%% Detecting Labels
if exist ('ocr')
[xvalues, yvalues] = detect_labels(image, xaxis, yaxis, ylinear);
else
x1 = input('Enter minimum x value: ');
x2 = input('Enter maximum x value: ');
xvalues = [x1 x2];
y1 = input('Enter minimum y value: ');
y2 = input('Enter maximum y value: ');
yvalues = [y1 y2];
end
%% Data Extraction
line = classifyGraph(origin,xaxis,yaxis,imgFile);
if line
coord = getLineCoord(origin,xaxis,yaxis,xvalues,yvalues,imgFile,ylinear);
else
coord = getMultCoord(origin,xaxis,yaxis,xvalues,yvalues,imgFile,ylinear);
end
if ylinear
figure; plot(coord(:,1),coord(:,2),'o');
else
figure; semilogy(coord(:,1),coord(:,2),'o');
end
axis([xvalues(1) xvalues(2) yvalues(1) yvalues(2)]); title('Extracted data');