i am doing work on images using java. i read a gray scale image and convert the pixel values to 0 and 1 i got the output image correctly for only some images. in others some image portions are lost here is the code i am using to make the image array back into image
`BufferedImage I = ImageIO.read(new File("path"));
SampleModel sampleModel;
Raster pixelData;
pixelData = I.getData();
int[][] pixels=new int[wid][hgt];
sampleModel=pixelData.getSampleModel();
BufferedImage image=new BufferedImage(wid,hgt,BufferedImage.TYPE_BYTE_BINARY);
WritableRaster raster=Raster.createWritableRaster(sampleModel,new Point(0,0));
for(int i=0;i<wid;i++)
{
for(int j=0;j<hgt;j++)
{
raster.setSample(i,j,0,pixels[i][j]);
}
}
image.setData(raster);
File output=new File("path");
ImageIO.write(image,"png",output);
System.out.println("..End..");`
size of the image is same as original but the entire size contains only a portion of original image.can u help me