I can't google this question, because I can't come up with a good query, so let me describe what I want and maybe someone will be able to suggest a way forward for me.

I need to solve the following problem: there is an list of jpg images. There is also one "source" jpg image. I need to find if this image is a cropped image from the list. I do not know what software was used to crop and have no control over what jpeg quality setting is used in the source image. I do realize that if the setting is to low the result can't be unrecognisable, but I still would like somehow be able to check the source image against each of the images in the list and get a "yes" if a match found.

Ideally I'd like a .net library for this, but I also could implement it myself if only I knew a proper algorithm (and it's description is not 100 pages long). Since jpeg is lossy format I can't do bit by bit comparison, and even if I could it's not immediately obvious how to find the correct part of image to compare so this does not take too long, since the crop can be of arbitrary size in arbitrary spot of the image.

In my case the crop is never resized or rotated, so it kind of makes it simpler, but I'm still not sure where to start.

  • 1
    Image "feature detection" would be a good search phrase to begin with. Searching would be difficult if the "source image" is texture-less (thus feature-less) unless the RGB values stay the same.
    – rwong
    Commented Feb 14, 2014 at 9:33

2 Answers 2


You will need some image pattern recognisation or comparing library.,

You should probably take a look at OpenCV and VLfeat.

For instance you can use SIFT to compare images, which also works pretty good on rotated and cropped images (which you don't even need ).

VLfeat's SIFT is pretty cool

Note: You can also use other algoritms to compare, sift is just an example.

  • This gave me a good starting point, and soon I arrived at this: nowozin.net/sebastian/tu-berlin-2006/libsift I think this should be adequate for my purposes. I bit of work will be required to extract the matching logic from the sources, but nothing insurmountable. Thanks. Commented Feb 14, 2014 at 11:16
  • Very nicely found, notice the last update 2005 though. I'm not sure if there are possible improvements of the C# implementation in more up to date libraries to extract from. Good luck!
    – Timmetje
    Commented Feb 14, 2014 at 15:28

I'm not an expert on image processing or anything, but how about this:

  • first make sure you have tools available to extract pixel info out of your JPEG images. Stuff such as RGB values, for example should suffice (as you don't have an alpha channel in a JPEG). Depending on your platform of choice, this may already come bundled in (for example the Java JDK has the ImageIO and BufferedImage that can help you do this. For PHP, you can use imagecolorat)

  • You'll get a matrix for the pixels, where the values inside that matrix are a structure depicting the color values of each pixel.

  • In order to do the check you need, since we're talking about the posibility that the cropped image will no longer be identical in pixel color value to the original from which it was cropped, you can start of by finding a way to avearage the properties of the cropped image, and then try to find a similar average value (with a given tolerance) in a same-sized area on the possible "parent" picture. There's a good suggestion on how to do this kind of "sub-matrix" matching here

  • what a pointless answer, if you dont have an answer dont write Commented Jul 2, 2021 at 17:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.