Oct 20, 2020
When you read the image using cv2.imread(), it will return an array of numbers. This array denotes the image and numbers denote the values in each pixel. For a one-channel image (black&white ), one number denotes each pixel 2D, but for an three-channel image (colored), three images denote each pixel 3D.
Hence the indices of the array give you the location of each pixel. Given that each block is 10 X 10 pixel each than (0,0) will be image[0:10,0:10] and (0,1) will image[0:10,10:20]. For a box at x,y with size S, pixels will be image[x*S : (x+1)*S , y*S : (y+1)*S].
In the article I’ve used the code :
block = img[h0:h,w0:w]
Where :
h = CELL_SIZE*(coordinate[0]+1)
w = CELL_SIZE*(coordinate[1]+1)
h0= CELL_SIZE*coordinate[0]
w0= CELL_SIZE*coordinate[1]
Hope, your problem is solved.