-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.cpp
42 lines (32 loc) · 1.13 KB
/
utils.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
35
36
37
38
39
40
41
#include "utils.h"
void imagesc(std::string name_s, cv::Mat* map)
{
char* name = const_cast<char*>(name_s.c_str());
double min;
double max;
cv::minMaxIdx(*map, &min, &max);
cv::Mat adjMap;
// Histogram Equalization
float scale = 255 / (max-min);
map->convertTo(adjMap,CV_8UC1, scale, -min*scale);
cv::Mat resultMap;
applyColorMap(adjMap, resultMap, cv::COLORMAP_PARULA);
cv::namedWindow(name, cv::WINDOW_NORMAL);
cv::imshow(name, resultMap);
cv::waitKey(1);
}
template <typename T>
void imagesc(std::string name_s, T* tab, int width, int height) {
cv::Mat map = cv::Mat(height, width, CV_64F);
for(int i=0; i<height; i++) {
for(int j=0; j<width; j++)
map.at<double>(i, j) = (double)tab[i*width + j];
}
imagesc(name_s, &map);
}
template
void imagesc(std::string name_s, double* tab, int width, int height);
template
void imagesc(std::string name_s, int* tab, int width, int height);
template
void imagesc(std::string name_s, unsigned char* tab, int width, int height);