其他分享
首页 > 其他分享> > cv2 canny 边缘检测

cv2 canny 边缘检测

作者:互联网

import numpy as np
import cv2
import matplotlib.pyplot as plt

img_path = r'C:\Kaggle\Ultrasound_nerve_seg\train/1_1_mask.tif'
val_path = './data/train_val_256.npz'
val_data = np.load(val_path)
val_x,val_y = val_data['x'],val_data['y']
# val_y = np.where(val_y == 255, 1, 0)
for i in range(50):
    mask_img = val_y[i]
    r1 = cv2.Canny(mask_img, 170, 255)
    # img2 = cv2.imread(img_path,0)
    plt.subplot(121)
    plt.title('mask_y')
    plt.imshow(mask_img)
    plt.subplot(122)
    plt.title('border_y')
    plt.imshow(r1)
    plt.show()
    plt.close()

 

标签:plt,val,img,检测,cv2,mask,canny,path
来源: https://www.cnblogs.com/cxhzy/p/16421083.html