up with what the tutorial is showing and I'm getting 4 errors:
2 with the getWidth() and getHeight(), and 2 saying array required but java.awt.Image found
Here's what the tutorial says: and it's code:
a) Simple Image Matching
This operation is as simple as it sounds, it involves a pixel by pixel
comparison between two images. In pseudocode:
ExactMatch(image_1, image_2)
Input: Two images
Output: True if the images are pixel by pixel matches,
false otherwise
for(x = 0; x < image_1.width; x++) {
for(y = 0; y < image_1.height; y++) {
if(image_1[x][y] ≠ image_2[x][y]) {
return false;
}
}
}
return true;
Here's the best I could do with it, I fear I'm way off !!!!!
import java.awt.*;
import javax.swing.*;
public class CompareImg{
public static void main(String[] args){
String b;
Image image1 = Toolkit.getDefaultToolkit().getImage("main.jpg");
Image image2 = Toolkit.getDefaultToolkit().getImage("9.jpg");
for(int x = 0; x < image1.getWidth(); x++) {
for(int y = 0; y < image1.getHeight(); y++) {
if((image1[x][y]) == (image2[x][y])) {
b = "Images match";
} else {
b = "No match found";
}
}
}
System.out.println("" + b);
}
}

New Topic/Question
Reply




MultiQuote







|