Screenshot colour averaging of rectangles

后端 未结 3 944
萌比男神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:42

    A quick win could be to use a resize operation (in PIL) (you may use simple interpolation for speed) to a 5x5 image instead of averaging the regions, e.g.:

    myimg = ImageGrab.grab()
    resized = myimg.resize((5, 5), Image.NEAREST) 
    

    This should yield approximately the same effect as doing the averaging work yourself.

    Not really sure about the speed of PIL's ImageGrab (and how it compares to autopy) though, but it's easy enough to try and find out.

提交回复
热议问题