I am trying to apply Bilinear/bicubic interpolation on my data set which is in text files. These text files are in a folder and name output_00.text to output_23.text. Each text file consist on three columns. First is Latitude, second is longitude and third column is temperature value at this latitude and longitude(position over earth).
Temperature column contain -9999.000 as not a number or NaN values. This NaN value appear randomly in each file. Some times it appear over start, some times in middle of data, and some times at the end in the file. It is random in appearance.
I want to interpolate these NaN values with bilinear/ bicubic interpolation technique.
This code will read each text file and interpolate it with bilinear method and save it with method_00.text.
My text files has been attached
On google i found a tool for bilinear interpolation over a image or matrix. For the time shake this code can be modify to my requirement. But How? This code as been attached with this question. Link of this tool is here http://www.mathworks.com/matlabcentral/fileexchange/43533-bilinear-interpolation-of-an-image-or-matrix
Thanks always for this kind assistance

댓글 수: 3

Stephen23
Stephen23 2016년 3월 9일
편집: Stephen23 2016년 3월 28일
@ Muhammad Usman Saleem: you have already asked this question:
And you have already been told that Because of your missing data you do not have gridded data, but scattered data points, so therefore you can only use a scattered interpolant. You cannot use bilinear/ bicubic interpolation.
Now you asked this question again, and the two answers below have told you exactly the same thing as I did: that you need to use a scattered interpolant. You got the same answer here too.
It seems that you misunderstand what bilinear/ bicubic interpolation can do: it cannot interpolate your data with missing values. It does not matter how many times you ask this question, the problem is your wrong understanding of those interpolation methods. If you spent some time trying to understand how bilinear/ bicubic interpolation work then you would understand why you cannot use them with your data. This would be a good place to start:
@Stephon thanks for your kind contribution always.This question was answered with interpolat1 but now i am asking about interpolation in 2d. Consist on bilinear or scatter.

댓글을 달려면 로그인하십시오.

 채택된 답변

Mike Garrity
Mike Garrity 2016년 3월 8일

4 개 추천

Here's one approach.
Create an XY grid, but put nans in some of the Z values.
[x,y] = meshgrid(linspace(-3,3,40));
z = peaks(x,y);
m = unique(randi(numel(z),[1 50]));
z(m) = nan;
surf(x,y,z)
Now use scatteredInterpolant to fill in the missing values.
m = isnan(z(:));
F = scatteredInterpolant(x(~m),y(~m),z(~m),'linear');
z2 = z;
z2(m) = F(x(m),y(m));
surf(x,y,z2)
What's going on there is that I created a scatteredInterpolant from the locations where there weren't nans (i.e. x(~m),y(~m),z(~m)), and then I applied it at the locations where there are nans (i.e. x(m),y(m)). Does that make sense?

댓글 수: 3

yes this makes sense. But please note that my question is about bilinear and bicubic interpolation method. Scatteredinterpolant only carry linear, natural and nearest interpolation i want to apply bilinear/ bicubic interpolation over my data set. Thanks for your kind assistance. Please modify this code to bilinear and bicubic interpolation method
Stephen23
Stephen23 2016년 3월 9일
편집: Stephen23 2016년 3월 9일
@Muhammad Usman Saleem
It does not matter how many times you ask, you cannot get the impossible. Bilinear/ bicubic interpolation requires all data on a grid. You have missing data. Ergo you cannot use these methods. This has been explained to you multiple times.
thanks Stephon i know i am absolutely wrong every time.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2016년 3월 8일

1 개 추천

If your data are in a rectangular grid (i.e., an image), you can use imresize() (in the Image Processing Toolbox) to do bilinear interpolation, or a variety of other interpolations. If they're not in a grid, use scatteredInterpolant like Mike showed you.

댓글 수: 5

@Image please check my data set. I have attached it to this question. I have used scatteredinterpolant for this data sets. But as this holds only linear, natural and nearest interpolation method not bilinear, bicubic interpolation method. On google i find the code which i have attached with this post. Do not know how can i use this code for my requirements?
Image Analyst
Image Analyst 2016년 3월 8일
Take the x and y numbers and multiply by 10 to get pixels. Then assign the 3rd column as image values. Then use imresize().
Muhammad Usman Saleem
Muhammad Usman Saleem 2016년 3월 8일
편집: Muhammad Usman Saleem 2016년 3월 8일
totally unable to get your answer?
Is linear interpolation in scatteredinterpolant is bilinear interpolation?? What about bicubic interpolation in scatteredinterpolant?
Image Analyst
Image Analyst 2016년 3월 8일
See attached.
thanks for you reply @image.
But this will be modification to my shared code. I want to modify this code so that i can read all test files and interpolation through bilinear and bicubic interpolation and then save it. This attachment only producing my text file as image. And i do not know what will be input in my code

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by