对于android_demo中对数据的处理疑问
Created by: sosky-yty
android_demo项目中MainActivity.java中: /** * get the 3 * 224 *224 float array * * @param bitmap * @param desWidth * @param desHeight * @return */ public float[] getScaledMatrix(Bitmap bitmap, int desWidth, int desHeight) { float[] dataBuf = new float[3 * desWidth * desHeight]; int rIndex; int gIndex; int bIndex;
Bitmap bitmap1 = Bitmap.createScaledBitmap(bitmap, desWidth, desHeight, false);
for (int j = 0; j < desHeight; ++j) {
for (int k = 0; k < desWidth; ++k) {
rIndex = j * desWidth + k;
gIndex = rIndex + desWidth * desHeight;
bIndex = gIndex + desWidth * desHeight;
int color = bitmap1.getPixel(k, j);
if (type == googlenet) {
dataBuf[rIndex] = (float) (red(color)) - 148;
dataBuf[gIndex] = (float) (green(color)) - 148;
dataBuf[bIndex] = (float) (blue(color)) - 148;
} else if (type == mobilenet) {
dataBuf[rIndex] = (float) ((red(color) - 123.68) * 0.017);
dataBuf[gIndex] = (float) ((green(color) - 116.78) * 0.017);
dataBuf[bIndex] = (float) ((blue(color) - 103.94) * 0.017);
} else if (type == squeezenet) {
dataBuf[rIndex] = (float) (red(color)) - 123;
dataBuf[gIndex] = (float) (green(color)) - 117;
dataBuf[bIndex] = (float) (blue(color)) - 104;
}
}
}
return dataBuf;
}
不同网络对于数据处理的依据是什么,为什么会这样处理?对于其他网络该怎么处理?