How Can I fill in holes in a grid/data set using bin averaging or LaGrange Interpolating Polynomials?

10 次查看(过去 30 天)
Hi Everyone,
I've been trying to figure out a way to bin average a 2D set of data to achieve a high enough grid resolution. For example, if I have an 8x8 chessboard with the value of every other cell known, I want to interpolate or average the existing data to populate the unknown cells. If less data is known (i.e. every 6th cell known), this process can just be repeated until the entire board is filled. Ideally it will be a 5 (or even 9) point method where the unknown cell in question obtains its value from an average of the surrounding 4 cell values (up, down, left, right).
Does anyone know of or have any suggestions of what type of command or process would be the best way to go about doing this? I eventually want to use something more accurate like LaGrange Interpolating polynomials but figured this would be the best way to start.
I will update my post with code when I get home, but any and all help is appreciated! Thank you!

采纳的回答

John D'Errico
John D'Errico 2014-1-24
Use a tool designed to fill in missing values exactly as you have. inpaint_nans is on the file exchange.
Just put NaNs in for the elements you need interpolated.

更多回答(1 个)

Image Analyst
Image Analyst 2014-1-22
No, definitely don't do Lagrange. Do you know what happens when the order gets too high? You could use interp1(). For the situation you described, I'd use a 2D median filter (medfilt2(), if you have the Image Processing Toolbox), or a Savitzky-Golay filter (sgolay() if you have the Signal Processing Toolbox). If it's salt and pepper noise, I have a demo for that that uses a modified median filter, which applies the median filter only at those locations where the value of the pixel is replaced by the median only if it's very much different than the median. I you or anyone else wants that demo, it's attached, as well as a Savitzky-Golay demo. Savitky-Golay fits a polynomial to data in a sliding window. I also have a color version of the salt and pepper noise removal demo if anyone is interested.
  2 个评论
Mike
Mike 2014-1-23
I don't think I would need anything to use colors or pixels. I just used the chessboard as an example. For what I'm trying to do, it's essentially a large grid with sparsely populated cells/nodes. I just want to fill the entire grid (each cell/node) with some sort of interpolated value. I'm hoping to do it for any grid size, as long as the data is known (probably from a .txt or .xls file). Any suggestions?
Thank you for the files, I'm going to take a look at them and see what they do.
Thanks a lot for your help!
Image Analyst
Image Analyst 2014-1-24
If you want to fill a grid, and you have only sparse, randomly scattered data, you need to use griddedInsterpolant (or TriScatteredInterp or griddata if you're using older versions of MATLAB).

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by