[Python] Converting image to grayscale

Discussão em 'Python' iniciado por Stack, Março 30, 2025.

  1. Stack

    Stack Membro Participativo

    I want to convert any image to grayscale, but I don't understand the difference between these implementations.

    image = cv2.imread('lenna.jpg')
    gray = cv2.cvtColor(image, cv2.IMREAD_GRAYSCALE)

    gray1 = rgb2gray(image)

    gray2 = cv2.imread('lenna.jpg', cv2.IMREAD_GRAYSCALE)

    image1 = Image.open('lenna.jpg', 'r')
    gray3 = image1.convert('L')


    When I plot them, I get them in blue scale, green scale, green scale and gray respectively. When I should use each one?

    Continue reading...

Compartilhe esta Página