AiLaoHuYouZuo 2023-12-21 01:53 采纳率: 0%
浏览 7
已结题

图像分割后怎么给分割后的图像自定义命名

使用openslide和xlm
核心代码:
def split_svs(name: str, start_x: int, start_y: int, end_x: int, end_y: int):
img = np.array(g_slide.read_region((start_x, start_y), level=0, size=(end_x-start_x, end_y-start_y)), dtype=np.uint8)
# 保存图像
imageio.imsave(g_output + "/" + name + ".tif", img)

# img = np.array(slide.read_region((start_x, start_y), level=0, size=(width, height)), dtype=np.uint8)
# imageio.imsave(out_path + "/test.tif", img)

def parse_xml(file_path: str):
# xml
tree = ET.parse(file_path)
root = tree.getroot()

# 获取标签名
for annotations in root:
    for annotation in annotations:
        coordinates = annotation.find('Coordinates')
        print(annotation.attrib['Name'])
        print(int(float(coordinates[0].attrib['X'])))

        split_svs(
            annotation.attrib['Name'],
            int(float(coordinates[0].attrib['X'])), int(float(coordinates[0].attrib['Y'])),
            int(float(coordinates[2].attrib['X'])), int(float(coordinates[2].attrib['Y']))
        )

怎么让输出的图像以它在原图像中的行和列来命名
比如他是第一行第二个被标注的图,那就以1.2来命名

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月29日
    • 创建了问题 12月21日

    悬赏问题

    • ¥15 关于#python#的问题:使用ATL02数据解算光子脚点的坐标(操作系统-windows)
    • ¥115 关于#python#的问题:未加密前两个软件都可以打开,加密后只有A软件可打开,B软件可以打开但读取不了数据
    • ¥15 在matlab中Application Compiler后的软件无法打开
    • ¥15 想问一下STM32创建工程模板时遇到得问题
    • ¥15 Fiddler抓包443
    • ¥20 Qt Quick Android 项目报错及显示问题
    • ¥15 而且都没有 OpenCVConfig.cmake文件我是不是需要安装opencv,如何解决?
    • ¥15 oracleBIEE analytics
    • ¥15 H.264选择性加密例程
    • ¥50 windows的SFTP服务器如何能批量同步用户信息?