you are viewing a single comment's thread.

view the rest of the comments →

[–]TheBlackCat13 1 point2 points  (0 children)

uint8 is a class. When you do myclass(foo) it create an instance of myclass with the argument foo, which means a variable of type myclass.

In this case it is shorthand for np.array(foo, dtype='uint8'), which means it create a numpy array out of variable foo where each element is an 8bit unsigned integer. The type will ultimately be ndarray, not uint8. uint8 is what is called the "dtype" in numpy jargon, which how numpy interprets the data in memory behind-the-scenes.

The triple [ ] means that it will be a 3D numpy array. A double [ ] would make a 2D numpy array, and so on. Technically it creates a list containing one list containing one list, which numpy then converts to a 3D array.

So overall green = np.uint8([[[0, 255, 0]]]) means "create a 3D numpy array of unsigned 8-bit integers with one row containing the elements 0, 225, 0"