brain_tumor_segmentation_models.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:nn-segmentation-for-lar 作者: cvdlab 项目源码 文件源码
def predict_image(self, test_img):
        """
        predicts classes of input image
        :param test_img: filepath to image to predict on
        :return: segmented result
        """
        # imgs = io.imread(test_img).astype('float').reshape(5, 216, 160)
        imgs = mpimg.imread(test_img).astype('float')
        imgs = rgb2gray(imgs).reshape(5, 216, 160)

        plist = []

        # create patches_to_predict from an entire slice
        for img in imgs[:-1]:
            if np.max(img) != 0:
                img /= np.max(img)
            p = extract_patches_2d(img, (33, 33))
            plist.append(p)
        patches_to_predict = np.array(
            zip(np.array(plist[0]), np.array(plist[1]), np.array(plist[2]), np.array(plist[3])))

        # predict classes of each pixel based on model
        full_pred = self.model.predict_classes(patches_to_predict)
        fp1 = full_pred.reshape(184, 128)
        return fp1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号