Electron microscopy
 
Image Similarity Search in Python
- Python Automation and Machine Learning for ICs -
- An Online Book -
Python Automation and Machine Learning for ICs                                        http://www.globalsino.com/ICs/        


=================================================================================

 

In the Image Similarity Search Problem, assuming that we have a large set of images available in our database, then we want to find similar images to a given image. The following steps intruduce how to achive the goal of such image searching:

Reconstruct images. To search over images, the first thing which is needed is to understand how does the PC `learn` about images. Once the algorithm understands how images look like, then it can find out similar images. Therefore, we need to reconstruct the images. However, reconstructing an image, we need to learn how the image looks. This notion is captured by an `encoding network` called a convolutional encoder. The convolutional encoder converts images into feature representations. These `feature representations` helps to recognize images.
To reconstruct an image we would again need to convert these `feature representation` to original images. To achieve it, we use a 'decoding network' called a convolutional decoder. The convolutional decoder reconstructs an image from its feature representation.

Two key components in this task:
Encoder: compress the original input into a small encoding
Decoder: restore the original data from that encoding generated by the Encoder

These two components work in cooperation. One (encoder) tries to learn how the image can be transformed into features, while the other (decoder) focuses on how these features can be converted back to the original image. They both mutually help each other in learning.

Template matching with cv2.matchTemplate (details)

In this application, to find the template in the source image, as shown in Figure 4852a, we slide the template from left-to-right and top-to-bottom across the source. At each (x, y)-location, a metric is calculated to represent how “good” or “bad” the match is. Typically, a normalized correlation coefficient is used to determine how “similar” the pixel intensities of the two patches. In Figure 4852b, the brightest location of the result matrix R indicate the best matches, where dark regions indicate there is less correlation between the source and template images.

Template matching pipeline where the object/template is to detect (left), the source image (middle), and the template in the source image (right)

Figure 4852a. Template matching pipeline where the object/template is to detect (left), the source image (middle), and the template in the source image (right). Adapted from [1]

Normalized image of correlation coefficient, R.

Figure 4852b. Normalized image of correlation coefficient, R. [1]

======================================================

Click the link on a webpage with a similar feature: code:
         Click the link on a webpage with a similar feature
Template:         
         Click the link on a webpage with a similar feature
Webpage for click:         
         Click the link on a webpage with a similar feature
Output (only clicked the closest one in red): opened webpage:         
         Click the link on a webpage with a similar feature
Printed output (only printed the closest one in red above):     
         Click the link on a webpage with a similar feature    

======================================================

Click the link on a webpage with a similar feature: code:
         Click the link on a webpage with a similar feature
Template:         
         Click the link on a webpage with a similar feature
Webpage for click:         
         Click the link on a webpage with a similar feature
Output: opened webpage (only clicked the closest one in red):         
         Click the link on a webpage with a similar feature
Printed output (only printed the closest one in red above):     
         Click the link on a webpage with a similar feature  

======================================================

Search a similar feature on the screen: code:
         
Template:         
         Click the link on a webpage with a similar feature
Figure on the screen:         
         
Printed output:     
         Click the link on a webpage with a similar feature

======================================================

Find all similar images from a specific folder and then collect the file path and the folder names: code:
         
Opened image on the window :         
         Opened image on the window
Output :         
         Opened image on the window
         Opened image on the window

 

 

 

 

 

 

 

 

[1] www.pyimagesearch.com.

 

=================================================================================