2

How to get the (2,2) pixel of every (4,4) block. I know how to get the (0,0) for every (4,4). Sample code as below

import numpy as np
image = np.arange(12*8).reshape(12,8)
print(image)
image2 = image2 = image[::4, ::4]
print(image2)

Output:

[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]
 [40 41 42 43 44 45 46 47]
 [48 49 50 51 52 53 54 55]
 [56 57 58 59 60 61 62 63]
 [64 65 66 67 68 69 70 71]
 [72 73 74 75 76 77 78 79]
 [80 81 82 83 84 85 86 87]
 [88 89 90 91 92 93 94 95]]
[[ 0  4]
 [32 36]
 [64 68]]

I would like to see

[[ 9  13]
 [41 45]
 [73 77]]
py_newbie
  • 329
  • 2
  • 9

0 Answers0