iT邦幫忙

2022 iThome 鐵人賽

0

今天一樣使用IU當範例哈哈哈哈哈

原圖IU
https://ithelp.ithome.com.tw/upload/images/20221120/20151839Ly7Ek5MKfD.png

import numpy as np
import cv2

img = cv2.imread('C://Users//USER//iu.png')
res=cv2.resize(img,(500,700),interpolation=cv2.INTER_CUBIC)
img_gray = cv2.cvtColor(res, cv2.COLOR_BGR2GRAY)
cv2.imshow('color_image',res)
cv2.imshow('gray_image',img_gray)

retval, img_binary = cv2.threshold(img_gray,50, 255, cv2.THRESH_BINARY)
cv2.imshow('img_binary',img_binary)

cv2.waitKey(0)
cv2.destroyAllWindows()

blurred_binary = np.hstack([
    cv2.GaussianBlur(img_binary, (3,3), 0),
    cv2.GaussianBlur(img_binary, (7,7), 0),
    cv2.GaussianBlur(img_binary, (15,15), 0)])

blurred_gray = np.hstack([
    cv2.GaussianBlur(img_gray, (3,3), 0),
    cv2.GaussianBlur(img_gray, (7,7), 0),
    cv2.GaussianBlur(img_gray, (15,15), 0)])

blurred = np.hstack([
    cv2.GaussianBlur(res, (3,3), 0),
    cv2.GaussianBlur(res, (7,7), 0),
    cv2.GaussianBlur(res, (15,15), 0)])

cv2.imshow("Gaussian", blurred_binary)
cv2.waitKey(0)
cv2.destroyAllWindows()

cv2.imshow("Gaussian", blurred_gray)
cv2.waitKey(0)
cv2.destroyAllWindows()

https://ithelp.ithome.com.tw/upload/images/20221120/20151839KcSxN9B4Au.png

https://ithelp.ithome.com.tw/upload/images/20221120/20151839GngFePcjAD.png

https://ithelp.ithome.com.tw/upload/images/20221120/20151839jjkfhEt5AX.png


上一篇
Day20-OpenCV 函數
下一篇
Day22-圓環真的很難走欸!
系列文
大四要畢業了但還不太會python合理嗎30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言