Skip to content

Instantly share code, notes, and snippets.

@nezza
Created December 10, 2019 13:01
Show Gist options
  • Save nezza/136a2ed0435e011cd1d9208f325318e5 to your computer and use it in GitHub Desktop.
Save nezza/136a2ed0435e011cd1d9208f325318e5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
import sys
imagename = sys.argv[1]
imgcol = cv.imread(imagename)
# Load as black/white for the highpass, 'good enough'
img = cv.imread(imagename, 0)
laplacian = cv.Laplacian(img,cv.CV_64F)
sobelx = cv.Sobel(img,cv.CV_64F,1,0,ksize=5)
sobely = cv.Sobel(img,cv.CV_64F,0,1,ksize=5)
print(np.size(img))
height = len(img)
width = len(img[0])
print(f"{width}x{height}")
for x in range(width):
for y in range(height):
# You can try laplacian, sobelx or sobely here:
# The 30 is a random threshold value.
if(laplacian[y, x] > 30):
imgcol[y, x] = (0, 0, 255)
cv.imshow("Fokus Peak", imgcol)
cv.waitKey(0)
cv.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment