0

I have a quick question regarding rigid transformation between two 2D numpy arrays. I have tried several methods from opencv but none return interesting result and I guess that my problem is not too complicated, so maybe I am looking in the wrong direction and I will need your precious help.

So I have two 2D numpy arrays of the same size filled with 0 and 1, like this one:

[[0, 0, 0, 1, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0, 0, 1],
[1, 0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 1, 0]]

When there is a 1 it means that I have a point at location (x,y) and 0, means there is nothing. So at least, I can consider this matrix as a cloud of points that can be drawn in a graph.

I have a second array with same size as the previous one but where the 1 elements have been translated in one direction (all the 1 elements are translated in the same direction and with egal number of translations). It means that some of the 1 element will be out of the array, while some other 1 elements will appear in the free space leaves by the translation, for example second matrix can look like this :

[[1, 0, 1, 0, 1, 0, 1, 0, 1],
[[0, 0, 0, 1, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0, 0, 1],
[1, 0, 0, 1, 0, 0, 1, 0, 0]]

So first matrix has been translated down of 1 row. First row is new and the three rows below are common in the two matrix. The last row disappears in the second matrix because of the translation. Translation can be in any direction, but it is a rigid transformation (keep distance between points).

Is there a clever method to estimate the best warp matrix between this two arrays ?

Thanks a lot for your help

Watchdog
  • 9
  • 1
  • https://xyproblem.info/ -- don't abstract so much that you're hiding your real problem. -- if you have points, and you made these "pictures" from the points, you _should_ work with points instead... and then the problem is to align point clouds, and there's the ICP algorithm for that – Christoph Rackwitz Sep 20 '22 at 12:38
  • Thanks a lot Christoph. Yes you are right, this can be considered as cloud of points registration. I have read several post regarding the ICP algo and it is said that it tolerates small transformation but is bad for big transformation. I also did not find any implemention of the ICP algo in python... – Watchdog Sep 20 '22 at 13:02
  • if you know it's purely translation, just do autocorrelation, i.e. convolve. you still haven't revealed that this _really_ is. you're just presenting a severely abstracted toy example, not your real data, or the real application. have you considered that your approach may not be the most suitable to whatever you're trying to achieve? – Christoph Rackwitz Sep 20 '22 at 13:22
  • There are still many open questions, e.g.: (1) How often do you take photos? Are the images nearly the same with just a small change? This will be much easier, of course. (2) Can you predict the direction of movement, e.g. always down? (3) Is this really always a translation or do you also take photos in circumpolar direction, so you have to approximate a rotation? (4) What is the resolution of the images? How close are the stars? (5) Can you give us at least two real life photos and your code so far? – Markus Sep 20 '22 at 15:46
  • Is this what you are looking for? https://stackoverflow.com/a/24769222/18667225 – Markus Sep 20 '22 at 15:52

0 Answers0