Hi so I have used a saliency map alongside thresholding to obtain a threshold map of an image. Below is the original, salience map and threshold image respectively:
import cv2
imgpath = r'D:\Documents\University\MSc Data Science\Bath\Modules\Programming\Dissertation\Content Image.jpg'
image = cv2.imread(imgpath)
width = 350
height = 450
dim = (width, height)
# resize image
resized = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)
saliency = cv2.saliency.StaticSaliencyFineGrained_create()
(success, saliencyMap) = saliency.computeSaliency(resized)
# Set threshold for saliency map
ret, threshMap = cv2.threshold((saliencyMap * 255).astype('uint8'), 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
cv2.imshow("Image", resized)
cv2.imshow("Output", saliencyMap)
cv2.imshow("Thresh", threshMap)
cv2.waitKey(0)
The pictures are below:
The issue I'm having now is, I'm not sure how to put the threshold map over the original image, to get a new image that just has the content of what is in the threshold? Does anyone know what I could do to do this? The resultant image I want is one that copies the threshold image but only the parts of the content image that is white on the threshold map.