擅长:python、mysql、java
<p>我有别的选择。可以使用以下代码将rgb图像转换为灰色:</p>
<pre><code># libraries
import cv2
import Image
# reading an image
image = cv2.imread(path_to_image)
# converting into gray image
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# saving image
Image.fromarray(gray_image).save(save_path)
</code></pre>