Пример #1
0
    tmp_img = np.zeros(imshape)
    tmp_label = FullImage.copy()
    # with open('./logs/data/%s_side.pkl'%img_path,'w+') as f:
    #     data = [tmp_img, tmp_label, img_path, ally]
    #     pkl.dump(data, f)
    MSE_loss = MSE_pixel_loss(tmp_img, tmp_label, img_path, ally)
    print 'sideoutput:', img_path, MSE_loss
    MSE_loss_list.append(MSE_loss)

    if save_test_img:
        pred_img = cv2.resize(new_Image.astype(np.uint8), (ROI_img.shape[1], ROI_img.shape[0]))
        tmp_img = pred_img.copy()
        tmp_ROI_img = ROI_img.copy()
        pred_img[pred_img==3]=2
        pred_img[NucluesImage==1]=3
        ROI_img = crop_boundry(ROI_img, pred_img)
        alpha_img = ori_img.copy()
        alpha_img[BeginY:, ally[0]:ally[1]] = ROI_img

        ROI_img = cv2.addWeighted(alpha_img, 0.4, ori_img, 0.6, 0)
        ## imshow the truth
        ROI_img = get_truth(ROI_img, img_path, ally, BeginY)
        if not os.path.exists(os.path.join(args.results,model_name)):
            os.mkdir(os.path.join(args.results,model_name))
        img_path2 = img_path[:-4] + '_ray.png'
        save_name = os.path.join(args.results,model_name, img_path2)
        cv2.imwrite(save_name, ROI_img)

        FullImage = np.zeros(imshape)
        FinalShape = FinalShape * 1
        pred_imgFinal = pred_img
Пример #2
0
        if epoch % 4 == 0 and i % 4 == 0 and epoch != 0:
            left, right, top = img_infor[path]['position']
            w, h = img_infor[path]['size'][:2]

            new_Image = ppi.astype(np.uint8)
            kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
            new_Image = cv2.morphologyEx(new_Image, cv2.MORPH_CLOSE, kernel)

            ori_img_path = os.path.join(ori_data, path)
            ori_img = cv2.imread(ori_img_path)
            ROI_img = ori_img[top:, left:right, :].copy()
            pred_img = cv2.resize(new_Image.astype(np.uint8),
                                  (ROI_img.shape[1], ROI_img.shape[0]),
                                  interpolation=cv2.INTER_LANCZOS4)
            ROI_img = crop_boundry(ROI_img, pred_img)
            alpha_img = ori_img.copy()
            alpha_img[top:, left:right] = ROI_img
            ROI_img = cv2.addWeighted(alpha_img, 0.4, ori_img, 0.6, 0)
            try:
                ROI_img = get_truth(ROI_img, path, [left, right], top)
            except:
                print path

            if not os.path.exists('./visual_results/%s' % model_name):
                os.mkdir('./visual_results/%s' % model_name)
            save_name = './visual_results/%s/label_%s_%s.png' % (model_name,
                                                                 epoch, i)
            cv2.imwrite(save_name, ROI_img)

    MSE_loss = None