It looks like you're new here. If you want to get involved, click one of these buttons!
File file = new File(\"img/smile.bmp\");
BufferedImage img = null;
try {
img = ImageIO.read(file);
} catch (IOException e) {
e.printStackTrace();
}
int[] vector = new int[img.getWidth() * img.getHeight()];
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
int rgb = img.getRGB(x, y);
if (rgb == 0xffffffff) { // white pixel
vector[x * y] = 0;
} else {
vector[x * y] = 1;
}
System.out.print(vector[x * y]);
}
System.out.println();
}