alexwlchan / dominant_colours

A CLI tool to find the dominant colours in an image 🎨
https://dominant-colours.glitch.me
MIT License
89 stars 4 forks source link

question: dominant colours of foreground object #25

Closed abubelinha closed 2 months ago

abubelinha commented 8 months ago

Hi. Nice package! (I am interested in using it from Python, as you already provide a function for that)

Probably off topic question, but maybe you have already thought about this before.

Example images: https://zenodo.org/api/iiif/record:3230911:BR0000012524556.jpg/full/1024,/0/default.jpg https://zenodo.org/api/iiif/record:3613776:TOLI-27785-MAT-01-N14-176.jpg/full/1024,/0/default.jpg https://zenodo.org/api/iiif/record:2869800:BR0000012078165.jpg/full/1024,/0/default.jpg

Is it possible to get dominant_colours of foreground objects, so white or yellow backgrounds are not taken in account? I would even like to remove certain rectangular shapes if possible (colour cards, rules, labels) to concentrate only in the plant colours.

I suppose the answer will involve some other packages but I am interested in your opinion on how to do this.

Thanks a lot in advance @abubelinha

alexwlchan commented 8 months ago

Is it possible to get dominant_colours of foreground objects, so white or yellow backgrounds are not taken in account?

Not with this tool – it looks at the whole image. You could use another tool to delete the colours you're not interested in and then pass it to this tool, but the tool itself isn't doing any filtering of colours.

Alternatively, I wrote a blog post that explains how this works in more detail, which is written in Python – you could adapt that code, and tell it to ignore colours within a certain threshold (e.g. if the colour is a particular shade of white).