What is the difference in inpaintn and inpaint_nans functions?
조회 수: 12 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
John D'Errico
2023년 6월 6일
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.
추가 답변 (1개)
Image Analyst
2023년 6월 7일
You should also look at the function regionfill in the Image Processing Toolbox, if you have it. Does essentially the same thing.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!