I want to embed and extract the secret data in host image using svd technique. The related information and code goes here... I have taken two images, one is host image and the other one is watermark image both of size 512x512 and decomposed two images into U,S,V. Then their singular values are added to form "Snew". By using this Snew i got embedded image. Now while extracting, when I substract the host image singular values to get watermark data... The singular values are not ordered like s1 >= s2 >= s3 >=... So i could not reconstruct the image. Is there any way to get the watermark extracted..? Any help is appreciated. Thank you!!
img = cv2.imread("Lena.tiff",0)
imgw = cv2.imread("4.2.07.tiff",0)
Singular-value decomposition
U, s, VT = np.linalg.svd(img)
Uw, sw, VTw = np.linalg.svd(imgw)
snew=s+(sw*0.01)
# create Sigma matrix and populate diagonal elements into it
Sigma = zeros((img.shape[0], img.shape[1]))
Sigma[:img.shape[1], :img.shape[1]] = diag(snew)
### inverse svd
img_emb = U.dot(Sigma.dot(VT))
cv2.imwrite("Emb_Lenaimg.tiff",np.uint8(img_emb))
cv2.waitKey(5000)
cv2.destroyAllWindows()
psnr = cv2.PSNR(img,np.uint8(img_emb))
print("psnr of host image", psnr)
### Extraction
Ue, se, VTe = svd(np.uint8(img_emb))
sw1= (snew-se)/0.01
Sigma1 = zeros((img.shape[0], img.shape[1]))
Sigma1[:img.shape[1], :img.shape[1]] = diag(sw1)
img_w_ext= Uw.dot(Sigma1.dot(VTw))
cv2.imwrite("watermark_extracted.tiff", np.uint8(img_w_ext))
cv2.waitKey(5000)
cv2.destroyAllWindows()
psnr = cv2.PSNR(imgw,np.uint8(img_w_ext))
print("psnr of watermark", psnr)