how to find the quadrant of the point in a image

4 visualizaciones (últimos 30 días)
Joel Nunes
Joel Nunes el 9 de Mzo. de 2020
Comentada: Joel Nunes el 9 de Mzo. de 2020
Say you have a point in a bounding box and have to calculate which quadrant it lies in, in order to find the orientation of the next connected component. I have the centroid of the bounding box as well as the centroid of the point. Thanks
I have tried to find the directional vector of the two points but i dont think matlab has that functionality to find the oritentation of the next connected component.
  12 comentarios
Joel Nunes
Joel Nunes el 9 de Mzo. de 2020
i had this, and i had to segement in order to extract the white dots which is in the figure above.
my task is to find the next arrow

Iniciar sesión para comentar.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 9 de Mzo. de 2020
Editada: Ameer Hamza el 9 de Mzo. de 2020
You can use atan2 to calculate the direction of the line connecting the center of the bounding box and dot.
center_bb = [0.1 0.3]; %
center_dot = [-0.5 0.5]; % 2nd quadrant with respect to center_bb
difference = center_dot - center_bb;
angle = atan2d(difference(2), difference(1)); % angles in degrees
Result
angle =
161.5651
This assumes that you are using rectangular coordinates. So angle 161 degrees lies in the 2nd coordinate as we initially assumed.
Note that in case of an image, the y-axis might be inverted if the pixel coordinates start from the top-left of the image. In that case, 1st coordinate will be swapped with 4th and 2nd with 3rd.
  6 comentarios
Guillaume
Guillaume el 9 de Mzo. de 2020
I thought Ameer's explanation and drawing were very clear. I'd recommend you spend a bit of time drawing axes on a paper. This is really basic geometry.
_"what has to be changed to get the right angle?"
The sign of y or the sign of the angle... or nothing at all if you use the same coordinate system to define all your angles/coordinates.
Joel Nunes
Joel Nunes el 9 de Mzo. de 2020
thanks soo much

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by