Skip to content

Commit

Permalink
Revert "Minor ambilight optimization"
Browse files Browse the repository at this point in the history
This reverts commit cd54c42.
  • Loading branch information
zim514 committed Jan 7, 2024
1 parent 2ca9df2 commit 2d630a7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions script.service.hue/resources/lib/imageprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# http://www.screenbloom.com/

from PIL import ImageEnhance

from . import timer


Expand All @@ -22,7 +23,7 @@ def __init__(self):
def img_avg(self, img, min_bri, max_bri, saturation):
dark_pixels = 1
mid_range_pixels = 1
total_pixels = img.width * img.height
total_pixels = 1
r = 1
g = 1
b = 1
Expand All @@ -37,7 +38,10 @@ def img_avg(self, img, min_bri, max_bri, saturation):
# img.save(savepath)
# =======================================================================

for red, green, blue, alpha in img.getdata():
# Create list of pixels
pixels = list(img.getdata())

for red, green, blue, alpha in pixels:
# Don't count pixels that are too dark
if red < self.LOW_THRESHOLD and green < self.LOW_THRESHOLD and blue < self.LOW_THRESHOLD:
dark_pixels += 1
Expand All @@ -51,10 +55,12 @@ def img_avg(self, img, min_bri, max_bri, saturation):
r += red
g += green
b += blue
total_pixels += 1

r_avg = r / total_pixels
g_avg = g / total_pixels
b_avg = b / total_pixels
n = len(pixels)
r_avg = r / n
g_avg = g / n
b_avg = b / n
rgb = [r_avg, g_avg, b_avg]

# If computed average below darkness threshold, set to the threshold
Expand Down

0 comments on commit 2d630a7

Please sign in to comment.