package imgx;
public class pro {
public static void main(String[] args) {
pro t=new pro();
}
pro(){
int h,w;
getsize sub8=new getsize();
sub8.makedata("neko.jpg");
h=sub8.h;
w=sub8.w;
System.out.println(w+","+h);
int[][] memor=new int[h][w];
int[][] memog=new int[h][w]; int[][] memob=new int[h][w];
catchimg sub=new catchimg();
sub.w=w;
sub.h=h;
sub.memor=memor;
sub.memog=memog;
sub.memob=memob;
sub.makedata("neko.jpg");
memor=sub.memor;
memog=sub.memog;
memob=sub.memob;
int s,sx;
int[][] rgb=new int[h][w];
for(s=1;s<h;s++){
for(sx=1;sx<w;sx++){
int r1=memor[s][sx]-memor[s][sx-1];
int g1=memog[s][sx]-memog[s][sx-1];
int b1=memob[s][sx]-memob[s][sx-1];
double z1=r1*r1+g1*g1+b1*b1;
r1=memor[s][sx]-memor[s-1][sx];
g1=memog[s][sx]-memog[s-1][sx];
b1=memob[s][sx]-memob[s-1][sx];
double z2=r1*r1+g1*g1+b1*b1;
rgb[s][sx]=(int)Math.sqrt(z1+z2);
}}
graph sub4=new graph(); sub4.rgb=rgb; sub4.w=w; sub4.h=h; sub4.makedata("den.jpg");
}
}
package imgx;
import java.awt.*; import java.awt.Color; import java.awt.image.*; import java.awt.image.BufferedImage; import java.io.*; import javax.imageio.ImageIO; import java.awt.Polygon;
class graph{
int h; int w;
int[][] rgb=new int[h][w]; int[][] sampleg=new int[h][w]; int[][] sampleb=new int[h][w];
void makedata(String file){
int w1,h1,mx,nx;
w1=w; h1=h; BufferedImage off = new BufferedImage(w1, h1, BufferedImage.TYPE_INT_BGR); Graphics offsc = off.getGraphics();
int z; offsc.setColor(Color.white); offsc.fillRect(0,0,w,h);
for(mx=0;mx<h;mx++){ for(nx=0;nx<w;nx++){ offsc.setColor(Color.blue); if(rgb[mx][nx]>50)offsc.fillRect(nx,mx,1,1); } }
offsc.dispose();
try { ImageIO.write(off, "jpeg", new File(file)); } catch (IOException exception) { exception.printStackTrace(); } } }
package imgx;
import java.awt.*; import java.awt.image.*; import java.net.URL; import java.net.MalformedURLException;
public class catchimg {
PixelGrabber pg; Color col; Image img2; int red,green,blue;
int mx,nx,m,n; int ex,ey; String s1,s2,s3,s4; URL urlx;
int h,w;
int w1=2000; int h1=2000; int[] pix=new int[h1*w1]; int[][] memor=new int[h1][w1]; int[][] memog=new int[h1][w1]; int[][] memob=new int[h1][w1];
void makedata(String sp){
img2 = Toolkit.getDefaultToolkit().getImage(sp); pg = new PixelGrabber(img2,0,0,w,h,pix,0,w);
try{pg.grabPixels();}catch(InterruptedException ie){}
m=0; n=0; for(int i=0;i<w*h;i++){ int p = pix[i]; col=new Color(pix[i]); red=col.getRed(); green=col.getGreen(); blue=col.getBlue(); memor[m][n]=red; memog[m][n]=green; memob[m][n]=blue; n=n+1; if (n==w)m=m+1; if (n==w)n=0; }
}
}
package imgx;
import javax.swing.ImageIcon;
import java.awt.*; import java.awt.image.*; import java.net.URL; import java.net.MalformedURLException;
public class getsize {
Image img; int red,green,blue;
int mx,nx,m,n; int ex,ey; String s1,s2,s3,s4; URL urlx;
int h,w;
void makedata(String pic){
catchimgx(pic);
}
void catchimgx(String s){
img = Toolkit.getDefaultToolkit().getImage(s);
ImageIcon icon = new ImageIcon(img); h = icon.getIconHeight(); w = icon.getIconWidth();
}
}