forked from yuqing-liu-dut/ISPLab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NRyuv.cpp
76 lines (56 loc) · 1.27 KB
/
NRyuv.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
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
#include "MyISP.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
void NRchroma(ImageYUV& yuv, int d)
{
ImageYUV* yuv_pad = new ImageYUV(yuv);
yuv_pad->padding(d / 2, PADDING_MODE_EDGE);
uint8_t* valU = new uint8_t[d * d];
uint8_t* valV = new uint8_t[d * d];
for (int y = 0; y < yuv.getHeight(); y++)
{
for (int x = 0; x < yuv.getWidth(); x++)
{
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
valU[i * d + j] = yuv_pad->at(y + i, x + j).U;
valV[i * d + j] = yuv_pad->at(y + i, x + j).V;
}
}
std::sort(valU, valU + d * d);
std::sort(valV, valV + d * d);
yuv.at(y, x).U = valU[d * d / 2];
yuv.at(y, x).V = valV[d * d / 2];
}
}
delete[] valU;
delete[] valV;
delete yuv_pad;
}
void NRluma(ImageYUV& yuv, int d)
{
ImageYUV* yuv_pad = new ImageYUV(yuv);
yuv_pad->padding(d / 2, PADDING_MODE_EDGE);
uint8_t* valY = new uint8_t[d * d];
for (int y = 0; y < yuv.getHeight(); y++)
{
for (int x = 0; x < yuv.getWidth(); x++)
{
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
valY[i * d + j] = yuv_pad->at(y + i, x + j).Y;
}
}
std::sort(valY, valY + d * d);
yuv.at(y, x).Y = valY[d * d / 2];
}
}
delete[] valY;
delete yuv_pad;
}