Because of array depth issues in PHP, receiving this array from Python becomes truncated with an ellipsis ("..."). I'd like to process the array in Python before returning back to php.
Clarification: I need to maintain the inner sets [135, 121, 81]. These are R, G, B values and I'm tying to group sets that occur more than once. Values in sets need to maintain [1, 2, 3] sequence, NOT [1,2,3,4,5,6,7,8] as some answers have suggested below.
How would you simplify this 3D numpy.ndarray
to a collection of unique RGB triples?
Here is how the array is printed by Python:
[[[135 121 81]
[135 121 81]
[135 121 81]
...,
[135 121 81]
[135 121 81]
[135 121 81]]
[[135 121 81]
[135 121 81]
[135 121 81]
...,
[135 121 81]
[135 121 81]
[135 121 81]]
[[ 67 68 29]
[135 121 81]
[ 67 68 29]
...,
[135 121 81]
[135 121 81]
[135 121 81]]
...,
[[200 170 19]
[200 170 19]
[200 170 19]
...,
[ 67 68 29]
[ 67 68 29]
[ 67 68 29]]
[[200 170 19]
[200 170 19]
[200 170 19]
...,
[116 146 15]
[116 146 15]
[116 146 15]]
[[200 170 19]
[200 170 19]
[200 170 19]
...,
[116 146 15]
[116 146 15]
[116 146 15]]]
Here is the code that I have attempted:
def uniquify(arr)
keys = []
for c in arr:
if not c in keys:
keys[c] = 1
else:
keys[c] += 1
return keys
result = uniquify(items)