-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXray.cpp
51 lines (42 loc) · 1.33 KB
/
Xray.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
42
43
44
45
46
47
48
49
50
51
#include "Xray.hpp"
/*void Xray::performEffect(cv::Mat &input)
{
cv::Vec4b min(255,255,255, 0);
cv::Vec4b max( 0, 0, 0, 255);
//this->effect = cv::Mat::zeros(input.cols,input.rows, CV_8UC4);
if(this->effect.empty()) this->effect = input.clone();
//std::vector <cv::Mat> planes;
//cv::split(input, planes); // Partition image into three channel planes
//for(int i = 0; i < 3; i++)
//{
// double minVal, maxVal;
// cv::minMaxLoc(planes[0], &minVal, &maxVal, NULL, NULL);
// min[i] = (char)(int)minVal;
// max[i] = (char)(int)maxVal;
//}
for (int row = 0; row < input.rows; row++)
{
for (int col = 0; col < input.cols; col++)
{
const cv::Vec4b& src = input.at<cv::Vec4b>(row, col);
min[0] = std::min(min[0], src[0]);
min[1] = std::min(min[1], src[1]);
min[2] = std::min(min[2], src[2]);
//min[3] = std::min(min[3], src[3]);
max[0] = std::max(max[0], src[0]);
max[1] = std::max(max[1], src[1]);
max[2] = std::max(max[2], src[2]);
//max[3] = std::max(max[3], src[3]);
}
}
for (int row = 0; row < input.rows; row++)
{
for (int col = 0; col < input.cols; col++)
{
cv::Vec4b result = (max - input.at<cv::Vec4b>(row, col)) + min;
//result[3] = 0xFF;
this->effect.at<cv::Vec4b>(row, col) = result;
}
}
//cv::imshow("xray", effect);
}*/