pythonarraysnumpy

What is np.uint8?


Is np.uint9 possible? Why use it?

red_lower = np.array([136, 87, 111], np.uint9)

Solution

  • https://numpy.org/doc/stable/reference/arrays.scalars.html#unsigned-integer-types

    class numpy.ubyte[source]
    Unsigned integer type, compatible with C unsigned char.
    
    Character code
    'B'
    
    Alias on this platform (Linux x86_64)
    numpy.uint8: 8-bit unsigned integer (0 to 255).
    

    Most often this is used for arrays representing images, with the 3 color channels having small integer values (0 to 255).