As I\'m lead to believe, OpenCV reads images in BGR colorspace ordering and we usually have to convert it back to RGB like this:
img = cv2.cv
If you do not need to use any other Image processing library (example Matplotlib's imshow), there is no need to do color scale conversion. Below code is an example, where the color scale conversion is done but when the image is loaded, it is still loaded in BGR. This conversion is not needed as the image is displayed using cv2.imshow().
import cv2
# read the image #
image = cv2.imread('<>')
image_rgb = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
# write a function to draw circles on the image #
def draw_circle(event,x,y,flags,params):
if event == cv2.EVENT_RBUTTONDOWN:
cv2.circle(img=image_rgb,center=(x,y),radius=100,color=(0,0,255),thickness=10)
# Open CV callbacks #
cv2.namedWindow(winname='ImageWindow')
cv2.setMouseCallback('ImageWindow',draw_circle)
# display the image till the user hits the ESC key #
while True:
cv2.imshow('ImageWindow',image_rgb)
if cv2.waitKey(20) & 0xFF == 27:
break
cv2.destroyAllWindows()