-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaliancy_detection_two_approches.py
More file actions
53 lines (42 loc) · 1.56 KB
/
saliancy_detection_two_approches.py
File metadata and controls
53 lines (42 loc) · 1.56 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'''
===============================================================================
-- Author: Hamid Doostmohammadi, Azadeh Nazemi
-- Create date: 05/11/2020
-- Description: This code is for Saliancy detection by two approcahes.
-- Status: In progress
================================================================================
'''
import sys
import os
import cv2
import cv2
import os
import sys
saliency1 = cv2.saliency.StaticSaliencySpectralResidual_create()
def saliantMap1(image):
(success, saliencyMap) = saliency1.computeSaliency(image)
saliencyMap = (saliencyMap * 255).astype("uint8")
threshMap = cv2.threshold(saliencyMap, 127, 255,
cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
return threshMap, saliencyMap
'''
saliancy
'''
saliency2 = cv2.saliency.StaticSaliencyFineGrained_create()
def saliantMap2(image):
(success, saliencyMap) = saliency2.computeSaliency(image)
saliencyMap = (saliencyMap * 255).astype("uint8")
threshMap = cv2.threshold(saliencyMap, 0, 255,
cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
cv2.imshow("saliencyMap.jpg", saliencyMap)
cv2.imshow("threshMap.jpg", threshMap)
cv2.waitKey(0)
return threshMap, saliencyMap
image = cv2.imread(sys.argv[1])
ho, wo = image.shape[:2]
img = cv2.resize(image, (int(wo/10), int(ho/10)))
threshMap, saliencyMap = saliantMap1(img)
cv2.imshow('MASK', threshMap)
cv2.imshow('SALIANT', saliencyMap)
if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()