In OpenCV (Python), why am I getting 3 channel images from a grayscale image?

后端 未结 3 1646
心在旅途
心在旅途 2021-01-31 08:15

I am using Python (2.7) and bindings for OpenCV 2.4.6 on Ubuntu 12.04

I load an image

    image = cv2.imread(\'image.jpg\')

I then chec

3条回答
  •  逝去的感伤
    2021-01-31 08:33

    In openCV reading jpg images result 3 channel images by default. So i'm not sure if you can actually see from jpg file that it's already grayscaled but you can always load it as grayscaled. It would bring problems only if the image isn't grayscaled beforehand and for your case i believe that it wouldn't work. So short answer: you cant save jpg as onechanneled image. So you would need to grayscale it again after reading or figure out new way determine if image is grayscaled or not.

提交回复
热议问题