• =?UTF-8?B?QXhpcyBhcmd1bWVudHMgZm9yIOKKpSBhbmQg4oqkPw==?=

    From Andrew Sengul@21:1/5 to All on Fri Sep 11 11:39:08 2020
    Has anyone considered implementing axis arguments for ⊥ and ⊤? It would
    be nice if you could encode or decode on a chosen axis. For instance,
    say that you have an 8-bit RGB image represented by an array of integers
    of the shape height×width×3. The first two dimensions are the height and width of the image, the third dimension is 3 units long for the R G B
    values.

    If you want to count the unique colors in the image, you can do it with
    this function:

    countColors ← {⍴∪,(3⍴2*8)⊥3 1 2⍉⍵}

    You have to permute the array to put the RGB dimension first in order
    for the decode to work. What if you could write this instead:

    countColors ← {⍴∪,(3⍴2*8)⊥[3]⍵}

    Is there a reason this hasn't been implemented? For multidimensional
    arguments, there could be a second axis argument to specify which
    dimension of the left argument to use as radix vectors for the right
    argument: A⊥[3;2]B.

    Andrew

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From iamjimfan@gmail.com@21:1/5 to All on Sat Sep 12 01:40:26 2020
    Hi Andrew,

    Might be rank operator would serve the purpose? Example in NARS2000:

    +RGB←?3 4 4⍴256
    213 135 171 165
    131 111 105 81
    43 63 133 231
    162 102 196 168

    233 65 43 216
    74 136 222 119
    54 206 117 149
    78 71 27 95

    50 181 190 129
    220 71 62 248
    58 19 13 231
    32 154 34 118

    {(3⍴2*8)(⊥⍤3)⍵}RGB
    14018866 8864181 11217854 10868865
    8604380 7309383 6938174 5339128
    2831930 4181523 8746253 15177191
    10636832 6703002 12852002 11034486


    Observe that the first pixel has RGB value (213 233 50) and is encoded as 14018866 by above dfn like below:

    256 256 256⊥213 233 50
    14018866


    Jim

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)