0
$\begingroup$

I am using the Peak to Correlation Energy (PCE) Metric to measure the similarity between two images using MATLAB. In some cases, the PCE value obtained is NaN. How can I solve this problem?

$\endgroup$
5
  • $\begingroup$ Either your input data is broken, or your algorithm is. The solution is to fix your input data, or your algorithm! So the first step is to validate your input data: is there any infinities, NaNs in there? If so, you'll have to decide what you want your metric to be in that case. $\endgroup$ Feb 20, 2021 at 19:02
  • $\begingroup$ No problem with input data, and no problem with the algorithm, it works well with other examples $\endgroup$
    – Noha
    Feb 20, 2021 at 19:33
  • 2
    $\begingroup$ Clearly, either one of your statements is false, or both. Your algorithm clearly produces undersired output, so start investigating. We can't read your data or your algorithm's implementation from here, that's up to you. $\endgroup$ Feb 20, 2021 at 19:42
  • $\begingroup$ Try dbstop if naninf. That should stop execution when a NaN or inf gets created and you can expect your code and data right when the problem happens. And yes, it's either your data or your algorithm or possible the combination of both. $\endgroup$
    – Hilmar
    Feb 20, 2021 at 20:01
  • $\begingroup$ A NaN (Not a Number) exception happens when a 0/0, or Inf / Inf, or inf - inf is encountered. Check your data for these extreme cases. Note that any value less than a threshold, say 1E-325 for matlab, may be treated as 0 too. $\endgroup$
    – Fat32
    Feb 20, 2021 at 20:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.