junqiangchen / LiTS---Liver-Tumor-Segmentation-Challenge

LiTS - Liver Tumor Segmentation Challenge
MIT License
234 stars 73 forks source link

About *.nii to *.bmp for test #10

Closed ouchaochao closed 5 years ago

ouchaochao commented 5 years ago

您好,这段nii转bmp的代码是我模仿生成训练数据写的,测试的效果很差,想知道问题是出在了哪里 :)

def prepareTestData():
    for i in range(0, 70, 1):
        filepath = testImage + str(i) + ".nii"
        src = load_itk(filepath)
        data = sitk.GetArrayFromImage(src)
        data = data.astype(np.float32)
        data = np.clip(data, 0, 255).astype('uint8')
        channel, width, height = data.shape[0], data.shape[1], data.shape[2]
        for j in range(channel):
            savePath = outputPath + str(i)
            if not os.path.exists(savePath):
                os.makedirs(savePath)
            v_flip = cv2.flip(data[j, :, :], 0)  # 上下翻转图片
            cv2.imwrite(savePath + "/" + str(j) + ".bmp", v_flip)