1. Substraction(Difference)
이미지 차이/오류 확인
$ MSE(Mean Squared Error) = \frac{(Original - Output)^{2}}{Pixels} $
Diff_Y = (inputImg1[j * stride + 3 * i + 2] - inputImg2[j * stride + 3 * i + 2]) *
(inputImg1[j * stride + 3 * i + 2] - ipnutImg2[j * stride + 3 * i + 2])
2. Addition(Embedding)
워터마크와 유사
Y1 = 0.299 * inputImg1[j * stride + 3 * i + 2] +
0.587 * inputImg1[j * stride + 3 * i + 1] +
0.114 * inputImg1[j * stride + 3 * i + 0]
Y2 = 0.299 * inputImg2[j * stride + 3 * i + 2] +
0.587 * inputImg2[j * stride + 3 * i + 1] +
0.114 * inputImg2[j * stride + 3 * i + 0]
Y = Y1 / a + Y2 / b
3. Ratio
4. Multiplication
(1)
for (int j = 0; j < height; j++)
{
for (int i = 0; i < width; i++)
{
double Y1 = 0.299 * inputImg1[j * stride + 3 * i + 2] +
0.587 * inputImg1[j * stride + 3 * i + 1] +
0.114 * inputImg1[j * stride + 3 * i + 0];
double Y2 = 0.299 * inputImg2[j * stride + 3 * i + 2] +
0.587 * inputImg2[j * stride + 3 * i + 1] +
0.114 * inputImg2[j * stride + 3 * i + 0];
double Y = Y1 / a + Y2 / b;
if (Y2 == 0) Y = 0;
outputImg[j * stride + 3 * i + 0] = (unsigned char)(Y > 255 ? 255 : (Y < 0 ? 0 : Y));
outputImg[j * stride + 3 * i + 1] = (unsigned char)(Y > 255 ? 255 : (Y < 0 ? 0 : Y));
outputImg[j * stride + 3 * i + 2] = (unsigned char)(Y > 255 ? 255 : (Y < 0 ? 0 : Y));
}
}
(2)
for (int j = 0; j < height; j++)
{
for (int i = 0; i < width; i++)
{
// inputImg2 색상반전
inputImg2[j * stride + 3 * i + 0] = 255 - inputImg2[j * stride + 3 * i + 0];
inputImg2[j * stride + 3 * i + 1] = 255 - inputImg2[j * stride + 3 * i + 1];
inputImg2[j * stride + 3 * i + 2] = 255 - inputImg2[j * stride + 3 * i + 2];
double Y1 = 0.299 * inputImg1[j * stride + 3 * i + 2] +
0.587 * inputImg1[j * stride + 3 * i + 1] +
0.114 * inputImg1[j * stride + 3 * i + 0];
double Y2 = 0.299 * inputImg2[j * stride + 3 * i + 2] +
0.587 * inputImg2[j * stride + 3 * i + 1] +
0.114 * inputImg2[j * stride + 3 * i + 0];
double Y = Y1 / a + Y2 / b;
if (Y2 == 0) Y = 0;
outputImg[j * stride + 3 * i + 0] = (unsigned char)(Y > 255 ? 255 : (Y < 0 ? 0 : Y));
outputImg[j * stride + 3 * i + 1] = (unsigned char)(Y > 255 ? 255 : (Y < 0 ? 0 : Y));
outputImg[j * stride + 3 * i + 2] = (unsigned char)(Y > 255 ? 255 : (Y < 0 ? 0 : Y));
}
}
'Computer Science > 영상처리' 카테고리의 다른 글
(C/C++) Filter (Denoising) (0) | 2024.04.01 |
---|---|
(C/C++) Quality Evaluation(PSNR) (0) | 2024.03.27 |
(C/C++) Color Model (0) | 2024.03.27 |
(C/C++) Image Format (0) | 2024.03.27 |
(C/C++) Resolution(해상도) (0) | 2024.03.27 |