Doubt in quiz question 10 of Numpy

Sir according to me ::-1 will reverse the whole channel and not specifically first and third channel. Please clear the confusion about the correct answer.

Hello @Charu510, yes it will reverse the whole channel, but correspondingly we will get the same output, as 1 and 3 get reversed and 2nd will remain at its place only after reversing as well.
So, we also need to consider that case as well, here we are checking for the correct output.
I hope it is clear to you. In case if there is any issue pls let me know. I will try my best to help you out.
In case it is clear to you, pls mark it as resolve and feel free to provide the feedback.
Thanks :slight_smile:

Means is it the case like all the 3 channels have the same value i.e 3 and that is why the whole reversal and reversal of the first and third channels will yield the same result that is 3,3,3. Please guide is my understanding this way is right?

Here reversing means we are reversing the outermost channels.
So if we see here we have img = np.arange(333).reshape(3,3,3)
That is equal to:

array([[[ 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]]])

now if we use the A or B operation we get,

array([[[18, 19, 20],
        [21, 22, 23],
        [24, 25, 26]],

       [[ 9, 10, 11],
        [12, 13, 14],
        [15, 16, 17]],

       [[ 0,  1,  2],
        [ 3,  4,  5],
        [ 6,  7,  8]]])

So the output is the same in both the cases and hence we mark both A and B.
I hope it is clear to you know. Pls, feel free to ask if still there is anything that you don’t understand.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.