Python method for obtaining image color information,
This example describes how to obtain the image color information using python. Share it with you for your reference. The specific analysis is as follows:
The python pil module obtains the color information of each pixel in the image from the image. The following Code demonstrates how to obtain the color information of all vertices and the number of each color.
From PIL import Imageimage = Image. open ("jb51.gif") image. getcolors ()
The returned results are as follows:
Copy codeThe Code is as follows:..., (44, (72, 64, 55,255), (32, (231,208,141,255), (2368, (70, 64, 55,255 )),
(1, (187,210,216,255), (256, (68, 64, 57,255), (592, (67, 80,103,255 )),
(2, (198,204,214,255 ),...
The returned result is a ancestor. The format of each element is as follows.
I hope this article will help you with Python programming.