EvilZone

Programming and Scripting => Java => : DreX September 12, 2014, 01:57:33 AM

: Java pixel comparison possible?
: DreX September 12, 2014, 01:57:33 AM
Can I create the following program in Java:
(this is a very crude plan):
I need to be able to compare two images. All pictures will be screenshoots (so the resolution will/ should be the same for every image). First I will make "reference images" for (0-9). Then I take another sc and and "disect" the image to be in one-digit numbers (0-9). I will then compare them and find out the number that is in picture.

I was thinking along the lines: import image. Compare every pixel with the same pixel from "reference" picture. If the pictures are equal return true. If true then int x="referencal" image number.

If this is possible I only wish to know in what chapter I need to look (ArrayList, Classes, Swing......).
: Re: Java pixel comparison possible?
: Matriplex September 12, 2014, 04:09:51 AM
You can do this using artificial neural networks. Look up heaton introduction to hopfield networks in java. It's a good book for beginners. Or you could extract the binary image data as a string and compare the two. This would be super easy, but the other image would have to be exactly the same.
: Re: Java pixel comparison possible?
: DreX September 12, 2014, 09:41:15 AM
You can do this using artificial neural networks. Look up heaton introduction to hopfield networks in java. It's a good book for beginners. Or you could extract the binary image data as a string and compare the two. This would be super easy, but the other image would have to be exactly the same.

Thanks. Gonna look into binary image first.
: Re: Java pixel comparison possible?
: Deque September 12, 2014, 02:01:35 PM
Here is a small example that I made for one of the weekly challenges here. It shows the very basics for reading an image and accessing and comparing single pixels. The task was to find the one pixel that is different from the others (with me making the assumption that it is not the first one).

: (Java)
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class DirtyPixel {

    public static void main(String[] args) throws IOException {
        BufferedImage image = ImageIO.read(new File("chalx.png"));
        int defRgb = image.getRGB(0, 0);
        for (int x = 0; x < image.getWidth(); x++) {
            for (int y = 0; y < image.getHeight(); y++) {
                int rgb = image.getRGB(x, y);
                if(defRgb != rgb){
                    System.out.println("x: " + x);
                    System.out.println("y: " + y);
                    break;
                }
            }
        }
    }
}

If you decide to look into ANN, you may read this:
https://evilzone.org/tutorials/artificial-neural-networks-the-basics/msg9782/#msg9782
: Re: Java pixel comparison possible?
: DreX September 13, 2014, 11:35:54 PM
Here is a small example that I made for one of the weekly challenges here. It shows the very basics for reading an image and accessing and comparing single pixels. The task was to find the one pixel that is different from the others (with me making the assumption that it is not the first one).

: (Java)
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class DirtyPixel {

    public static void main(String[] args) throws IOException {
        BufferedImage image = ImageIO.read(new File("chalx.png"));
        int defRgb = image.getRGB(0, 0);
        for (int x = 0; x < image.getWidth(); x++) {
            for (int y = 0; y < image.getHeight(); y++) {
                int rgb = image.getRGB(x, y);
                if(defRgb != rgb){
                    System.out.println("x: " + x);
                    System.out.println("y: " + y);
                    break;
                }
            }
        }
    }
}

If you decide to look into ANN, you may read this:
https://evilzone.org/tutorials/artificial-neural-networks-the-basics/msg9782/#msg9782 (https://evilzone.org/tutorials/artificial-neural-networks-the-basics/msg9782/#msg9782)



This will do quite nicely.
Thank you very much ^^
: Re: Java pixel comparison possible?
: chapp September 17, 2014, 10:58:16 AM
This is a task that is easily parallelised without much overhead if you want to look into that.