I'm trying to understand the algorithms behind DominantColors[]. Unfortunately Trace[] and PrintTrace[] don't help. For example, running the PrintTrace below will crash Mathematica:

(Don't run to the following code)

img = ExampleData[{"TestImage", "Lena"}];
PrintTrace @ DominantColors[img]

And the same for Trace:

enter image description here

Going the other way, I then tried using GeneralUtilities's PrintDefinitions[] function. But this really doesn't help much either as there is an huge amount of indirection, involving many undocumented functions including:


Any other suggestions?

  • 1
    $\begingroup$ Have you tried clicking on those functions in the PrintDefinitions window? Or directly running PrintDefinitions on them? $\endgroup$ – Batracos Mar 7 '18 at 15:43
  • $\begingroup$ @Batracos yes but it is very confusing! I tired to pull out all the necessary definitions into a single notebook in order to step through the code, but there are too many deep roots! $\endgroup$ – M.R. Mar 8 '18 at 2:46
  • 1
    $\begingroup$ Probably you can use TraceToFile from this question. $\endgroup$ – rhermans Jun 18 '18 at 21:48
  • $\begingroup$ What is PrintTrace? $\endgroup$ – Chip Hurst Sep 1 '18 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.