私はFindBestMatch
というメソッドを持っていて、それは10回繰り返されるcompareMatrices
という別のメソッドを呼び出します。 compareMatrices
は、基本的に2つの配列を比較して数値を返す数学を行いますが、2つの配列が一致するほど数値が大きくなります。 FindBestMatch
は、最も高い番号の値を返す必要があります。各番号の数値を返すメソッドのグループから最大の番号を見つける
public String FindBestMatch() {
compareMatrices(numFiles.getMatrix("zero"), imgMatrix);
compareMatrices(numFiles.getMatrix("one"), imgMatrix);
compareMatrices(numFiles.getMatrix("two"), imgMatrix);
compareMatrices(numFiles.getMatrix("three"), imgMatrix);
compareMatrices(numFiles.getMatrix("four"), imgMatrix);
compareMatrices(numFiles.getMatrix("five"), imgMatrix);
compareMatrices(numFiles.getMatrix("six"), imgMatrix);
compareMatrices(numFiles.getMatrix("seven"), imgMatrix);
compareMatrices(numFiles.getMatrix("eight"), imgMatrix);
compareMatrices(numFiles.getMatrix("nine"), imgMatrix);
}
そこで、基本的FindBestMatch
実行、9を通じてゼロ、およびそれぞれの時間は数を返します。
は、ここで私が持っているものです。 compareMatrices
コールが最も高い数値を返す方法を知る方法がわかりませんか?
EDIT
ここに「compareMatrices」があります。数値ファイルの2D配列と画像ファイルの2D配列を入力として受け取ります。
public double compareMatrices(int[][] num, double[][] img) {
int nNumRows = num.length;
int nNumCols = num[0].length;
int nImgRows = img.length;
int nImgCols = img[0].length;
double highest = 0;
for (int row = 0; row < nImgRows - nNumRows + 1; row++) {
for (int col = 0; col < nImgCols - nNumCols + 1; col++) {
double score = 0;
for
(int row_offset = 0; row_offset < nNumRows; row_offset++) {
for (int col_offset = 0;
col_offset < nNumCols; col_offset++) {
int imgRowIndex = row + row_offset;
int imgColIndex = col + col_offset;
int numV = num[row_offset][col_offset];
double imgV = img[imgRowIndex][imgColIndex];
if ((imgV == 1) && (numV == 1)) {
score +=1;
} else if ((numV == 1) & (imgV == 0)) {
score -= 0.25;
} else if ((numV == 0) && (imgV == 0)) {
score += 0.25;
}
}
}
if (score > highest) {
highest = score;
}
}
}
return highest;
}
そして、それは基本的に数行列と画像マトリックスマッチより良い、より高いスコア、スコアを返します。
'compareMatrices'は何をスコアとする方法は、文字列を返します?それは何かを返しますか?その入力は何ですか? –
さて、変数のように戻り値をどこかに格納してから、別のものと比較することから始めることができます。 – azurefrog