# Color mapping of difference

I have two arrays A and B. I want to do color mapping of their difference A - B. So far, I am doing this:

1) calculate d = A - B
2) find min / max in d
3) linear mapping of d from (min, max) to (0, 1)
4) convert (0, 1) to color


The problem is, that sometimes, there are noise values in my data. For example, several values in B are too large (like 100 times bigger than the rest) and it leads to enormous difference and increased min or max. After mapping to (0, 1) all other values are "wiped". How can I solve this?

• Are those noise values incorrect data or good data - i.e. do you want to "remove"/ignore them in result or do you want to include them? Aug 7 '16 at 18:37
• @wondra I want to "ignore" them in a sort... ie. I want to show them as max / min error. Aug 7 '16 at 18:49
• Are those data trending or of "continuous" function(read from a sensor)? Aug 7 '16 at 19:12
• @wondra they are continuous in a way.. not read from sensor, but calculated from a discretized function with some added noise and compared with values calculated from the function directly. Aug 7 '16 at 19:53

1. use percentile instead of min/max (e.g. 95/5%, you need to experiment here), with linear mapping clamped to (0,1) range. To do so sort the d array and pick (N - 1) * percentile + 1th member as minimum/maximum, map as normal and clamp r = Min(1.0, Max(0.0, r)) the results in (0,1) range
2. Use non linear mapping, for example the logarithmic scale is often used in scientific applications d = log (d)