Please take a look at the attached MatLab script. The goal is to plot the image intensity across a diameter passing through the image center and making an arbitrary angle 'phi' with the Cartesian x_axis. No averaging over image intensities. I can calculate the pixel indices of one end of the diameter as follows:
[rows columns] = size(img);
xmid = ceil(rows/2);
ymid = ceil(columns/2);
phi = 30*pi/180;
xs = xmid + round(ceil(radius * cos(phi)))
ys = ymid + round(ceil(radius * sin(phi)))
However, I am unable to get the indices of the other diameter end. Geometrically I would do:
xf = xmid + round(ceil(radius * cos(phi + pi)))
yf = ymid + round(ceil(radius * sin(phi + pi)))
The last two formulae do not generate the righ pixel indices of the other diameter end.
I tried the method indicated in an on-line example using function 'axes2pix' but MatLab issued an error upon getting XData and YData ... God knows why ...
I would greatly appreciate some help at computing correctly the pixel indices of a diameter passing through the 2D image center at an arbitrary angle 'phi'.
Thank you in advance.
**** Please reply to *email@example.com*