indragiek / DominantColor

Finding dominant colors of an image using k-means clustering
MIT License
960 stars 93 forks source link

macro if guard for Memoization of labValue calculations #19

Closed odeke-em closed 9 years ago

odeke-em commented 9 years ago

Pass in compiler macro definition 'MEMOIZE' to make use of memoization only when required since in some cases it is slower than the unmemoized version.

indragiek commented 9 years ago

Based on findings in #20, it seems to me like the only case where memoization would yield any performance benefit is for large n, and when the image is composed primarily of flat colors (i.e. many pixels of the same color). This sounds like it would be a per image setting, so I'm not sure if it makes sense to make this a compile-time change.

What if it were an optional parameter passed to the function?

odeke-em commented 9 years ago

Great thought, sounds like a plan. I'll spin up a fresh address for this.

odeke-em commented 9 years ago

Actually @indragiek will push up a fresh PR to address the common case.