"Ignazioc calo" <ignazioc@gmail.com> wrote in message <iuqa50$1um$1@newscl01ah.mathworks.com>...
> hi, i have a BW image, i found centroids and boundaries for each blob.
> now i need to calculate some distances between centroids and boundaries on particular directions.
> i solved the simple problem for 0/90/180/270 degrees, now i have some doubt for the other directions, like 45 or 30 degree..
> i tried two possible solution:
> 1) rotate image and reuse the same approach used for orthogonal axes
> 2) check for every point in boundaries his angle with centroid, if this angle == 45 i found a point and i can calculate euclidean distance.
> i think both approaches aren't very smart and i'm pretty sure that someone here can show me a better way to solve this problem.
>
> thanks in advance..
           
If the image lies in a rectangle extending in one corner from pixel (1,1) to the diagonally opposite corner at (m,n), if the centroid under consideration lies at (i,j), and if the "particular" direction makes an angle with respect to the xaxis of theta, then the Euclidean distance you want is the following:
r = min(max((mi)*sec(theta),(1i)*sec(theta)), ...
max((nj)*csc(theta),(1j)*csc(theta)));
Roger Stafford
