how to find the quadrant of the point in a image
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Ameer Hamza
il 9 Mar 2020
Modificato: Ameer Hamza
il 9 Mar 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 Commenti
Guillaume
il 9 Mar 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Geographic Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




