opencv簡單卷積運用

2022-07-01 14:09:15 字數 2681 閱讀 9846

#利用cv的卷積核卷積影象

dst=cv.filter2d(img,-1,imgkernel)

cv.imshow('filter img',dst)

print(dst.shape) #可以檢視陣列沒變,說明為same方式卷積

#利用cv的卷積核卷積影象

dst=cv.filter2d(img,-1,imgkernel)

# cv.imshow('filter img',dst)

# print(dst.shape) #可以檢視陣列沒變,說明為same方式卷積

#利用cv的卷積核卷積影象

dst=cv.filter2d(img,-1,imgkernel)

# cv.imshow('filter img',dst)

# print(dst.shape) #可以檢視陣列沒變,說明為same方式卷積

img_dst=np.hstack((img,dst))

# cv.imshow('merge img',img_dst)

img_cany=cv.canny(img,100,200)

# print(img_cany)

# cv.imshow('canny image',img_cany)

img_dst_canny=np.hstack((img_cany,img_cany))

img_total=np.vstack(( img_dst,img_dst_canny))

# cv.imshow('all image',img_total)

ret,threshold=cv.threshold(img,100,200,0)

print(ret)

print(threshold)

cv.imshow('threshold',threshold)

img1=threshold-img

ret1,threshold1=cv.threshold(img1,10,200,0)

print(ret1)

cv.imshow('threshold1',threshold1)

cv.waitkey()

cv.destroyallwindows()

OpenCV 卷積邊緣

在使用卷積處理影象時,不免會因為卷積的大小而導致影象的邊緣畫素無法得到處理。此時就需要確定邊緣處理的設定引數。border default 通過邊緣畫素反向映象 border replicate 邊緣畫素的延長 border wrap 取對邊畫素點,類似於複製很多張影象平鋪在一起 border co...

OpenCV學習筆記 卷積

使用函式為 對影象做卷積 void cvfilter2d const cvarr src,cvarr dst,const cvmat kernel,cvpoint anchor cvpoint 1,1 src 輸入影象.dst輸出影象.kernel 卷積核,單通道浮點矩陣.如果想要應用不同的核于不同...

opencv卷積核處理

關於卷積 這篇博文安利 高斯濾波的 卷積核就是影象處理時,給定輸入影象,在輸出影象中每乙個畫素是輸入影象中乙個小區域中畫素的加權平均,其中權值由乙個函式定義,這個函式稱為卷積核。其主要方法是通過確定的核塊來檢測影象的某個區域,之後根據所檢測的畫素與其他周圍存在的畫素的來讀差值來改變畫素明亮度。乙個三...