how to find the quadrant of the point in a image
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Joel Nunes
am 9 Mär. 2020
Kommentiert: Joel Nunes
am 9 Mär. 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 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 9 Mär. 2020
Bearbeitet: Ameer Hamza
am 9 Mär. 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 Kommentare
Guillaume
am 9 Mär. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Geographic Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




