Code covered by the BSD License

Highlights fromInpaint over missing data in 1-D, 2-D, 3-D,... N-D arrays

5.0

5.0 | 7 ratings Rate this file 97 Downloads (last 30 days) File Size: 4.43 KB File ID: #27994

Inpaint over missing data in 1-D, 2-D, 3-D,... N-D arrays

23 Jun 2010 (Updated 08 May 2013)

Y = INPAINTN(X) computes the missing data in the N-D array X.

File Information
Description

Y = INPAINTN(X) replaces the missing data in X by extra/interpolating the non-missing elements. The non finite values (NaN or Inf) in X are considered as missing data. X can be any N-D array.

Type "help inpaintn" in the Matlab command windows for several examples.

INPAINTN (no input/output argument) runs a 3-D example.

Important note:
----------------
INPAINTN uses an iterative process that converges toward the solution. Y = INPAINTN(X,N) uses N iterations. By default, N = 100. If you estimate that INPAINTN did not totally converge, then increase N: Y = INPAINTN(X,1000);

Example:
--------
%% ---- 2-D data ---- %%
n = 256;
y0 = peaks(n);
y = y0;
I = randperm(n^2);
y(I(1:n^2*0.5)) = NaN; % lose 1/2 of data
y(40:90,140:190) = NaN; % create a hole
z = inpaintn(y,200); % inpaint data
subplot(2,2,1:2), imagesc(y), axis equal off
title('Corrupt data')
subplot(223), imagesc(z), axis equal off
title('Recovered data ...')
subplot(224), imagesc(y0), axis equal off
title('... compared with original data')

------
http://www.biomecardio.com
-----

Acknowledgements

Inpaint Nans, Inpainting Nan Elements In 3 D, and Dct And Dst (+ Inverse) In Arbitrary Dimension inspired this file.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File
Everyone's Tags
Tags I've Applied
10 May 2013

I am getting error
??? Error: File: inpaintn.m Line: 176 Column: 7
Expression or statement is incorrect--possibly unbalanced (, {, or [.

09 May 2013

Hi, thank you for sharing this.

Do you happen to have onion.png, and wind.mat to try the other examples?

30 Oct 2012

hey everyone, the looks great, but unfotunately i've been getting the following error:

Error in ==> inpaintn at
140
y =
RF*idctn(Gamma.*dctn(W.*(x-y)+y))
+ (1-RF)*y;

since i don't feel capable enpugh changing the code on my own, can someone tell me what went wrong?

Thanks alot,

yoav

01 Mar 2012

Very useful script. I will never use matlab extrapolation routines ever again.

01 Mar 2012
08 Nov 2011

Great work, extremely useful, it works out of the box.
Thanks a lot for posting it!

Would there be a simple way to restrict calculations inside a "gating mask"?

12 Oct 2010

I had to interpolate missing 3D geophysical data in order to enable standard filtration process. Inpaint code worked very well for this, the results look pretty well. Using inpaint is easy.
I recommend using this script also for other interested users.

29 Jul 2010

Very useful, works nicely. The only issue is that a couple of additional functions (dctn and idctn) have to be downloaded from another site for this to work

24 Jun 2010

Image toolbox is no longer required.

25 Jun 2010

1) there was a mistake in the 4-D example
2) an initial guess can be now given as an input

08 May 2013

The functions DCTN and IDCTN are now included in INPAITN