I have a black and white image which every pixel values are loaded as a nested list with numpy (2948×1536). What i need to do is to grab the pixels from that list in a checkerboard pattern. So I need to extract pixels like this :
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
….
How would this be done ? Is this a good idea to use a nested list for such a job ? If not, what would you suggest ?
Image processing is quite new to me.
Any help would be greatly appreciated,
Let’s use smaller dimensions so the result is easier to see:
We can construct a boolean array in a checkerboard pattern:
Using this boolean array for indexing, we can extract the values we desire:
PS. Inspiration for this answer came from Ned Batchelder’s answer here.