如何将图像转换为仅包含黑色和白色方块的二进制流? [关闭]

Image pattern

Image will be just like chess board kind (actual image will contain some random pattern not uniform pattern like this sample image).

Is there any way to convert these kind of images into binary stream like?

10101010

01010101 ...... ....

preferred programming languages: java, jquery, javascript, php

At first step you have to choose cell size. It could be fixed (10px for example). Or image can have some kind of ruler (hava a look at QR fixed patterns or DataMatrix timing patterns)

When you have fixed cell size. All you have is to read image in rectangulars of desired size and calculate average color. Then move to next.

When you have timing pattern. First of all you have to calculate cell size. You read timing pattern by pixels and compare color with previous. Whenever color changes (with some average consideration), you get a cell size. Then read full image as with fixed size.

Have a look at QRcode manipulations written in you favorite language.