Screenshot colour averaging of rectangles

后端 未结 3 988
萌比男神i
萌比男神i 2021-02-06 04:01

I wrote a quick python script to return the average colour of rectangles surrounding the perimeter of my screen. (The end goal here is to have RGB LED strips surrounding my moni

3条回答
  •  眼角桃花
    2021-02-06 04:59

    To speed up a resize operation you can do it in two steps. Use NEAREST for the first one to cut down the number of pixels in the fastest way possible, then ANTIALIAS to merge those into a representative sample. It's equivalent to the step size you experimented with earlier, done with PIL functions.

    PIL.ImageGrab.grab().resize((150, 100), PIL.Image.NEAREST).resize((15, 10), PIL.Image.ANTIALIAS)
    

提交回复
热议问题