How do I distinguish the stem from the rest of the onion body?

How to distinguish the stem from the rest of the onion for the input image below?
The stem is the same color as the rest of the onion, the pointed portion (facing downwards) in the image attached below is the Stem of the onion.

use AI. semantic segmentation.

The stem color is the same as the rest of the onion, so in this case, how would semantic segmentation help distinguish the stem from the rest of the onion?

it would help by giving you the semantic segmentation you asked for, which is to point out the stem and the body.

it does that by being AI and getting trained.

you seem to imply that semantic segmentation can’t tell things apart if they have the same color. why do you think that?

The end goal is to have the stem aligned vertically facing upward. Can this be done just using OpenCV functions, if yes, how? @crackwitz

By using OpenCV functions, I’ve got to the stage where contours, inner and outer circles of the onion are drawn on the masked output.
Next I wish to rotate the entire onion such that the stem (present between the red and green circle in the image below) is facing vertically upwards.

Please suggest how I can go about doing this @crackwitz