title: Get Average of most Similar Colors in color ArrayList with unknown size
body: <p>I'm trying to create a denoiser in Java and now I'm at the state of actually creating the denoiser. The denoiser already knows what is noise and what isn't.</p>
  <p>Now I'm trying to come up with a function that gives me the average color of an ArrayList with the size between 0 and 8. I know how to do this in general but I don't know how to ignore &quot;extreme values (For example, if I have 3 similar Colors in the ArrayList (for example 3 similar red) and a color that is completely different (for example dark blue), the &quot;extreme value&quot; should be ignored because for example, the average of those 3 reds is 0xFD010B and if you include the dark blue, the average turns into 0xFD01FA, which is a &quot;completely different color&quot;.</p>
  <p>How can I write a function that can give me the average color of an undefined amount of similar colors and ignore the &quot;less similar ones?</p>
  <p><strong>Note that I am not allowed to import 3rd party libraries and I am using &quot;pure java&quot; so I can't import gradle or maven dependencies</strong></p>