# Is it possible to resample grid in such a way so that continuous objects remain continuous?

Suppose I rasterize a rectangle of width 2.5 gridpoints and get the values as shown:

       ===============
|  0  |  1  |  1  | 0.5 |  0  |


Now I resample that raster to a grid which is offset by 0.5 grid resolutions. The formula for resampling with offset by 0.5 pixels: a new pixel's value is the average of the old pixels that intersect the new one:

       ===============
|  0  |  1  |  1  | 0.5 |  0  |
\   / \   /  \  /  \  /
0  | 0.5 |  1  | 0.75| 0.25|  0


Unfortunately, the resampled grid

0  | 0.5 |  1  | 0.75| 0.25|  0
=============   ==


doesn't look like a rasterized rectangle would. Instead, the new grid, if it was a raster of a rectangle, should have been something like this:

0  | 0.5 |  1  |  1  |  0  |  0
===============


Thus the title question: is it possible to resample grid in such a way so that the rasters of continuous objects would remain continuous?

I think the problem is that you've lost the topology upon the first rasterization:

|  0  |  1  |  1  | 0.5 |  0  |


could be

       ===============
|  0  |  1  |  1  | 0.5 |  0  |


or it could be

       ============   ===
|  0  |  1  |  1  | 0.5 |  0  |


So the answer is no. Unless you demand that two objects cannot end in the same grid point, then you can find the first grid point in which it's not zero and the last one in which it's not zero and reconstruct the topology before re-rasterizing. In 2d that would be a bit more complicated but still manageable. But in any case you're going to have to reconstruct the object before re-rasterizing.

• What if the reconstruction algorithm assumes that the shape is as simple as possible? Something like a low-pass filter to minimize higher frequencies, so that resampled raster would resemble more continuous shapes. Also compressed sensing may help. There seem to be ways to pick the simplest of the multiple candidate solutions. – Michael Nov 11 '19 at 20:19