2

assume that I have a set of remap such as this: (assume that images are set and the code is working)

for(int i=0; i<NumberOfImages; i++)
{
    remap( inputImage, outImages[i], m_mapX[i], m_mapY[i], CV_INTER_NN );
}

Now I want to find the position of pixel (X,Y) on input image on outputImages (assuming that remap is in a way that any pixel on input image is mapped to only one output image)

The simplest way is to do a search on all m_mapX and m_mapY and look for requested pixel, but it is very time consuming. is there any better way to do so?

Assume that I have a big list of points that I need to convert, so probably creating a reverse map is better, but how to create a reverse map?

Georgy
  • 12,464
  • 7
  • 65
  • 73
mans
  • 17,104
  • 45
  • 172
  • 321
  • 2
    If the remap is 1:1 as you said, then just remap using the inverse of the mapping function used to create the original mapping. – Roger Rowland May 29 '14 at 09:11
  • @RogerRowland: Can be more specific? Any sample code? – mans May 29 '14 at 09:21
  • You didn't show how you created the mapping. Can you give the code that populates `m_mapX` and `m_mapY`? – Roger Rowland May 29 '14 at 09:45
  • 2
    I build a KD-tree for all the points in the map -- if you need to repeat the search many times this works well. Then I used Inverse Distance Weighting so interpolate. See my answer at https://stackoverflow.com/questions/41703210/inverting-a-real-valued-index-grid/46009462#46009462 – wcochran Sep 02 '17 at 19:17
  • Could you solve the problem of an inverse remapping in the end? – Georgy May 22 '18 at 09:28
  • did you try [`cv::invert`](https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#double%20invert(InputArray%20src,%20OutputArray%20dst,%20int%20flags))? – slawekwin May 22 '18 at 11:42
  • @slawekwin how to use it in a remap? – mans May 22 '18 at 12:33
  • @mans I'm not sure, but I would try to invert both map mats and call `remap` again – slawekwin May 22 '18 at 12:45

0 Answers0