-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.cpp
34 lines (27 loc) · 842 Bytes
/
main.cpp
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
#include <opencv2/imgcodecs.hpp>
#include <opencv2/gapi/imgproc.hpp>
#include <iostream>
#include <fstream>
#include <filesystem>
#include "dynamic_otsu.h"
int main(void) {
std::string path = "sample//";
cv::Mat input_img;
int M = 32;
int L = 256;
int N = L / M;
for (const auto& entry : std::filesystem::directory_iterator(path))
{
input_img = cv::imread(entry.path().string(), cv::IMREAD_GRAYSCALE);
vector<int> histogram = get_histogram(input_img);
vector<double> norm_hist = normalize_histogram(histogram, M, L);
vector<int> valleys = find_valleys(norm_hist);
vector<int> thresholds = threshold_valley_regions(histogram, valleys, N);
cout << entry.path() << endl;
for (int i = 0; i < thresholds.size(); i++) {
cout << "Threshold[" << i << "] - " << thresholds[i] << endl;
}
cout << endl;
}
return 0;
}