For creating materials and textures for the rendering engine Cycles in Blender I want to extract colors from images.
Since Blender's node-system to create materials and texture already has a couple of ways to create and modify
colors and images can have a huge amount of different colors I am looking for a "non destructive way"

transfer between ImageMagick and Blender.
This could go as follows:
Extract all colors from an image
Convert the colors from RGB to HSV (for exmaple)
Sort the colors "somehow"
Group the sorted colors
For each group create a color chart with values (hex preferred).
There are some questions hidden behind this:
1.) How can I create a list of colors from a color image (jpg/png) ?
2.) What is the best way to sort the result (For example: Sort hues and inside the hues the saturation and then the values?)
3.) What groups should be builded?
4.) How can I create handy color charts (not theses over length "one color field x 2000 color fields"-sized color "ramps"...) for
each group?
Additionally: My color vision is not the best....so I need a "academic" way to sort/group things not "look for the most reddish one"

Thank you very much in advance for any help!
Happy and colorful new year!
mcc