2022-10-12 16:43:28 -07:00
|
|
|
# MONOCHROME EDGE DETECTION
|
|
|
|
|
|
|
|
import cv2 as cv
|
|
|
|
import numpy as np
|
|
|
|
|
2022-10-27 10:31:42 -07:00
|
|
|
# edge-detection kernel amplification
|
|
|
|
AMPLIFIER=9
|
|
|
|
|
|
|
|
MIN_INTENSITY=100
|
|
|
|
|
|
|
|
# file = '01-0001-cropped.png'
|
|
|
|
file = 'streaktest.png'
|
2022-10-12 16:43:28 -07:00
|
|
|
file_name = file.split(".")[0]
|
|
|
|
file_ext = file.split(".")[1]
|
|
|
|
|
|
|
|
img = cv.imread(file)
|
|
|
|
|
|
|
|
img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
|
|
|
|
|
|
|
|
kernel = np.array([
|
|
|
|
[-1, -1, -1],
|
2022-10-27 10:31:42 -07:00
|
|
|
[-1, AMPLIFIER, -1],
|
2022-10-12 16:43:28 -07:00
|
|
|
[-1, -1, -1],
|
|
|
|
])
|
|
|
|
img = cv.filter2D(src=img, ddepth=-1, kernel=kernel)
|
|
|
|
|
|
|
|
cv.imwrite(f'{file_name}-edge-detection.{file_ext}', img)
|