Reputation: 13
I have a 2D array A: nxn with values of a function, and I want to take the values in different arrays for the black values, white values and gray values.
For example for the black and white values I wrote:
black_values = A[::2,::2]
white_values = A[1::2,1::2]
How to get the gray values?
Upvotes: 0
Views: 61
Reputation: 2696
Note that the number of gray values are twice that of either black or white values. So you might use two arrays to store gray values.
g1 = A[::2, 1::2]
g2 = A[1::2, ::2]
Here you will get 2 16 x 16
arrays g1
and g2
that will store your 32
gray values.
Upvotes: 1
Reputation: 404
If A
is a 2D numpy array then:
A[::2,::2]
should get what you want.
Upvotes: 3