This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.m
90 lines (73 loc) · 2.81 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
clc
clear all
%filename = '015001_GH020034.MP4.jpg';
dinfo = dir('assets/Testing/*.jpg');
names_cell = {dinfo.name};
image = convertCharsToStrings({dinfo.name});
colorResults = zeros(146,1); % array with all results
greyScaleResults = zeros(146,1);
allResults = []; % array with all results
filenames = string(char); %array with filenames of "blank" pictures
%size(names_cell,2)
allFilenames = strings(1);
for i=1:size(names_cell,2)
% get an image from the test set
filename = names_cell{i};
filePath = "assets/Testing/" + filename;
fishimage = imread(filePath);
isGreen = false;
if(getAvarangeRed(fishimage) < 90)
isGreen = true;
end
algoResult = jAlgoritmeColor(fishimage, isGreen); % algoritme to create binary image
if(checkIfBlankImage(algoResult))
result = 0;
else
possibleFishes = getObjects(algoResult); % get all objects in binary image
algBoundingBox = getMostCorrectFish(possibleFishes); % finds the most correct fish and returns the bounding box
answerBoundingBox = getAnswerCords(filename); % get the answer cords
result = compareBoxes(algBoundingBox, answerBoundingBox, fishimage); % compare the result
end
colorResults(i,:) = result; %save the result
algoResult = aAlgorithmGray2(fishimage, isGreen); % algoritme to create binary image
if(checkIfBlankImage(algoResult))
result = 0;
else
possibleFishes = getObjects(algoResult); % get all objects in binary image
algBoundingBox = getMostCorrectFish(possibleFishes); % finds the most correct fish and returns the bounding box
answerBoundingBox = getAnswerCords(filename); % get the answer cords
result = compareBoxes(algBoundingBox, answerBoundingBox, fishimage); % compare the result
end
if(result <0.3)
%imshow(filePath)
filenames(end+1)= names_cell{i};
%{
reply = questdlg('Continue?','Continue', 'OK','Cancel', 'OK');
if strcmpi(reply, 'Cancel')
% Stop if canceled.
return;
end
%}
end
greyScaleResults(i,:) = result; %save the result
%allResults(end+1) = result; %save the result
%showBoundingBox(fishimage, algoResult, algBoundingBox)
end
% xlswrite('result.xlsx',allResults);
% prints the results
% allResults
imageName = transpose(image);
T = table(imageName ,colorResults, greyScaleResults);
excelName = "results.xlsx";
writetable(T,excelName,'Sheet',1,'Range','A:C');
colorResults;
[~,s]=size(filenames);
for i=2:s
filePath = "assets/Testing/" + filenames(i);
fishimage = imread(filePath);
figure, imshow(fishimage) %opens all "bad" images
reply = questdlg('Continue?','Continue', 'OK','Cancel', 'OK');
if strcmpi(reply, 'Cancel')
return;% Stop if canceled.
end
end