Question

Je vais développer une application de comparaison d'image sur java. Pour cela, j'ai choisi algorithme d'Euclide. Cette application implique avec 2 images. 1. image réelle 2. Une partie de l'image réelle.

L'algorithme doit comparer la partie de l'image avec l'image réelle. Si la pièce est existé dans l'image réelle, elle doit retourner une valeur que le succès correspondant.

Quelqu'un peut-il me donner les étapes algorithmiques? code sur java sera apprécié ..!

Était-ce utile?

La solution

Voici une idée relativement simple, avec certaines parties laissées intentionnellement, car la question sent devoirs.

public static boolean contains(Image large, Image small) {
  final int largeWidth = large.getWidth(), largeHeight = large.getHeight();
  final int smallWidth = small.getWidth(), smallHeight = small.getHeight();

  if (smallWidth > largeWidth || smallHeight > largeHeight) {
    return false;
  }

  for (int x = 0; x < largeWidth - smallWidth; x++) {
    for (int y = 0; y < largeHeight - smallHeight; y++) {
      if (subImageEquals(large, x, y, small)) {
        return true;
      }
    }
  }
  return false;
}

private static boolean subImageEquals(Image large, int x, int y, Image small) {
  // TODO: checks whether all pixels starting at (x, y) match
  // those of the small image.
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top