Androidのjavaで2つの画像のピクセルの差を計算する必要があります。問題は、不正確な結果を返すコードがあることです。Android Javaのパーセンテージビットマップ2つの画像のピクセルの差
など。私は3つの非常によく似た写真を持っていますが、それはそれぞれの比較のために大きく異なる結果を返します: pic1対pic2 = 1.71%; pic1対pic3 = 0.0045%; pic2対pic3 = 36.7%。
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inPreferredConfig = Bitmap.Config.ARGB_8888;
opt.inSampleSize = 5;
Bitmap mBitmap1 = BitmapFactory.decodeFile("/sdcard/pic1.jpg", opt);
Bitmap mBitmap2 = BitmapFactory.decodeFile("/sdcard/pic2.jpg", opt);
int intColor1 = 0;
int intColor2 = 0;
for (int x = 0; x < mBitmap1.getWidth(); x++) {
for (int y = 0; y < mBitmap1.getHeight(); y++) {
intColor1 = mBitmap1.getPixel(x, y);
intColor2 = mBitmap2.getPixel(x, y);
//System.out.print(" ("+ x + ","+ y +") c:" + intColor1);
}
String resultString = String.valueOf(intColor1);
}
//now calculate percentage difference
double razlika = (((double)intColor1 - intColor2)/intColor2)*100;
}
私は(intColor2(x、y)の対intColor1(x、y)は)私は両方のイメージのために、各ピクセルを比較する必要があると思いますが、どのように私はそれを行うことができ、以降のパーセンテージ差を計算しますか?
私は類似した画像をすべて取得して一覧表示する必要があります。 –