【问题标题】:How to convert png to nrrd?如何将png转换为nrrd?
【发布时间】:2022-10-05 01:52:52
【问题描述】:

如何将 png 转换为 nrrd?我需要帮助,谢谢! 我使用以下代码:

    img = cv2.imread(imgPath)
    imgT = img.transpose(1,0,2)
    img3d = imgT[..., np.newaxis]
    nrrd.write(imgPath.split(".png")[0] + ".nrrd", img3d)

但是转换速度很慢.转换一张图片需要将近 8 秒。

【问题讨论】:

  • 图片有多大?

标签: python image-processing medical-imaging


【解决方案1】:

我不知道你的转换为什么这么慢,但你可以使用 SimpleITK 来做到这一点。不应该花那么长时间。这是该代码的样子:

import SimpleITK as sitk

img = sitk.ReadImage(imgPath)
# not sure exactly what you're doing with the transpose and 3d bit of code
sitk.WriteImage(img, imgPath.split(".png")[0] + ".nrrd")

【讨论】:

    猜你喜欢
    • 2012-08-09
    • 2018-10-11
    • 2011-04-19
    • 1970-01-01
    • 2013-10-04
    • 2021-06-26
    • 1970-01-01
    • 2015-01-31
    • 2021-10-14
    相关资源
    最近更新 更多