怀旧色
源码:
void huaijiu(Mat& src,Mat& dst)
{
for (int h = 0;h < src.rows;h ++)
{
uchar *d1 = src.ptr<uchar>(h);
uchar *d2 = dst.ptr<uchar>(h);
for (int w = 0;w < src.cols;w ++)
{
int w3 = 3*w;
int r = d1[w3 + 2];
int g = d1[w3 + 1];
int b = d1[w3 + 0];
int AR =(int)(0.393*r + 0.769*g + 0.189*b);
int AG =(int)(0.349*r + 0.686*g + 0.168*b);
int AB =(int)(0.272*r + 0.534*g + 0.131*b);
AR = AR > 255 ? 255 : AR;
AG = AG > 255 ? 255 : AG;
AB = AB > 255 ? 255 : AB;
d2[w3 + 2] = AR;
d2[w3 + 1] = AG;
d2[w3 + 0] = AB;
}
}
}
原图:
冰冻滤镜
void bingdong(Mat& src,Mat& dst)
{
for (int h = 0;h < src.rows;h ++)
{
uchar *d1 = src.ptr<uchar>(h);
uchar *d2 = dst.ptr<uchar>(h);
for (int w = 0;w < src.cols;w ++)
{
int w3 = 3*w;
int r = d1[w3 + 2];
int g = d1[w3 + 1];
int b = d1[w3 + 0];
int AR =(r - b - g)*3/2;
int AG =(g - b - r)*3/2;
int AB =(b - r - g)*3/2;
AR = AR > 255 ? 255 : AR;
AG = AG > 255 ? 255 : AG;
AB = AB > 255 ? 255 : AB;
d2[w3 + 2] = AR;
d2[w3 + 1] = AG;
d2[w3 + 0] = AB;
}
}
}
熔铸滤镜
void rongzhu(Mat& src,Mat& dst)
{
for (int h = 0;h < src.rows;h ++)
{
uchar *d1 = src.ptr<uchar>(h);
uchar *d2 = dst.ptr<uchar>(h);
for (int w = 0;w < src.cols;w ++)
{
int w3 = 3*w;
int r = d1[w3 + 2];
int g = d1[w3 + 1];
int b = d1[w3 + 0];
int AR = r * 128 / (b+g+1);
int AG = g*128 / (b+r+1);
int AB = b*128 / (r+g+1);
AR = AR > 255 ? 255 : AR;
AG = AG > 255 ? 255 : AG;
AB = AB > 255 ? 255 : AB;
d2[w3 + 2] = AR;
d2[w3 + 1] = AG;
d2[w3 + 0] = AB;
}
}
}