PIL rotate image colors (BGR -> RGB)

后端 未结 11 2187
深忆病人
深忆病人 2020-11-29 21:21

I have an image where the colors are BGR. How can I transform my PIL image to swap the B and R elements of each pixel in an efficient manner?

11条回答
  •  既然无缘
    2020-11-29 21:54

    Adding a solution using the ellipsis

    image = image[...,::-1]

    In this case, the ellipsis ... is equivalent to :,: while ::-1 inverts the order of the last dimension (channels).

提交回复
热议问题