# A discussion on the realization method of Android platform Camera real-time filter (nine) to investigate the skin grinding algorithm -- (a)

Classification:

The last one mentioned some of the denoising algorithm can be used for grinding, the following we achieve these algorithms and observe the effect, I do not consider the issue of real-time

First of all, this paper discusses theImage denoising based on local mean square deviation and its application in real time skin beauty algorithm

The algorithm uses the local statistical characteristics of the image filtering processing, such as NXM pixel gray map, the first point (I, J) in the window (size (2m+1) (2n+1)) the average value of M (I, J)

Mean square deviation:

The results obtained are as following:

Among them:

1 based on the optimization method proposed in the original text, the first is to establish the two integral graph,As shown in the figure, point 4 of the integral that is Sum (Ra) +Sum (Rb) +Sum (Rc) +Sum () (Rd).Integral graph algorithm can be referenceThis articleFor simple optimization, the M and V values of the formula can be calculated according to the formula.

M Integral (J, j+r) (i+r,) + Integral (, j-r-1) -Integral (i-r-1) (,) -Integral (i+r, j-r-1) (i-r-1,) () r (I, j+r). The code is as follows, respectively, for the 1 square and square integral map.

```MagicBeauty: void: initIntegral (inputMatrix uint8_t*) {
LOGE ("start initIntegral");
If (mIntegralMatrix = NULL)
MIntegralMatrix = uint64_t[mImageWidth new * mImageHeight];
If (mIntegralMatrixSqr = NULL)
MIntegralMatrixSqr = uint64_t[mImageWidth new * mImageHeight];

*columnSum new = uint64_t[mImageWidth] uint64_t;
*columnSumSqr new = uint64_t[mImageWidth] uint64_t;

ColumnSum[0] = inputMatrix[0];
ColumnSumSqr[0] = inputMatrix[0] * inputMatrix[0];

MIntegralMatrix[0] = columnSum[0];
MIntegralMatrixSqr[0] = columnSumSqr[0];

For (I int = 1; I < i++; mImageWidth) {

ColumnSum[i] = inputMatrix[i];
ColumnSumSqr[i] = inputMatrix[i] * inputMatrix[i];

MIntegralMatrix[i] = columnSum[i];
MIntegralMatrix[i] = mIntegralMatrix[i-1];
MIntegralMatrixSqr[i] = columnSumSqr[i];
MIntegralMatrixSqr[i] = mIntegralMatrixSqr[i-1];
}
For (I int = 1; I < i++; mImageHeight) {
Offset int = I * mImageWidth;

ColumnSum[0] = inputMatrix[offset];
ColumnSumSqr[0] = inputMatrix[offset] * inputMatrix[offset];

MIntegralMatrix[offset] = columnSum[0];
MIntegralMatrixSqr[offset] = columnSumSqr[0];
Other / / columns
For (J int = 1; J < j++; mImageWidth) {
ColumnSum[j] = inputMatrix[offset+j];
ColumnSumSqr[j] = inputMatrix[offset+j] * inputMatrix[offset+j];

MIntegralMatrix[offset+j] = mIntegralMatrix[offset+j-1] + columnSum[j];
MIntegralMatrixSqr[offset+j] = mIntegralMatrixSqr[offset+j-1] + columnSumSqr[j];
}
}
ColumnSum delete[];
ColumnSumSqr delete[];
LOGE ("end initIntegral");
}```

2 based on the online copy of the RGB skin color detection and calculation of skin color region

```MagicBeauty: void: initSkinMatrix () {
LOGE ("initSkinMatrix - start");
If (mSkinMatrix = NULL)
MSkinMatrix = uint8_t[mImageWidth new * mImageHeight];
For (I int = 0; I < i++; mImageHeight) {
For (J int = 0; J < j++; mImageWidth) {
Offset int = i*mImageWidth+j;
RGB ARGB;
BitmapOperation:: convertIntToArgb (mImageData_rgb[offset], &RGB);
If ((RGB.blue>95 & & & & RGB.red>20 & & RGB.green>40
RGB.blue-RGB.red>15 & & RGB.blue-RGB.green>15) ||//uniform illumination
(RGB.blue>200 & & & & RGB.red>170 & & RGB.green>210
ABS (RGB.blue-RGB.red) <=15 RGB.green>RGB.red) //lateral illumination & & RGB.blue>RGB.red&&)
MSkinMatrix[offset] = 255;
Else
MSkinMatrix[offset] = 0;
}
}
LOGE ("initSkinMatrix - end");
}```

3。根据公式对RGB通道或者将RGB通道转化为YCbCr格式单独对Y通道进行滤波

```无效magicbeauty：：startlocalstatisticssmooth（浮西格玛）{

mimagedata_yuv_y = = null | | mskinmatrix = = null | | mimagedata_yuv = = null）{

}

int offset =我mimagewidth + J；

int Imax = I +半径> = mimageheight-1？mimageheight-1：我+半径；
int JMAX = J +半径> = mimagewidth-1？mimagewidth-1：J +半径；
int Imin =我半径≤1？1：我半径；
int Jmin=R J半径≤1？1：半径；

int平方=（IMAX伊明+ 1）*（Jmax - jmin + 1）；
int I4 = IMAX * mimagewidth + Jmax；
int I3 =（imin-1）* mimagewidth +（jmin-1）；
int I2 = IMAX * mimagewidth +（jmin-1）；
int I1 =（imin-1）* mimagewidth + Jmax；

+ mintegralmatrix [I3]
- mintegralmatrix [I2]
- mintegralmatrix [ I1 ]）/平方；

+ mintegralmatrixsqr [I3]
- mintegralmatrixsqr [I2]
- mintegralmatrixsqr [ I1 ]）/平方米×米；

mimagedata_yuv [偏移] * 3 = M K m + k * mimagedata_yuv_y [偏移]；</跨度>
}
}
}
endlocalstatisticssmooth()；
}```

*以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
找工作
16应届生求Android开发工作！坐标：南京。邮箱：372535090 @ qq。com，有需求可联系~
个人资料
• 访问：21135次
• 积分：五百二十九
• 等级：
• 排名：千里之外
• 原创：28篇
• 转载：0篇
• 译文：0篇
• 评论：36条
博客专栏
 Android图像处理之实时滤镜 文章：10篇 阅读：12284
 cocos2dx塔防游戏开发 文章：15篇 阅读：8576
文章分类
文章存档