Created
August 21, 2018 21:11
-
-
Save fhiyo/73a1814f53204f55faf1484de0ffc792 to your computer and use it in GitHub Desktop.
opencvによるエッジ抽出のサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import cv2 | |
import numpy as np | |
def main(): | |
gray = cv2.imread('lena_std.png', 0) # 入力画像をグレースケールで読み込み | |
# gray = np.asarray([[0, 0, 1, 1], [0, 0, 1, 7], [1, 0, 8, 8], [0, 1, 8, 9]], dtype=np.uint8) | |
# カーネル(縦方向の輪郭検出用) | |
kernel = np.array([[-1, 0, 1], | |
[-1, 0, 1], | |
[-1, 0, 1]]) | |
dst1 = cv2.filter2D(gray, -1, kernel) | |
# print(dst1) | |
# Output | |
cv2.imwrite('lena_prewitt.png', dst1) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment