0

我喜欢使用来自 tensorflow 的对象检测 api 和 dicom 图像而不是 jpg。

在文档中: https ://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html#create-tensorflow-records 我找到以下代码

    # ...
    encoded_jpg_io = io.BytesIO(encoded_jpg)
    # ...

    image_format = b'jpg'
    # ...

    tf_example = tf.train.Example(features=tf.train.Features(feature={
        'image/height': dataset_util.int64_feature(height),
        'image/width': dataset_util.int64_feature(width),
        'image/filename': dataset_util.bytes_feature(filename),
        'image/source_id': dataset_util.bytes_feature(filename),
        'image/encoded': dataset_util.bytes_feature(encoded_jpg),
        'image/format': dataset_util.bytes_feature(image_format),
        'image/object/bbox/xmin': dataset_util.float_list_feature(xmins),
        'image/object/bbox/xmax': dataset_util.float_list_feature(xmaxs),
        'image/object/bbox/ymin': dataset_util.float_list_feature(ymins),
        'image/object/bbox/ymax': dataset_util.float_list_feature(ymaxs),
        'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
        'image/object/class/label': dataset_util.int64_list_feature(classes),
    }))

我已经成功保存了具有上述格式的 tfrecord,其中 encoded_jpg 是 dicom 文件的 numpy 数组的字节串。

  1. 但是我问自己如何设置 image_format 以及这是否需要以及记录在哪里?
  2. 此外,我想知道通常是否可以将 tensorflow 反对 api 与 dicom 文件一起使用,或者 tensorflow 对象检测 api 是否仅限于 jpg。

@j2abro 我希望明确不要将我的 dicom 图像转换为 jpeg,因为据了解,jpeg 每像素 8 位,而我的 dicom 文件每像素 12 位。我想使用我的数据的无损版本。

4

1 回答 1

0

作为一种解决方法,如何将 DICOM 转换为 JPEG?然后你可以使用你拥有的代码。

med2image -i file.dcm -d out

上面的示例来自med2image Python 库。

于 2021-02-10T18:34:51.703 回答