how is it possible to correspond negative coordinates to matrix indices?
3 ビュー (過去 30 日間)
古いコメントを表示
I was working on a piece of code which take a cartesian image and change it to polar demonstration (rho , phi).
using "interp2" negative non-integer numbers correspond to indices of an image (which are positive integers).
in part of the code we see:
x = Pixel_spacing* (-(nrad-0.5):(nrad-0.5));
[x,y] = meshgrid(x,x);
polar_image = interp2(x, y, double(image), xi, yi);
here x and y are expanded on something like (-9.5 , 9.5) and through this these negative coordinates work as indices of matrix. note that x ,y and image are the same size.
having this example in mind, how can correspond indices of a matrix to negative and non-integer contents of another matrix, like the function 'interp2' does?
thanks
0 件のコメント
回答 (1 件)
chicken vector
2023 年 4 月 23 日
You can normalise the coordiante to transorm them into indeces:
x = -9.5 : 9.5; % -9.5 -8.5 ... 8.5 9.5
xIdx = x - x(1) + 1; % 1 2 ... 19 20
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!