You can use LEADTOOLS Imaging Pro SDK technology in your application.
https://www.leadtools.com/sdk/products/imaging-pro
Imaging Pro SDK - $795 (Price for Developer Seat (08/2021))
You can leverage the CorrelationCommand class, which allows you to match an image containing a portion of the source image to the source image according to the measure of correlation.
DISCLOSURE: I am an employee of the company offering this toolkit.
Here is some sample code:
List<string> files = Directory.EnumerateFiles(@"DIRECTORY_CONTAINING_IMAGES_THAT_COULD_MATCH_TO_PART_OF_SOURCE_IMAGE").ToList();
using (RasterCodecs _codecs = new RasterCodecs())
using (RasterImage _srcImage = _codecs.Load(@"FILE_PATH_TO_MAIN_SOURCE_IMAGE"))
{
foreach (string file in files)
{
using (RasterImage _dstImage = _codecs.Load(file))
{
CorrelationCommand command = new CorrelationCommand();
// Set the CorrelationImage equal to the thousands of small image parts you are iterating through
command.CorrelationImage = _dstImage;
// The threshold indicates the measure of association required to consider the two images/areas to be correlated
command.Threshold = 70;
// Value that represents the step size in the X direction (along image width), in pixels. For best results, use 1
command.XStep = 1;
// Value that represents the step size in the Y direction (along image height), in pixels. For best results, use 1
command.YStep = 1;
command.Points = new LeadPoint[90];
// Pass in the example source image
command.Run(_srcImage);
// If correlation is found export image to matched images directory
if (command.NumberOfPoints > 0)
{
string _fileName = Path.GetFileNameWithoutExtension(file);
string _outDir = @"DIRECTORY_TO_SAVE_MATCHED_IMAGES";
if (!Directory.Exists(_outDir))
Directory.CreateDirectory(_outDir);
string _outFile = Path.Combine(_outDir, $"{_fileName}.tif");
_codecs.Save(_dstImage, _outFile, RasterImageFormat.Tif, _dstImage.BitsPerPixel);
}
}
}
}
You can also take the correlation LeadPoint and create a LeadRect, which can be used to draw a bounding rectangle on the source image showcasing where the correlation image(s) is located (See the below screenshot).
Also, note that we have a C# .NET tutorial that uses various LEADTOOLS image processing commands to compare two images to determine how similar they are (See in link below).
https://www.leadtools.com/help/sdk/v21/tutorials/dotnet-console-compare-image-data-for-similarities.html