package ocrtest;


import java.awt.Image;

import java.awt.image.PixelGrabber;


import javax.swing.ImageIcon;


public class image {

public static void main(String[] args) {

Image img = new ImageIcon("im/gi.jpg").getImage();

Image img1 = new ImageIcon("im/gi1.jpg").getImage();


int width = img.getWidth(null);

int height = img.getHeight(null);


int width1 = img1.getWidth(null);

int height1 = img1.getHeight(null);


int[] pixels = new int[width * height];

int[] pixels1 = new int[width1 * height1];


PixelGrabber grab = 

   new PixelGrabber(img, 0, 0, width, height, pixels, 0, width);

PixelGrabber grab1 = 

  new PixelGrabber(img1, 0, 0, width1, height1, pixels1, 0, width1);


try {

grab.grabPixels();

grab1.grabPixels();


int[][] picture = new int[width][height];

int[][] picture1 = new int[width1][height1];

if (pixels.length != pixels1.length) {

System.out.println("사이즈 다름");

} else {

System.out.println("1 "+grab.getWidth()+" "+grab.getHeight());

System.out.println("2 "+grab1.getWidth()+" "+grab1.getHeight());

}


for (int i = 0; i < pixels.length; i++) {

picture[i % width][i / width] = pixels[i];

picture1[i % width1][i / width1] = pixels1[i];


if (picture[i % width][i / width] == picture1[i % width1][i / width1]) {


} else {


System.out.println(i + " 번째 픽셀 : " + picture[i % width][i / width]); System.out.println(i + " 번째 픽셀 : " + picture1[i % width1][i / width1]);

System.out.println("다른이미지 종료");

return;

}

}

System.out.println("같은 이미지");


} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}


}


}



// System.out.println("alpha " + ((picture[i % width][i / width] >>24) &0xff));

// System.out.println("R " + ((picture[i % width][i / width] >> 16) & 0xff));

// System.out.println("G " + ((picture[i % width][i / width] >> 8) & 0xff));

// System.out.println("B " + (picture[i % width][i / width] & 0xff));



'JAVA > 자바' 카테고리의 다른 글

자바 이미지 형태 비교  (0) 2015.10.14
자바 이미지 불러와서 수정 후 저장  (0) 2015.10.13
자바 메일보내기  (3) 2015.10.06
자바 팩토리얼  (0) 2015.09.10
자바 피보나치수열  (0) 2015.09.10
블로그 이미지

왕왕왕왕

,