Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>All they are doing is matching histograms. </p> <p>So build a histogram for your images. Normalize the histograms by size of image. A <strong>histogram</strong> is a vector with as many elements as colors. You don't need 32,24, and maybe not even 16 bits of accuracy and this will just slow you down. For performance reasons, I would map the histograms down to 4, 8, and 10-12 bits. </p> <ul> <li>Do a fuzzy <code>least distance compare</code> between the all the 4 bit histograms and your sample colors. </li> <li>Then take that set and do the 8 bit histogram compare. </li> <li>Then maybe go up to a 10 or 12 bit histogram compare with the remaining set. This will be the highest performance search, because you are comparing the total set with a very small number of calculations, to find a small subset. </li> <li>Then you work on the small subset with a higher number of calculations, etc. </li> </ul> <p>The real big trick is to find the best algorithm for matching similar histograms. </p> <ul> <li><p>Start with the distance calculation. In 3 dimensions i think it was: </p> <p>SQRT((x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2)</p></li> </ul> <p>I'm doing this from memory, so look it up to make sure. </p> <ul> <li><p>For your purposes, you will have more than 3 dimensions, so you will have more terms. A 4 bit histogram would have 16 terms, an 8 bit one would have 256 terms, etc. Remember that this kind of math is slow, so don't actually do the <code>SQRT</code> part. If you normalize the size of your images small enough, say down to 10,000 pixels, then you know you only will ever have to do <code>x^2</code> for values 0..10,0000. Pre-calculate a lookup table of <code>x^2</code> where x goes from 0..10,000. Then your calculations will go fast. </p></li> <li><p>When you select a color from the palette, just make a histogram with that color = 10,0000. When select 2, make a histogram with color1=5000, color2=5000 etc. </p></li> <li><p>In the end you will have to add in fudge factors to make the application match the real world, but you will find these with testing.</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload