Image Processing for Dummies with C# and GDI+ Part 3 - Edge Detection Filters
]. It's in c#, but the concepts and algorithms are generic.
I don't mean to be rude, but if you're not capable of using the search functionality on the site, I wonder how you're going to go writing a complex system that examines two totally different pictures and tries to work out if they are of the same thing. The pixel values are NOT going to match, it's a much more complex task than that. Trimming the picture is the least of your worries. If this is for a class, I'd be talking to the teacher and asking him what resources you should be using, because he obviously believes you have all the information you need to do this task.