Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
calculate distance on particular direction.

Subject: calculate distance on particular direction.

From: Ignazioc calo

Date: 3 Jul, 2011 17:50:24

Message: 1 of 3

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..

Subject: calculate distance on particular direction.

From: Roger Stafford

Date: 3 Jul, 2011 19:13:09

Message: 2 of 3

"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 x-axis of theta, then the Euclidean distance you want is the following:

 r = min(max((m-i)*sec(theta),(1-i)*sec(theta)), ...
         max((n-j)*csc(theta),(1-j)*csc(theta)));

Roger Stafford

Subject: calculate distance on particular direction.

From: ImageAnalyst

Date: 6 Jul, 2011 05:58:59

Message: 3 of 3

On Jul 3, 1:50 pm, "Ignazioc calo" <ignaz...@gmail.com> wrote:
> 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..

-------------------------------------------------------------
Ignazioc calo:
(1) is dumb. But I don't see any problem with your (2). That's what
I'd do, and it should be pretty fast since there are probably only a
few hundred boundary points to scan through.
ImageAnalyst

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us