问题
I have got an image in opencv, and I want to add labels in the axis. Actually I want similar implementation as xlabel and ylabel matlab functions. How is it then, to add labels in both x and y axis of an image?
回答1:
If you have a string a label variable label image matrix img and positions x and y , you can do
putText(img, label, Point(x, y), FONT_HERSHEY_PLAIN, 1.0, CV_RGB(0,255,0), 2.0);
The additional parameters are for font attributes.
回答2:
You will need to get the size of the original image and then create a new image that is larger than the existing image from this, manually draw your Axis in this image, and label them using the putText function. Then insert the original image into the relevant portion of this new image.
Images dont have "Axis" as such, so your labels and axis will need to be part of the image!
来源:https://stackoverflow.com/questions/21256914/add-text-labels-in-opencv-image