gpt4 book ai didi

python - skimage转换为灰度,生成黑色图像

转载 作者:行者123 更新时间:2023-12-02 17:02:26 25 4
gpt4 key购买 nike

我正在抓取图像并将其转换为灰度图像。但是,如果我查看图像。它是纯黑色。有人可以告诉我这是怎么了吗?谢谢

这是我的片段

import cv2
from skimage import io
from skimage import data
from skimage.color import rgb2gray

#...some codes

for i in elements:
try:
i.click()
except ElementClickInterceptedException:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
i.click()
url = driver.find_element_by_xpath('//*[@class="slider-list"]/div/img').get_attribute('src').replace('height=600','height=1200').replace('quality=70','quality=100')
print (url)
name = driver.find_element_by_xpath('//*[@class="slider-list"]/div/img').get_attribute('alt') + '.jpg'

print (name)
img = io.imread(url)
new = rgb2gray(img)
cv2.imwrite(os.path.join(fldrnm, name), new)

最佳答案

Import cv2
Img = cv2.inread(filepath)
Img = cv2.cvtColor(Img, cv2.COLOR_RGB2GRAY)
cv2.imwrite(path,img)

关于python - skimage转换为灰度,生成黑色图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60106454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com