# Is it okay to interpolate between overlapping areas obtained using a sliding window?

I am using a 50x50 pixel sliding window which moves left to right every pixel so that it covers a whole binary image which is about 2000x2000 pixels. In the window, the ratio value of black to white pixels is calculated. I have then been uploading the values into matlab as xyz coordinates with x and y being the centre of each window square and z as the ratio value and interpolating between them to create a meshgrid colormap to help visualise the image.

This is outside the realms of my expertise but I was wondering is it okay to interpolate between these values in matlab as they are not really discrete points but overlapping areas. The colormaps come out looking really good and seem to be a very good representation of the original binary image but it's more the theory that I am having trouble with and I am not having much luck searching.

Is it okay to interpolate overlapping sliding window values in this way using matlab's standard linear interpolation mesh and does anyone have any links to helpful resources regarding this?

Any help would be greatly appreciated!

• Could you share the code so we'll know for sure what you do? – Royi Jul 3 at 18:30

A first suggestion is to use an odd-sized sliding window (say $$w=51$$), so that you can really affect the black/white proportion to the center pixel. An even length can generate a half-pixel bias.
And you have a window sliding by one pixel, therefore you have a black/white proportion for each pixel (except on the borders of the large image, of dimension $$W\times W$$). The resulting picture will be of size $$(W-w+1)^2$$, about $$1950\times 1950$$ here, which already seems to have a large definition for most displays. Hence, I cannot really understand the need to interpolate for visual purposes.
Nevertheless, two contiguous windows share $$w\times (w-1)$$ (sides) or $$(w-1)\times (w-1)$$ (diagonal) pixels in common, so more than 98% or 96 % respectively. Hence, the variations in the proportion should vary quite slowly. Then simple interpolation should work nicely. The problem is to give a meaning to the interpolated values. It should be close to having a window with fractional offsets over the big image, and counting partial pixels.