GithubHelp home page GithubHelp logo

lancegin / haishoku Goto Github PK

View Code? Open in Web Editor NEW
275.0 275.0 28.0 945 KB

A development tool for grabbing the dominant color or representative color palette from an image

License: MIT License

Python 100.00%
design-tools dominant-colors palette pillow python3

haishoku's People

Contributors

hungryfour avatar lancegin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

haishoku's Issues

input numpy array or PIL.Image rather than img_path

Dear LanceGin,

Thank you for your wonderful work. I want to know if there is a way to input numpy array or PIL.Image rather than img_path? I already preprocess my images, I dont want to save one image to jpg then reload it.

Best Wishes,

Alex

Need to convert to RGB if image is with indexed palette

from haishoku.haishoku import Haishoku
palette = Haishoku.getPalette( some_gif_image )
palette = Haishoku.getPalette(image_path)
  File "/usr/lib/python3.7/site-packages/haishoku/haishoku.py", line 129, in getPalette
    colors_mean = Haishoku.getColorsMean(image_path)
  File "/usr/lib/python3.7/site-packages/haishoku/haishoku.py", line 65, in getColorsMean
    grouped_image_colors = alg.group_by_accuracy(sorted_image_colors)
  File "/usr/lib/python3.7/site-packages/haishoku/alg.py", line 54, in group_by_accuracy
    rgb_maximum_json = rgb_maximum(sorted_tuple)
  File "/usr/lib/python3.7/site-packages/haishoku/alg.py", line 23, in rgb_maximum
    r_sorted_tuple = sorted(colors_tuple, key=lambda x:x[1][0])
  File "/usr/lib/python3.7/site-packages/haishoku/alg.py", line 23, in <lambda>
    r_sorted_tuple = sorted(colors_tuple, key=lambda x:x[1][0])
TypeError: 'int' object is not subscriptable

also just a sidenote, from haishoku.haishoku import Haishoku looks quite awkward, you could import Haishoku in __init__.py, so it can be used as from haishoku import Haishoku

Will you take pull requests?

This is a cool idea. Are you interested in taking any pull requests? I've reworked the haishoku class so it's a bit more object-oriented by having methods on instances rather than on the type itself.

【BUG】部分黑白图片导致致命错误

这个列表的所有图片都会出现错误,全部是黑白图片,但似乎不是所有黑白图片都会出现问题
All the pictures in this list will have errors, all black and white pictures, but it seems that not all black and white pictures will have problems.
image_list = ["https://store.playstation.com/store/api/chihiro/00_09_000/container/HK/ch/999/HP9000-CUSA02417_00-GONETOTHERAPTURE/1561603730000/image?w=432&h=432", "https://store.playstation.com/store/api/chihiro/00_09_000/container/HK/ch/999/EP4034-CUSA03094_00-ASIA000000000000/1555304545000/image?w=432&h=432", "https://store.playstation.com/store/api/chihiro/00_09_000/container/HK/ch/999/UP1164-CUSA13422_00-ASIA000000000000/1554792500000/image?w=432&h=432", "https://store.playstation.com/store/api/chihiro/00_09_000/container/HK/ch/999/UP9000-CUSA00695_00-ASIAFULLGAME0000/1561601024000/image?w=432&h=432", "https://store.playstation.com/store/api/chihiro/00_09_000/container/HK/ch/999/HP9000-CUSA12613_00-DEATHSTRAND00001/1561107092000/image?w=432&h=432", "https://store.playstation.com/store/api/chihiro/00_09_000/container/HK/ch/999/HP2005-CUSA14358_00-PATOBOXASIA00000/1560504014000/image?w=432&h=432"]

Traceback (most recent call last):
File "/Users/Phishion/Desktop/Haishokutest.py", line 12, in
dominant = Haishoku.getDominant(value)
File "/usr/local/lib/python3.7/site-packages/haishoku/haishoku.py", line 119, in getDominant
colors_mean = Haishoku.getColorsMean(image_path)
File "/usr/local/lib/python3.7/site-packages/haishoku/haishoku.py", line 65, in getColorsMean
grouped_image_colors = alg.group_by_accuracy(sorted_image_colors)
File "/usr/local/lib/python3.7/site-packages/haishoku/alg.py", line 54, in group_by_accuracy
rgb_maximum_json = rgb_maximum(sorted_tuple)
File "/usr/local/lib/python3.7/site-packages/haishoku/alg.py", line 23, in rgb_maximum
r_sorted_tuple = sorted(colors_tuple, key=lambda x:x[1][0])
File "/usr/local/lib/python3.7/site-packages/haishoku/alg.py", line 23, in
r_sorted_tuple = sorted(colors_tuple, key=lambda x:x[1][0])
TypeError: 'int' object is not subscriptable

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.