I was looking up a way to find pixels values over the three channel of a segmentation class image to replace them with their categories,and i found this code which works fine, but i have trouble understanding what the * operator is used for exactly, my understanding is that it simply unpack lists and dictionary in order,but why doesnt it work without it. Only thing i can see is that the problem comes from the limited number of argument on np.logical_and, but why does unpacking sunddendly makes it work. So yeah if anyone has some intuition i'd apreciate it, here is the code from the link:
>>> pixel_class_dict = {1: [18, 19, 20], 2: [9,10,11]}
>>> a = np.arange(2*4*3).reshape(2,4,3)
>>> b = np.zeros((a.shape[:2]), dtype=np.int)
>>> for pixel_class, pixel_values in pixel_class_dict.items():
#here is the line i have trouble with
... mask = np.logical_and(*(a[..., channel] == pixel_values[channel]
... for channel in range(a.shape[-1])))
... b += pixel_class*mask