Ejemplo n.º 1
0
	def compress(self,numberOfColors=256):
		colorCube = ColorCube(numberOfColors)
		for p1 in self.pixels:
			color = colorCube.getClusterIn(p1.getRGB())
			print(p1.getRGB(),end="")
			print("->",end="")
			print(color)
Ejemplo n.º 2
0
def get_dominant_frame_color(method, file):
    """Extract the dominant color for a given file."""
    if method == "colortheif":
        from colorthief import ColorThief
        color_thief = ColorThief(file)
        return color_thief.get_color(quality=1)
    
    elif method == "colorcube":
        sys.path.append('ColorCube/Python')
        from ColorCube import ColorCube
        from PIL import Image
        cc = ColorCube(bright_threshold=0.0)
        img = Image.open(file)
        colors = cc.get_colors(img)
        return colors[0]
    
    elif method == "colorweave":
        from colorweave import palette
        p = palette(path=file, n=1)
        return hex_to_rgb(p[0])
        
    else:
        return average_image_color(file)
Ejemplo n.º 3
0
# Importation des librairies utiles
from ColorCube import ColorCube
from PIL import Image

# Instanciation de l'objet color cube, en précisant d'éliminer les couleurs trop proches du blanc
cc = ColorCube(avoid_color=[255, 255, 255])

# Chargement d'une image et redimensionnement à la taille (100,100) pour
# rendre le temps de traitement plus rapide
# En diminuant la taille, on itensifie aussi la perception des couleurs dominantes
image = Image.open("images/lego-yellow-brick.jpg").resize((100, 100))

# Traitement de l'image et extraction des couleurs
colors = cc.get_colors(image)

# Affichage des composantes de la couleur dominante
print("couleur dominante R : {}".format(colors[0][0]))
print("couleur dominante G : {}".format(colors[0][1]))
print("couleur dominante B : {}".format(colors[0][2]))
from bs4 import BeautifulSoup
import textwrap
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
from lib_tft24T import TFT24T
import RPi.GPIO as GPIO
from time import sleep
import apds9960 as GestureSensor
from apds9960_constants import *
from gpiozero import DigitalInputDevice
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
from ColorCube import ColorCube
from PIL import Image
cc = ColorCube(avoid_color=[255, 255, 255])
# sudo pip3 install google_images_download
# http:www.github.com/hardikvasa/google-images-download  pour un lien vers la doc de l'API
from google_images_download import google_images_download

import spidev

DC = 22
RST = 25
LED = 23

TFT = TFT24T(spidev.SpiDev(), GPIO, landscape=False)

# Initialisation de l'écran
TFT.initLCD(DC, RST, LED)