-
Notifications
You must be signed in to change notification settings - Fork 62
-
I'm trying to use #pharecor
again like I did for another project ~2 years ago but I still fail to understand the result of this function.
For example, here are two images:
0002
0003
If we compare under names a2
and a3
:
require "ruby-vips" require "mll" ... Vips::Image.bandrank(MLL::nest_list[ a2.phasecor(a3).scaleimage, 5, ->_{ _.rank(20,20,399)-10 } ].to_a, index: 4).write_to_file "temp.png"
temp
we can interpretate this as "the a3
matches a2
if we shift it right and a bit down". Now what if we swap them?
Vips::Image.bandrank(MLL::nest_list[ a3.phasecor(a2).scaleimage, 5, ->_{ _.rank(20,20,399)-10 } ].to_a, index: 4).write_to_file "temp.png"
temp
we see that the resulting image was reflected, ok, then we assume there is the "negative axis quarter". Does it mean that we shift only up to half of the image size? Let's test a bigger shift:
0001
0005
Vips::Image.bandrank(MLL::nest_list[ a1.phasecor(a5).scaleimage, 5, ->_{ _.rank(20,20,399)-10 } ].to_a, index: 4).write_to_file "temp.png"
temp
nope! it's detected the shift farther than a half.
Now the question is: How do we recognize it's a shift "3/4 right and a bit down" and not "1/4 left and a bit down"?
Previously when I faced this problem I was taking 4 variants [dx,dy], [dx-width,dy], [dx,dy-height], [dx-width,dy-height]
, cropping out the intersecting part and used an heuristic such as .min_by{ ... (a_crop - b_crop).avg }
but isn't there a better way?
Beta Was this translation helpful? Give feedback.