How cosine similarity is used in images
Any digital images can be converted into vectors. The vectors can be compared in the latent vector space by the cosine similarity score to indicate the “resemblance” of two images. Figure 5.2 first shows the digital image of the number 5 as a 2D matrix.
Figure 5.2 – The image of “5” (image from [1])
This 2D matrix can be converted by a neural network such as a Convolutional Neural Network (CNN) to become vectors. The square boxes in Figure 5.2 represent a series of layers, including convolutional, pooling, and fully connected layers, to convert an image to a long vector. Let me describe the process a little bit. Initially, the CNN applies multiple convolutional layers to extract hierarchical features from the image. These layers detect patterns such as edges, textures, and shapes. As the network progresses through convolution and pooling layers, it captures increasingly complex...