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

LNCC similarity result is out of range of [0,1] when images have large portion of zero valued area #132

Open
lintian-a opened this issue Nov 7, 2019 · 1 comment
Assignees
Labels

Comments

@lintian-a
Copy link

LNCC output will be out of the range [0,1] when the images have large area with zero value.

Steps to reproduce:

  1. Generate Data:
params = pars.ParameterDict()
params['square_example_images']['len_s'] = 10
params['square_example_images']['len_l'] = 30
I0,I1,spacing = EG.CreateSquares(dim=3, add_noise_to_bg=False).create_image_pair(np.array([64, 64, 64]),params=params)
  1. Register with LNCC similarity.
params['model']['registration_model']['type'] = "svf_vector_momentum_map" 
params['model']['registration_model']['similarity_measure']['type'] = "lncc"
opt = MO.SimpleSingleScaleRegistration(I0,
                                       I1,
                                       spacing,
                                       sz,
                                       params,
                                       compute_inverse_map=False)
opt.register()

The log shows as follows:
0-Tot: E=099.4140 | simE=099.4140 | regE=000.0000 | optParE=000.0000 | relF= n/a |
0-Img: E=099.4140 | simE=099.4140 | regE=000.0000 |

@lintian-a lintian-a added the bug label Nov 7, 2019
@xhs400
Copy link
Contributor

xhs400 commented Nov 7, 2019

I am pretty sure this is caused by the floating-precision, although I didn't run your case. Issues are with some background area, you will have a division between two small values. This would not happen in NCC unless the entire image is a constant.

To workaround, you can try:
1.use double instead of float in the LNCC. (may fix the problem perfectly)
2. Clamp the value to (0,1) in the similarity measure.
for example:
image
add "torch.clamp(lncc, min=0.0, max=1.0) " before "1-lncc.mean()"

Of course, if others have better solution, welcome to share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants