@@ -33,14 +33,13 @@ void logTransform(const Mat input, Mat& output)
33
33
34
34
void gammaCorrection (const Mat input, Mat& output, const float gamma)
35
35
{
36
- vector< int > table ( 256 ) ;
36
+ array<uchar, 256 > table;
37
37
for (int i = 0 ; i < 256 ; i++)
38
38
{
39
- table[i] = ( int ) (pow ((i / 255.0 ), gamma ) * 255.0 );
39
+ table[i] = saturate_cast<uchar> (pow ((i / 255.0 ), gamma ) * 255.0 );
40
40
}
41
41
42
42
LUT (input, table, output);
43
- output.convertTo (output, CV_8UC3);
44
43
}
45
44
46
45
void autoscaling (const Mat input, Mat& output)
@@ -52,25 +51,24 @@ void autoscaling(const Mat input, Mat& output)
52
51
53
52
void contrastStretching (const Mat input, Mat& output, const int r1, const int s1, const int r2, const int s2)
54
53
{
55
- vector< int > table ( 256 ) ;
54
+ array<uchar, 256 > table;
56
55
for (int i = 0 ; i < 256 ; i++)
57
56
{
58
57
if (i <= r1)
59
58
{
60
- table[i] = ( int ) (((float )s1 / (float )r1) * i);
59
+ table[i] = saturate_cast<uchar> (((float )s1 / (float )r1) * i);
61
60
}
62
61
else if (r1 < i && i <= r2)
63
62
{
64
- table[i] = ( int ) (((float )(s2 - s1)/(float )(r2 - r1)) * (i - r1) + s1);
63
+ table[i] = saturate_cast<uchar> (((float )(s2 - s1)/(float )(r2 - r1)) * (i - r1) + s1);
65
64
}
66
65
else // (r2 < i)
67
66
{
68
- table[i] = ( int ) (((float )(255 - s2)/(float )(255 - r2)) * (i - r2) + s2);
67
+ table[i] = saturate_cast<uchar> (((float )(255 - s2)/(float )(255 - r2)) * (i - r2) + s2);
69
68
}
70
69
}
71
70
72
71
LUT (input, table, output);
73
- output.convertTo (output, CV_8UC3);
74
72
}
75
73
76
74
}} // cv::intensity_transform::
0 commit comments