1

I converted an image from RBG to CieLab, now I need to use the value of the cielab to calculate some equations. I have been trying to get the value of each column in the array. For example if I have:

List =

   [[[ 65 234 169]
     [203 191 245]
     [ 36  58 196]
     [207 208 143]
     [251 208 187]]

    [[ 79  69 237]
     [ 13 124  42]
     [104 165  82]
     [170 178 178]
     [ 66  42 210]]

   [[ 40 163 219]
    [142  37 140]
    [ 75 205 143]
    [246  30 221]
    [ 16  98 102]]]

How can I get it to give me the values of each columns like:

1st_column =

         65
         203
         36
         207
         251

         79
         13
         104
         170
         66
         
         40
         142
         75
         246
         16

Thank you.

3
  • 1
    Assuming a the array, use a[...,0] Commented Jun 1, 2022 at 21:02
  • 1
    @mozway. I didn't know about ellipsis!!! Great Commented Jun 1, 2022 at 21:03
  • Just add it to your answer if you want Commented Jun 1, 2022 at 21:04

1 Answer 1

1

Try:

>>> m[:, :, 0]
array([[ 65, 203,  36, 207, 251],
       [ 79,  13, 104, 170,  66],
       [ 40, 142,  75, 246,  16]])

As suggested by @mozway, you can use the ellipsis syntax: m[..., 0].

To know more, read How do you use the ellipsis slicing syntax in Python?

You can also flatten your array:

>>> m[:, :, 0].flatten()
array([ 65, 203,  36, 207, 251,  79,  13, 104, 170,  66,  40, 142,  75, 246,  16])
Sign up to request clarification or add additional context in comments.

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.