Say I have an image of 2x2
pixels named image_array
, each pixel color is identified by a tuple of 3 entries (RGB), so the shape of image_array
is 2x2x3
.
I want to create an np.array c
which has the shape 2x2x1
and which last coordinate is an empty set.
I tried this:
import numpy as np
image = (((1,2,3), (1,0,0)), ((1,1,1), (2,1,2)))
image_array = np.array(image)
c = np.empty(image_array.shape[:2], dtype=set)
c.fill(set())
c[0][1].add(124)
print(c)
I get:
[[{124} {124}]
[{124} {124}]]
And instead I would like the return:
[[{} {124}]
[{} {}]]
Any idea ?