Body: <p>I have to extract part of a source image, then I have to check if it is similar or almost similar to any of the 10 target images, so that I can do further processing on that one specific target image, which is similar to the source image. It's like template matching, but they have to loop over 10 different images to find whether a matching template is found in any of those images or not.</p>
  <p>I wanted to use a CNN-based solution, as a classical distance-based solution is giving poor results.</p>
  <p>Can I use a CNN for template matching, so that there is robustness, as the background of the target image is not that good, and it causes a problem? If some resource can be pointed that would be great too.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-29T22:56:08.933Z
Comments.Text: Do you have enough training instances for each of the 10 (target) classes for which you have the prototypical target images? Because in that case, the task would boil down to a simple classification task (of a class label). Otherwise, for template matching, have you tried using the SIFT transform method, possibly in combination with pre-processing to reduce the noise in images?
Comments.UserDisplayName: Daniel B.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-29T23:12:13.630Z
Comments.Text: Yes I have reasonable value to train right now but problem is that in future classes will be keep on expanding and new classes will be slightly different from existing classes, that's why I was thinking to use template based CNN solution. I have tried SIFT and SURF based algorithm but using them didn't gave better result. I have thought about zero shot learning/incremental learning as for future classes I will have some details available like how new class of image should be. But not sure which approach to take.
Comments.UserDisplayName: Rambo_john
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-29T23:19:58.927Z
Comments.Text: A CNN, if you don't use it for classification, only produces a highly-nonlinear encoding of some input image. From there on, you would probably have to resort to other template matching techniques again. Alternatively. have you tried [LVQ](https://en.wikipedia.org/wiki/Learning_vector_quantization) already?
Comments.UserDisplayName: Daniel B.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-29T23:29:09.450Z
Comments.Text: Thanks for suggestion, will try both CNN and parallelly LVQ to check which one works. But since my old try with classical algorithm failed, or it was very slow to find matching.As destination where the template is to be matched is very noisy and filled with extra unnecessary details which confused classical methods for matching.
Comments.UserDisplayName: Rambo_john
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-29T23:34:08.857Z
Comments.Text: You can always try improving robustness of almost any ML method by applying data augmentation, i.e. by adding additional artificial training data to your existing training dataset, where the extra images are copies of existing training images to which noise (maybe even of different magnitude, so to say) has been added. That might help as well.
Comments.UserDisplayName: Daniel B.
Tags: <convolutional-neural-networks><computer-vision><reference-request><image-processing><template-matching>
Title: Can I use a CNN for template matching, so that there is robustness, as the background of the target image is not that good?
UserDisplayName: Rambo_john
ThreadText: # Can I use a CNN for template matching, so that there is robustness, as the background of the target image is not that good?
  
  (Asked by: username_0 on 2021-01-28)
  
  I have to extract part of a source image, then I have to check if it is similar or almost similar to any of the 10 target images, so that I can do further processing on that one specific target image, which is similar to the source image. It's like template matching, but they have to loop over 10 different images to find whether a matching template is found in any of those images or not.
  
  I wanted to use a CNN-based solution, as a classical distance-based solution is giving poor results.
  
  Can I use a CNN for template matching, so that there is robustness, as the background of the target image is not that good, and it causes a problem? If some resource can be pointed that would be great too.
  
  **Tags:** convolutional-neural-networks, computer-vision, reference-request, image-processing, template-matching
  > **Comments:**
  > **username_1**: Do you have enough training instances for each of the 10 (target) classes for which you have the prototypical target images? Because in that case, the task would boil down to a simple classification task (of a class label). Otherwise, for template matching, have you tried using the SIFT transform method, possibly in combination with pre-processing to reduce the noise in images?  
  > **username_0**: Yes I have reasonable value to train right now but problem is that in future classes will be keep on expanding and new classes will be slightly different from existing classes, that's why I was thinking to use template based CNN solution. I have tried SIFT and SURF based algorithm but using them didn't gave better result. I have thought about zero shot learning/incremental learning as for future classes I will have some details available like how new class of image should be. But not sure which approach to take.  
  > **username_1**: A CNN, if you don't use it for classification, only produces a highly-nonlinear encoding of some input image. From there on, you would probably have to resort to other template matching techniques again. Alternatively. have you tried [LVQ](https://en.wikipedia.org/wiki/Learning_vector_quantization) already?  
  > **username_0**: Thanks for suggestion, will try both CNN and parallelly LVQ to check which one works. But since my old try with classical algorithm failed, or it was very slow to find matching.As destination where the template is to be matched is very noisy and filled with extra unnecessary details which confused classical methods for matching.  
  > **username_1**: You can always try improving robustness of almost any ML method by applying data augmentation, i.e. by adding additional artificial training data to your existing training dataset, where the extra images are copies of existing training images to which noise (maybe even of different magnitude, so to say) has been added. That might help as well.  
  
  ---
  
  ## 0 answers
  
  