-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsobelXYAndLaplacian.py
More file actions
36 lines (27 loc) · 945 Bytes
/
sobelXYAndLaplacian.py
File metadata and controls
36 lines (27 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'''
===============================================================================
-- Author: Hamid Doostmohammadi, Azadeh Nazemi
-- Create date: 28/10/2020
-- Description: This code is for Laplacian and Sobel Combined.
================================================================================
'''
import cv2
import sys
import os
import numpy as np
from splitAndMergeEdgeCannyDetection import edges
def sobelCombined(image):
edges0 = edges(image)
# edges0 can be used from Canny
lap = cv2.Laplacian(edges0, cv2.CV_64F)
lap = np.uint8(np.absolute(lap))
# edges0 can be used from Canny
sobelX = cv2.Sobel(edges0, cv2.CV_64F, 1, 0)
sobelY = cv2.Sobel(edges0, cv2.CV_64F, 0, 1)
sobelX = np.uint8(np.absolute(sobelX))
sobelY = np.uint8(np.absolute(sobelY))
sb = cv2.bitwise_or(sobelX, sobelY)
return sb
imagepath = sys.argv[1]
image = cv2.imread(imagepath)
sb = sobelCombined(image)