Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何更改skimage.io.imsave中的文件夹位置?_Python 3.x_Scikit Image - Fatal编程技术网

Python 3.x 如何更改skimage.io.imsave中的文件夹位置?

Python 3.x 如何更改skimage.io.imsave中的文件夹位置?,python-3.x,scikit-image,Python 3.x,Scikit Image,我正在使用skimage进行图像处理。首先我读取图像,将其更改为灰度,然后将图像保存到另一个位置。当我试图将代码保存到另一个位置时,代码不起作用。有人能帮忙吗 ` `我想你是说 file\u name=“/new\u path/gray\u{:%Y%m%dT%H%m%S}.png”。格式(datetime.datetime.now()) No。。假设我从D驱动器的“test”文件夹中获取输入,我想将新的灰度图像保存到同一驱动器的“results”文件夹中。那怎么做呢?我还是不明白问题出在哪里?将

我正在使用skimage进行图像处理。首先我读取图像,将其更改为灰度,然后将图像保存到另一个位置。当我试图将代码保存到另一个位置时,代码不起作用。有人能帮忙吗

`

`我想你是说

file\u name=“/new\u path/gray\u{:%Y%m%dT%H%m%S}.png”。格式(datetime.datetime.now())

No。。假设我从D驱动器的“test”文件夹中获取输入,我想将新的灰度图像保存到同一驱动器的“results”文件夹中。那怎么做呢?我还是不明白问题出在哪里?将“新路径”替换为“/d/results/[whateverfilenameyouwant]”?很抱歉,您是对的。我先不明白。我试过了你的建议,现在起作用了。谢谢你宝贵的时间。
    import skimage.io
    from skimage.color import rgb2gray

    def gray_image(image_path=None):
       print("Running on {}".format(args.image)
       image=skimage.io.imread(args.image)
       graycale=rgb2gray(image)
       file_name="gray_{:%Y%m%dT%H%M%S}.png".format("/new_path/", datetime.datetime.now())
       skimage.io.imsave(filename, grayscale)


    gray_image(image_path="/path/to/file")