0

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.

Matrix

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?

0

2 Answers 2

3

If A is a 2D numpy array then:

A[::2,::2]

should get what you want.

Sign up to request clarification or add additional context in comments.

1 Comment

This fetches the black values and already mentioned in the question.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.