Answers.Body: <p>If your image just slightly changes, all you need is the simple algorithm, just find the keyword &quot;k-Nearest Neighbor&quot; or take a look at <a href="https://cs231n.github.io/classification/" rel="nofollow noreferrer">this link</a>.</p>
  <p>To locate where is the difference, you can find the difference by subtracting two images by this script:</p>
  <pre><code>def extract_diff(imageA, imageB):
      '''
      Find the different between two image:
          + Input: two RGB image
          + Output: binary image show different between two image
      Assume the different between two image in each channel will be bigger or equal 30
      '''
      subtract = imageB.astype(np.float32) - imageA.astype(np.float32)
      mask_motion = cv2.inRange(np.abs(subtract),(30,30,30),(255,255,255))
      # mask_motion[mask_motion==255] = 1 # scale to 1 to reduce computation
      return mask_motion
  </code></pre>
  <p>And locate where the position with value 255 in the image. Next time you should this kind of question in the stack overflow community, there is a more active community, they can give you a better solution than mine.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-04T01:24:59.983Z
Answers.LastActivityDate: 2020-12-04T01:24:59.983Z
Answers.UserDisplayName: CuCaRot
Body: <p>Newbie to CV here so sorry of this is basic. Here's the deal, I have a program that I run many times. and each run I produce a screenshot. I need to compare screenshots from N-1 and N runs and make sure they aren't different in any dramatic way. Of course there are some minor changes like logos and pictures getting updated, etc.</p>
  <p>SO far I've used something as simple as absdiff from opencv to highlight the difference regions and then use some sort of threshold to determine whether something passes or not. But I want to make it slightly intelligent but I'm not 100% sure how to proceed. Google hasn't yielded ghe best answers.</p>
  <p>Essentially, I want to train the model on many different pairs of images and have the output be binary, yes or no depending on whether it should pass or not. In theory, I should be able to plug in 2 images and based on previous training, it should be able to tell me whether there is significant difference or not. What are some ways I might approach this, particularly with regards to what kinds of models to use.</p>
  <p>The requirements here might seem amorphous but that's kinda the nature of the problem. the differences could be, in theory, anything. I am hoping that there will be patterns between different images and that a model would pick up on that. Things like the name of a document is 045 instead of 056 or a logo is slightly updated.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-03T22:16:24.043Z
Comments.Text: Cross-posted: https://ai.stackexchange.com/q/24957/1794, https://cs.stackexchange.com/q/132831/755.  Please [do not post the same question on multiple sites](https://meta.stackexchange.com/q/64068).
Comments.UserDisplayName: D.W.
Tags: <neural-networks><convolutional-neural-networks><computer-vision><image-recognition><image-processing>
Title: Training a model to identify certain differences between images?
UserDisplayName: bumblyboi
ThreadText: # Training a model to identify certain differences between images?
  
  (Asked by: username_0 on 2020-12-02)
  
  Newbie to CV here so sorry of this is basic. Here's the deal, I have a program that I run many times. and each run I produce a screenshot. I need to compare screenshots from N-1 and N runs and make sure they aren't different in any dramatic way. Of course there are some minor changes like logos and pictures getting updated, etc.
  
  SO far I've used something as simple as absdiff from opencv to highlight the difference regions and then use some sort of threshold to determine whether something passes or not. But I want to make it slightly intelligent but I'm not 100% sure how to proceed. Google hasn't yielded ghe best answers.
  
  Essentially, I want to train the model on many different pairs of images and have the output be binary, yes or no depending on whether it should pass or not. In theory, I should be able to plug in 2 images and based on previous training, it should be able to tell me whether there is significant difference or not. What are some ways I might approach this, particularly with regards to what kinds of models to use.
  
  The requirements here might seem amorphous but that's kinda the nature of the problem. the differences could be, in theory, anything. I am hoping that there will be patterns between different images and that a model would pick up on that. Things like the name of a document is 045 instead of 056 or a logo is slightly updated.
  
  **Tags:** neural-networks, convolutional-neural-networks, computer-vision, image-recognition, image-processing
  > **Comments:**
  > **username_1**: Cross-posted: https://ai.stackexchange.com/q/24957/1794, https://cs.stackexchange.com/q/132831/755.  Please [do not post the same question on multiple sites](https://meta.stackexchange.com/q/64068).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-12-04. Score: 0
  
  If your image just slightly changes, all you need is the simple algorithm, just find the keyword "k-Nearest Neighbor" or take a look at this link.
  To locate where is the difference, you can find the difference by subtracting two images by this script:
  def extract_diff(imageA, imageB):
      '''
      Find the different between two image:
          + Input: two RGB image
          + Output: binary image show different between two image
      Assume the different between two image in each channel will be bigger or equal 30
      '''
      subtract = imageB.astype(np.float32) - imageA.astype(np.float32)
      mask_motion = cv2.inRange(np.abs(subtract),(30,30,30),(255,255,255))
      # mask_motion[mask_motion==255] = 1 # scale to 1 to reduce computation
      return mask_motion
  
  And locate where the position with value 255 in the image. Next time you should this kind of question in the stack overflow community, there is a more active community, they can give you a better solution than mine.
  
  
  ---
  
  