Interp2 - make resolution lower
古いコメントを表示
I have a matrix 'I' representing a digital elevation model, with a pixel resolution of 90m. I need to lower the resolution to 250m and I've been advised to do this using interp2 but I'm unclear on how to do so from the help file?
I don't understand what I put as the X, Y, Z, Xi, Yi inputs.
Thank you
8 件のコメント
Matt Kindig
2013 年 3 月 7 日
In what form do you have the model? Is it an image? A matrix of vertices? etc. That will help us advise you further.
Grant
2013 年 3 月 7 日
Matt Kindig
2013 年 3 月 7 日
Matt J's suggestion of griddedInterpolant would be good. If you must use interp2, the code would be this:
Values = imread('/your/tif/file/here.tif');
Xi = 1:4609; Yi = 1:2737; %original resolution
Xo = 1:(250/90):Xi(end);
Yo = 1:(250/90):Yi(end);
ValOut= interp2(Xi, Yi, Values,Xo, Yo); %do the interpolation
%note that this will not be an image anymore
mesh(Xo, Yo, ValOut); %illustrate new data
Grant
2013 年 3 月 7 日
Matt Kindig
2013 年 3 月 7 日
編集済み: Matt Kindig
2013 年 3 月 7 日
What is the output of:
>> size(Values)
?
Image Analyst
2013 年 3 月 7 日
You can use linspace(startValue, endingValue, numberOfSteps) instead of startValue:stepValue:endingValue to make sure arrays have exactly the size (number of elements) that you want them to have.
Grant
2013 年 3 月 8 日
Grant
2013 年 3 月 8 日
採用された回答
その他の回答 (2 件)
I would advise using griddedInterpolant instead
F=griddedInterpolant(I);
Now evaluate F at the sample locations that you want. So, for example, if you want the resulting image to be 100x250, you would do
x=linspace(1,size(I,1),100);
y=linspace(1,size(I,2),250);
I_new = F({x,y});
Grant
2013 年 3 月 8 日
0 投票
2 件のコメント
Thanks, but it appears I don't have griddenInterpolant in my toolbox.
What MATLAB version are you using? It would have to be several years old. You've spelled griddedInterpolant incorrectly, so that might be why you couldn't find it.
I'd also prefer to use interp2 to ensure I'm consistent with another person's method.
INTERP2 calls griddedInterpolant to perform its interpolations. It would be the same method, just with a somewhat easier (IMO) interface.
Grant
2013 年 3 月 8 日
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!