Extracting a region from an image using slicing in Python, OpenCV

后端 未结 3 1246
野性不改
野性不改 2020-12-12 09:14

I have an image and I want to extract a region from it. I have coordinates of left upper corner and right lower corner of this region. In gray scale I do it like this:

3条回答
  •  盖世英雄少女心
    2020-12-12 09:57

    Best way to do this is to use :-
    img2 = cv2.cvtColor(img , cv2.COLOR_BGR2RGB)

    This will convert the BGR 'img' array to RGB 'img2' array. Now you can use img2 array for imshow() function of matplotlib.

    Refer Link:- cvtColor

提交回复
热议问题