import java.awt.*;
import java.awt.image.*;
import java.awt.Color;
import java.awt.Image;
import java.awt.Graphics;
import javax.swing.*;
import java.lang.Object;
import java.util.*;
import java.awt.BorderLayout;
import java.awt.MediaTracker;
import java.awt.Toolkit;




public class Binary_Image

{
public static void main(String[]arg)
{


Image img;
int iw,ih;
int pixels[];
int hist[] = new int[256];
int max_hist = 0;
int cnt1=0,cnt=0,cnt2=0,h1,h2,h3,c=0;




{


Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth = screenSize.width;
int screenHeight = screenSize.height;


try


{

MediaTracker tracker = new MediaTracker(this);
tracker.addImage(img,0);
try {tracker.waitForID(0);}
catch (InterruptedException e){}


img= Toolkit.getDefaultToolkit().getImage("jawi.gif");

iw = img.getWidth(null);
ih = img.getHeight(null);


pixels = new int[iw*ih];
PixelGrabber pg = new PixelGrabber(img,0,0,iw,ih,pixels,0,iw);
pg.grabPixels();



}
catch(InterruptedException e) {};


for(int i=0;i<iw*ih;i++)
{
int p = pixels[i];
int r = (p>>16) & 0xff;
int g = (p>>8) & 0xff;
int b = (p) & 0xff;
int k = (int)(.56*g + .33*r + .11 * b);
//pixels[i] = (0xff000000 | k<<16 | k<<8 |k);
cnt++;
if(k<36)


{
cnt1++;
pixels[i]=(255 << 24)|(0 << 16)|(0 << 8)|0;
}

else


{
cnt2++;
pixels[i]=(255 << 24)|(255 << 16)|(255 << 8)|255;
}
}

System.out.println("Total no of pixels ="+cnt);
System.out.println("Total no of black pixels ="+cnt1);
System.out.println("Total no of white pixels ="+cnt2);


}


}

}