OpenIMAJ のチュートリアルを読み、そのチュートリアルから次のコードを取得しました。コードによると、画像のクラスターの中心を取得します。しかし、その時点から、2 つの画像を比較するためにこれらの値を使用する方法がわかりません。これがコードです。ドキュメントにあるようにコメントを追加したので、アイデアを得ることができます。
public static void main(String[] args) throws IOException
{
final String input_1Str ="/compareimage/clip6.jpg";
MBFImage input = ImageUtilities.readMBF(objectRecognition.class.getResourceAsStream(input_1Str));
input = ColourSpace.convert(input, ColourSpace.CIE_Lab); //apply a colour-space transform to the image
FloatKMeans cluster = FloatKMeans.createExact(2); //construct the K-Means algorithm. The parameter (2) is the number of clusters or classes we wish the algorithm to generate
FloatKMeans.createKDTreeEnsemble(2);
float[][] imageData = input.getPixelVectorNative(new float[input.getWidth() * input.getHeight()][3]); //The FloatKMeans algorithm takes its input as an array of floating point vectors (float[][]). We can flatten the pixels of an image into the required form using the getPixelVectorNative() method
FloatCentroidsResult result = cluster.cluster(imageData);
float[][] centroids = result.centroids; //The K-Means algorithm can then be run to group all the pixels into the requested number of classes
for (float[] fs : centroids) {
System.out.println(Arrays.toString(fs)); //Each class or cluster produced by the K-Means algorithm has an index, starting from 0. Each class is represented by its centroid. Running it prints the (L, a, b) coordinates of each of the classes
}
画像に対して上記のコードを実行すると、次の結果が得られました。
Image 1:
[95.99463, 3.6134863, 2.641686]
[32.080914, 14.114657, -48.14841]
上記のコードを別の画像で実行すると、次のようになります
Image 2:
[32.11119, 13.966739, -47.994236]
[95.64963, 3.9856236, 2.9136417]
これらの値を使用して、2 つの画像をどのように比較できますか。画像を比較する方法についてのアイデアはありません。私を助けてください。前もって感謝します。