COPs get the dominant colors of an image.

   2410   12   0
User Avatar
Member
339 posts
Joined: June 2013
Online
There's Quantize COP but I don't want to divide the existing pixels by predefined ranges, instead I would like to extract the dominant colors of an image like Kuler (Adobe Color) does:


Or when a Color Table is generated from an image in Photshop:


Or ImageMagik -colors x:


But I'm unsure about how to go about this. I can see the histogram in the Composite View, but not sure how would I cluster them and sort by occurence:


Am I missing some straight forward way to do this?

Thanks
prb
Edited by probiner - Dec. 16, 2021 19:32:11
User Avatar
Member
670 posts
Joined: Sept. 2013
Online
Hi Probiner,

not sure whether this is acceptable for your workflow but I have used the cluster point SOP for this.
Edited by Konstantin Magnus - Dec. 17, 2021 08:45:00

Attachments:
cluster_colors.hiplc (564.1 KB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
339 posts
Joined: June 2013
Online
Konstantin Magnus
Hi Probiner,

not sure whether this is acceptable for your workflow but I have used the cluster point SOP for this.

Thanks. I've looked into and I'm noticing that while it does an interesting job at posterizing, the issue I notice with a lot of solutions is that once you lower the amount of "buckets" is when you start to see some issues:

I would expect blue to be dominant while reducing the number of clusters but seems that red gets the cake.

With Adobe Color I also don't get the "importance" of each swatch.


I've been using Attribute Promote Median or Mode but I was looking for something that would offer a more "statistical analysis approach", eheh...
Edited by probiner - Dec. 16, 2021 21:24:24
User Avatar
Member
475 posts
Joined: July 2005
Offline
Hi,

maybe you calculate some attributes for each cluster and use these attributes to sort the clusters. You can take for example the deviation on a cluster. If this value is low, the colors are close together. If you decrease the number of clusters, this value will probably raise and gives less good approximation. Here is an example (modification of Konstantins file).

Attachments:
cluster_colors_measure_clusters.hipnc (581.0 KB)

User Avatar
Member
670 posts
Joined: Sept. 2013
Online
Ok, I assume you have already checked the fuse SOP then.
Edited by Konstantin Magnus - Dec. 17, 2021 08:45:31

Attachments:
fuse_colors_2.hipnc (1.7 MB)
fuse_colors.png (146.8 KB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
339 posts
Joined: June 2013
Online
Aizatulin
Hi,

maybe you calculate some attributes for each cluster and use these attributes to sort the clusters. You can take for example the deviation on a cluster. If this value is low, the colors are close together. If you decrease the number of clusters, this value will probably raise and gives less good approximation. Here is an example (modification of Konstantins file).

Interesting addition! It's actually interesting to look at the "streaks" of color when you do @P = @Cd ; and you can almost see the clusters very clearly then. Thanks for the file!

Konstantin Magnus
Ok, I assume you have already checked the fuse SOP then.
I didn't and you're very right, I should have tried, ehehe That looks great, really. I guess it didn't come to mind because one will not set the amount of buckets but a Threshold. Thanks for the file!

Cheers
prb
User Avatar
Member
7770 posts
Joined: Sept. 2011
Online
probiner
Aizatulin
Hi,

maybe you calculate some attributes for each cluster and use these attributes to sort the clusters. You can take for example the deviation on a cluster. If this value is low, the colors are close together. If you decrease the number of clusters, this value will probably raise and gives less good approximation. Here is an example (modification of Konstantins file).

Interesting addition! It's actually interesting to look at the "streaks" of color when you do @P = @Cd ; and you can almost see the clusters very clearly then. Thanks for the file!

Konstantin Magnus
Ok, I assume you have already checked the fuse SOP then.
I didn't and you're very right, I should have tried, ehehe That looks great, really. I guess it didn't come to mind because one will not set the amount of buckets but a Threshold. Thanks for the file!

Cheers
prb

Something to try would be doing the snapping in a different color space, rather than linear rgb. Maybe try Lab or Y'uv?
User Avatar
Member
339 posts
Joined: June 2013
Online
jsmack
probiner
Aizatulin
Hi,

maybe you calculate some attributes for each cluster and use these attributes to sort the clusters. You can take for example the deviation on a cluster. If this value is low, the colors are close together. If you decrease the number of clusters, this value will probably raise and gives less good approximation. Here is an example (modification of Konstantins file).

Interesting addition! It's actually interesting to look at the "streaks" of color when you do @P = @Cd ; and you can almost see the clusters very clearly then. Thanks for the file!

Konstantin Magnus
Ok, I assume you have already checked the fuse SOP then.
I didn't and you're very right, I should have tried, ehehe That looks great, really. I guess it didn't come to mind because one will not set the amount of buckets but a Threshold. Thanks for the file!

Cheers
prb

Something to try would be doing the snapping in a different color space, rather than linear rgb. Maybe try Lab or Y'uv?

Yeah I did try that, although I didn't try with snapping since the values in other spaces can be very wild, so I retook Magnus setup with the clustering and tried a few color spaces with the function ctransform() in VEX. I've found HSV one is broken, so I already reported the bug.
Scene attached for example. I liked the results I got with Lab and hsl on my images.



Still not COPs, but hey..

Cheers
prb
Edited by probiner - Dec. 17, 2021 14:55:54

Attachments:
PRB_ctransform.hipnc (1.7 MB)

User Avatar
Member
670 posts
Joined: Sept. 2013
Online
If you absolutely need COPs, I read numpy does clustering, too.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
670 posts
Joined: Sept. 2013
Online
Btw. I found fusing and Lab to be alright.

Attachments:
fuse_colors_Lab.hipnc.zip (2.5 MB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
339 posts
Joined: June 2013
Online
Konstantin Magnus
Btw. I found fusing and Lab to be alright.
Yeah looks very nice. I guess I can give fuse another try, but the reason I'm shying away from it is that I can't define the amount of clusters.

Thank you everyone for all the ideas!
prb
User Avatar
Member
670 posts
Joined: Sept. 2013
Online
The nearpoint()-function can also be used to index colors ie. based on a reference image.
Edited by Konstantin Magnus - Dec. 19, 2021 10:34:34

Attachments:
color_posterization.hiplc (181.0 KB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
339 posts
Joined: June 2013
Online
Konstantin Magnus
The nearpoint()-function can also be used to index colors ie. based on a reference image.
Effect looks stylish but it does deviate from the original colors.

Also nice bit about using directly an URL for the Attribute from map

Cheers
prb
  • Quick Links