I am looking for an efficient image warping function $$f: (\text{image}\in \mathbb R ^{M\times N\times3}, \text{heatMap} \in \mathbb R ^{M\times N}) \to \text{warpedImage} \in \mathbb R ^{M\times N\times3}$$ that would "inflate" certain pixels in a base image, with the amount of inflation represented in a heat map that accompanies the image.
One way to think of this (maybe not the best) is that the heat map represents the amount of "mass" at each original pixel location. The mass "pulls" on the resampling (x', y')
locations, and this pull is counteracted by the tendency of the samples to want to remain at their original (x, y)
locations, and the resampling locations settle at the equilibrium point.
The image below gives a rough idea of what I'm looking for. I generated it using a really rough and very slow method, for generating resampling points which I feed into cv2.remap
. Example code is in this gist.
My questions
- Is this a known transformation with a name?
- Is there an efficient (even if approximate) way to compute the resampling points?