What is the difference in inpaintn and inpaint_nans functions?

15 Ansichten (letzte 30 Tage)
I can see inpaintn works on all N-D types of array while inpain_nans work on 2d array. Is there any difference than the dimensions both functions can handle? which one is better in interpolating the missing (NaN ) data (or which output is more reliable)?
I used them both to interpolate the NaN values for 2d array. Both are giving different output.
Thank you in advance!

Akzeptierte Antwort

John D'Errico
John D'Errico am 6 Jun. 2023
inpaint_nans is my code, so I know where it is, on the file exchange. Looking there, I see also a code named inpaintn.
If you want to know how inpaintn works, you can read the papers. I won't spend the time to dig up the references, read the papers, and report what that code does. You can do that part. It appears inpaintn uses an iterative algorithm. Sorry, but that is all I can say.
Is it different from inpaint_nans? OF COURSE. Different algorithms, different code. inpaint_nans formulates a sparse linear system of equations to solve the problem, generally based on the idea of formulating an elliptic PDE over the domain of the image. It than solves for the unknown elements based on using the known values as boundary values for the PDE. A virtue of this scheme is it is efficient to solve. There is also an option in inpaint_nans to perform an interpolation that tries to extrapolate as a constant function, for cases where the data lives only on some central part of the array. That method is purely an ad hoc one, but it works fairly nicely and has been used by many.
Note than there is a version of inpaint_nans that applies to 3-d problems. I saw no reason to extend these ideas to 4-d and higher arrays, because I saw no value in writing a code nobody would use.
Is one better than the other? Who knows? But why would you possibly expect them to return the same result? There are infinitely many possible ways to interpolate a set of data, and that is all either of those codes try to do. Every possible interpolant you might chose will yield a qualitatively different result.

Weitere Antworten (1)

Image Analyst
Image Analyst am 7 Jun. 2023
You should also look at the function regionfill in the Image Processing Toolbox, if you have it. Does essentially the same thing.

Produkte


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by