Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The Image#phasecor result is kind of ambigous, how to deal with it? #373

Unanswered
Nakilon asked this question in Q&A
Discussion options

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?

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /