Simple GIS

GISプログラムの練習

写真の練習

package pic3;



import java.awt.*; 
import java.awt.event.*; 
import java.awt.image.*; 

class pro extends Frame{ 

PixelGrabber pg; 
Color col; 
Image img; 
int w; 
int h; 
int memor=new int[h][w]; 
int memog=new int[h][w]; 
int memob=new int[h][w];
int f=new int[1000][1000];

 int teamx=new int[100000];
  int teamy=new int[100000];
  int teamnumber;

    int group=new int[100000];


int number;
int mx,nx; 
int num,s; 
String s1,s2; 

public static void main(String args) { 
pro f = new pro(); 
f.setSize(600,600); 
f.setBackground(Color.blue) ; 
f.setVisible(true); 
f.addWindowListener(new WindowAdapter(){public void 
windowClosing(WindowEvent e){System.exit(0);}}); 
} 



pro() { 

String str;
    
str="k.jpg"; 

w=400;
h=400;

catchimg sub=new catchimg();
sub.w=w;
sub.h=h;
sub.makedata(str);
memor=sub.memor;
memog=sub.memog;
memob=sub.memob;

for (mx=0;mx<h;mx++){ 
for (nx=0;nx<w;nx++){ 
f[mx][nx]=flesh(mx,nx,50);
} 
} 

s=0;
for (mx=0;mx<h;mx++){ 
for (nx=0;nx<w;nx++){ 
if(f[mx][nx]>50)s=s+1;    
if(f[mx][nx]>50)teamx[s]=nx;
if(f[mx][nx]>50)teamy[s]=mx;
}
}
teamnumber=s;

 System.out.println(teamnumber);

    group sub2=new group();
    sub2.teamx=teamx;
    sub2.teamy=teamy;
    sub2.teamnumber=teamnumber;
    sub2.makedata();
    number=sub2.number;
    group=sub2.group;

    System.out.println(number);
    


} 




int flesh(int mx,int nx,int x){
int h1,f1;
f1=0;
h1=0;
if(memor[mx][nx]>241-x)h1=h1+1;
if(memor[mx][nx]<241+x)h1=h1+1;
if(memog[mx][nx]>187-x)h1=h1+1;
if(memog[mx][nx]<187+x)h1=h1+1;
if(memob[mx][nx]>147-x)h1=h1+1;
if(memob[mx][nx]<147+x)h1=h1+1;
if(h1==6)f1=100;    
return f1;
}

public void paint( Graphics g ) { 
int i,z,pp,mx,nx,h1; 
g.setColor(Color.white); 
g.fillRect(0,0,600,600); 
 


System.out.println(h);

for (mx=0;mx<h;mx++){ 
for (nx=0;nx<w;nx++){ 
g.setColor(new Color(memor[mx][nx],memog[mx][nx],memob[mx][nx])); 
g.fillRect(nx+100,mx+100,1,1); 
} 
} 

for(s=1;s<teamnumber+1;s++){
mx=teamy[s];
nx=teamx[s];
g.setColor(Color.red); 
if(group[s]>50)g.fillRect(nx+100,mx+100,1,1); 
}


} 



}