title: copy-move forgery detection using key-points in python
body: <p>I'm trying to detect copy-move forgery through key points. I'm using this <a href="https://i.stack.imgur.com/hM8Cd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hM8Cd.jpg" alt=""></a></p>
  
  <p>This above image has tampered ( the number 4 is copied and moved). I got the key points (number = 891) and descriptors for each keypoint. The shape of <code>descriptors = (891x128</code>). This is the image on which key points are drawn.<br>
  <a href="https://i.stack.imgur.com/KWDli.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KWDli.jpg" alt=""></a></p>
  
  <p>Now I have to cluster these descriptors right? How exactly should I do that? I referred many papers and they only show the flow chart but not how to do it and most of them are hybrid. Most of the StackOverflow questions involve multiple images (from image similarity domain).</p>
  
  <p>I thought the descriptors for the key points lying on both the 4's will be the same and I tried finding duplicate values in the descriptor matrix with the  following code:</p>
  
  <pre><code>import cv2
  from collections import Counter 
  import numpy as np
  img = cv2.imread('img_tamp_1.bmp')
  
  gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  sift = cv2.xfeatures2d.SIFT_create()
  kp, des = sift.detectAndCompute(gray,None)
  
  print('number of key points:', len(kp))
  
  kp = np.array(kp)
  des = np.array(des)
  u = np.unique(des, axis = 0)
  
  print('unique:', len(u))
  img=cv2.drawKeypoints(gray,kp,img)
  cv2.imwrite('sift_keypoints.jpg',img)
  </code></pre>
  
  <p>The output is :</p>
  
  <pre><code>number of key points: 891
  unique: 880
  </code></pre>
  
  <p>implying only 11 are duplicate key points. This confuses me.</p>
  
  <p>So how shall I cluster the row vectors in order to proceed further and mark the forged region?</p>
  
  <p>I will be happy if someone can explain the clustering processing intuitively with some visual output. </p>
  
  <p>PS: This is my first question here. Please let me know if I'm unclear or what I asked is too broad. If anything is uncertain to you, I'll try to add more information. I'm working on this since the whole day and I'm very tired, help, please.</p>