0

我有这个代码:

    bPlane = myImage[:,:,0] - 0.5*(myImage[:,:,2]) - 0.5*(myImage[:,:,1]);
    purple = bPlane > 20
    purple2 = morphology.remove_small_objects(BW_2, 400);

其中 myImage 是 BGR。

如何在 Python 3.6 中将“ purple2 ”转换为灰度图像?

4

1 回答 1

0

如果您的图像最初是一个数组(arr),则可能的解决方案是:

import numpy as np
from PIL import Image

arr = np.random.rand(100,100)

im = Image.fromarray(arr)

gray = im.convert('L') # Converting to grayscale
于 2017-10-31T16:01:10.863 回答