-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRGBColorSpace.cpp
47 lines (40 loc) · 1002 Bytes
/
RGBColorSpace.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
#include "stdafx.h"
#include "RGBColorSpace.h"
RGBColorSpace::RGBColorSpace(Mat Input)
:Strategy(Input)
{
}
RGBColorSpace::~RGBColorSpace()
{
}
void RGBColorSpace::detectSkin()
{
MatIterator_<Vec3b> Iter2Src = SrcImage.begin<Vec3b>();
MatIterator_<Vec3b> Iter2SrcEnd = SrcImage.end<Vec3b>();
MatIterator_<uchar> Iter2Dst = DstImage.begin<uchar>();
for (; Iter2Src != Iter2SrcEnd; Iter2Src++, Iter2Dst++){
(*Iter2Dst) = 0;
if ((*Iter2Src)[2] > 95 && (*Iter2Src)[1] > 40 && (*Iter2Src)[0] > 20
&& (*Iter2Src)[2] > (*Iter2Src)[0] && (*Iter2Src)[2] > (*Iter2Src)[1]
&& abs((*Iter2Src)[2] - (*Iter2Src)[1]) > 15){
uchar Max, Min;
if ((*Iter2Src)[0] >= (*Iter2Src)[1]){
Max = (*Iter2Src)[0];
Min = (*Iter2Src)[1];
}
else{
Max = (*Iter2Src)[1];
Min = (*Iter2Src)[0];
}
if ((*Iter2Src)[2] > Max){
Max = (*Iter2Src)[2];
}
else if ((*Iter2Src)[2] < Min){
Min = (*Iter2Src)[2];
}
if (Max - Min > 15){
(*Iter2Dst) = 255;
}
}
}
}