InsightSoftwareConsortium/ITKMontage

RefineMontage OptimizeTiles compute solutions get nan sometimes

Closed this issue · 8 comments

RefineMontage OptimizeTiles get out of the outlierExists while loop in first Iteration, as the solutions second dimension is -nan(ind) then residuals second dimension is also -nan(ind), maxCost is 0 less than sqrtDim, so the while loop ends.
image

the incorret solutions it got:

Iteration 1  solutions -2.66924e-05    -nan(ind)
    -7.33366    -nan(ind)
    -26.4369    -nan(ind)
    -40.3492    -nan(ind)
    -49.3753    -nan(ind)
    -55.0427    -nan(ind)
    -21.3801    -nan(ind)
    -8.66447    -nan(ind)
    -24.1475    -nan(ind)
     -35.077    -nan(ind)
    -43.1564    -nan(ind)
    -50.6843    -nan(ind)
    -18.3034    -nan(ind)
    -24.4699    -nan(ind) 
    ...

the configure file only has one dimension as a result

# Tile coordinates are in index space, not physical space
dim = 2

flat_000_000.jpg;;(2.6692372557590716e-5, )
flat_001_023.jpg;;(2647.3336577415466, )
flat_002_000.jpg;;(5306.436941146851, )
flat_003_023.jpg;;(7960.349170684814, )
...

here is the full output:
result_fail.txt

but if i try the RefineMontage several times, it can compute success with a correct solutions sometimes

Iteration 1  solutions -2.66924e-05 -1.22878e-05
    -7.33366      10.0892
    -26.4369      8.30614
    -40.3492      8.86617
    -49.3753      11.6031
    -55.0427       24.366
    -21.3801      40.3239
    -8.66447      44.6249
    -24.1475       51.982
     -35.077      48.8064
    -43.1564      56.1388
    -50.6843      63.2872
    -18.3034      75.5062
    -24.4699      77.9727
   ...

here is the full success output:
result_success.txt

i wonder why the results differ on the same dataset, is there any suggestions about how to keep it compute correct stable
both 5.2.1 and 5.3.0 has the same problem as i test

If you share a case (preferably small) which causes NaNs to appear, I could take a look.

@dzenanz thank you sir, this is the minimal dataset i get

There is no issue running this on my computer. The results are attached. itk_test_data_result.zip (the image is rescaled down to 5% of original size, as original was 260MB big).

Oh, on the fifth or so run, I ran into the same problem.

I think the problem comes from this line:

residual /= m_CandidateConfidences[candidateIndex][0];

when the confidence is exactly equal to zero.

@zhusihan-python can you check whether #221 fixes the problem for you?

@zhusihan-python did you check #221?

@zhusihan-python did you check #221?

sor for the late reply. the nan result didn't shown any more as i test in the last few weeks.