Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should KDE performs on the two images separately? #34

Closed
nnop opened this issue Apr 15, 2024 · 7 comments
Closed

Should KDE performs on the two images separately? #34

nnop opened this issue Apr 15, 2024 · 7 comments

Comments

@nnop
Copy link

nnop commented Apr 15, 2024

Thanks for the great method which almost solved the WxBS problem.

I noticed symmetric matching is the default.

symmetric = True

and KDE is performed on all sampled matches from (H, 2*W) warp results:

RoMa/roma/models/matcher.py

Lines 475 to 486 in 5052229

matches, certainty = (
matches.reshape(-1, 4),
certainty.reshape(-1),
)
expansion_factor = 4 if "balanced" in self.sample_mode else 1
good_samples = torch.multinomial(certainty,
num_samples = min(expansion_factor*num, len(certainty)),
replacement=False)
good_matches, good_certainty = matches[good_samples], certainty[good_samples]
if "balanced" not in self.sample_mode:
return good_matches, good_certainty
density = kde(good_matches, std=0.1)

The positions and warping of image1 and image2 should be independent.
So, should KDE performs on the two images separately?

Another question:
Since, the sampling is from symmetric matching, will the results contain many near duplicated matches?

@Parskatt
Copy link
Owner

Kde is typically run after sparse sampling, and works on 4D coords. Symmetric shouldn't affect it.

@Parskatt
Copy link
Owner

Regarding duplicates, yes this is likely.

@nnop
Copy link
Author

nnop commented Apr 16, 2024

Kde is typically run after sparse sampling, and works on 4D coords. Symmetric shouldn't affect it.

Don't know if I described clear.
I mean the 4D coords in the other image shouldn't be taken into account for supporting. It not the problem of symmetric.
4D coords in the first (H, W) and the second (H, W) part are both in range [-1, 1].
Wouldn't directly computing the pairwise distance mistake the samples of the other image into account?

scores = (-torch.cdist(x,x)**2/(2*std**2)).exp()

@Parskatt
Copy link
Owner

I'm not sure I understand the question unfortunately. Why would we not want to take the other coordinates into account?
We simply view the correspondences as 4D vectors. We have a bunch of those, and we want to reduce sampling in regions where we have high density. It doesn't matter where these vectors come from.

@nnop
Copy link
Author

nnop commented Apr 16, 2024

Suppose the red dot and the green dot have the same coordinates in Image 1 and 2. Then the matches represented by the yellow line and the blue line should be equal in the 4D match space. Therefore, does the yellow match act as an inhibition to the blue match?

@Parskatt
Copy link
Owner

No, because all corresps are from A to B even (we switch the ordering internally)

@nnop
Copy link
Author

nnop commented Apr 16, 2024

That clears it up for me, thank you for clarifying my misunderstanding of this representation!

@nnop nnop closed this as completed Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants