I'm currently working on a style transfer project and wanted to look at the difference between the salience maps of the content and style image. I've managed to get the actual transfer working but am having issues trying to workout how to minimize the saliency loss between 2 images. The code below is the one used to generate the salience maps.
import cv2
imgpath = r'Content Image.jpg'
image = cv2.imread(imgpath)
saliency = cv2.saliency.StaticSaliencySpectralResidual_create()
(success, saliencyMap) = saliency.computeSaliency(image)
saliencyMap = (saliencyMap * 255).astype("uint8")
cv2.imshow("Image", image)
cv2.imshow("Output", saliencyMap)
cv2.waitKey(0)
cv2.destroyAllWindows()
imgpath = r'Content Image.jpg'
image = cv2.imread(imgpath)
saliency = cv2.saliency.StaticSaliencyFineGrained_create()
(success, saliencyMap) = saliency.computeSaliency(image)
# Set threshold for saliency map
threshMap = cv2.threshold(saliencyMap.astype("uint8"), 0, 255,cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
cv2.imshow("Image", image)
cv2.imshow("Output", saliencyMap)
# cv2.imshow("Thresh", threshMap)
cv2.waitKey(0)
The pictures below are the result of running the above code except the Content Image is replace with 'Style Image'. I can see that the map is working fine, however, I have been struggling on how to work out how to get a value for the salience map or how to subtract one from the other in order to see what the difference is between the 2 if that makes sense.
So my question is, is there a way to compute the numerical difference between the 2 maps? I am looking to minimize this "difference" between the 2 maps but have not figured out how to do it.
Thanks
The issue I had was to make sure that both are the same size and then you can do an absolute difference.
z = cv2.absdiff(g,l)
This gives the resultant difference between the 2.