Interp2 - make resolution lower
조회 수: 7 (최근 30일)
이전 댓글 표시
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 J
2013년 3월 8일
XI and YI must be the same size or vectors of different orientations.
Xo must be a row vector and Yo must be a column vector. So just transpose Yo
ValOut= interp2(Xi, Yi, Values,Xo, Yo.'); %do the interpolation
댓글 수: 2
Matt J
2013년 3월 8일
I assume you're using a 32-bit machine. Pre-converting your Values to type single would probably make it fit
ValOut= interp2(Xi, Yi, single(Values),Xo, Yo.');
Or, look for a 64-bit computer to work on.
추가 답변 (2개)
Matt J
2013년 3월 7일
편집: Matt J
2013년 3월 7일
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});
댓글 수: 0
Grant
2013년 3월 8일
댓글 수: 2
Matt J
2013년 3월 8일
편집: Matt J
2013년 3월 8일
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!