how is it possible to correspond negative coordinates to matrix indices?

3 visualizaciones (últimos 30 días)
Babak
Babak el 23 de Abr. de 2023
Comentada: Babak el 23 de Abr. de 2023
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

Respuestas (1)

chicken vector
chicken vector el 23 de Abr. de 2023
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

Categorías

Más información sobre Images en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by