Under review

Heatmap interpolation color

Oystein Bjorke 10 years ago updated 10 years ago 3
This discussion was imported from CodePlex

AvanDiepen wrote at 2014-01-16 11:43:

When I create a heatmap with say +10 is red, 0 is green and -10 is blue, the interpolated color of two adjacent cells of +10 and -10 is not green (0). I expect that the color between these two cells is green! Or is there a setting to change this behaviour?

objo wrote at 2014-01-17 07:59:

Interesting :) I think this is a bug when Interpolate = true.
The heat map is rendered by interpolating a bitmap, and this is not the same as the interpolation of the palette.
At the center of each pixel it will be correct, but between pixels may be wrong.

It can be reproduced by
        [Example("D501409: Interpolation Issue")]
        public static PlotModel InterpolationIssue()
        {
            var data = new double[2, 3];
            data[0, 0] = -10;
            data[0, 1] = 10;

            var model = new PlotModel("HeatMapSeries");
            model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right, Palette = new OxyPalette(OxyColors.Red, OxyColors.Green, OxyColors.Blue) });

            var hms = new HeatMapSeries
            {
                CoordinateDefinition = HeatMapCoordinateDefinition.Edge,
                X0 = 0,
                X1 = 2,
                Y0 = 0,
                Y1 = 3,
                Data = data,
                Interpolate = true,
                LabelFontSize = 0.2
            };
            model.Series.Add(hms);
            return model;
        }
Does anyone know how this can be fixed?

AvanDiepen wrote at 2014-05-15 08:07:

Someone found a solution for this 'bug'?
Hello,

I have (of course) the same issue.
In my opinion, the only way to correct this is to modify the source code (eventually by adding an "InterpolationMode" enum if you want to keep the bitmap interpolation mode (but it really seems wrong to me)).
Is this planned ?

Olivier
And, moreover, I think this can be fixed by interpolating the values of the map for each future pixel. You will then get a giant matrix of values (of the size of the desired bitmap). Then, and only then, you can convert it to a bitmap. (there will be then no need to interpolate the bitmap because every pixel will be defined).
It certainly is not optimal, but it should work
.
Olivier
Under review
Good idea! I have added issue #343!