0

I have two images, one is a big image another one is small which is a portion of the big image. Now I need to find if the big image contains the small image and get the frame of the small image inside the big image.

I want this to be done in Objective-C, I can't use any webservices/frameworks.

I am using the following code now, which gives YES only if the two images are identical.

- (BOOL)isEqualToByBytes:(UIImage *)oneImage with:(UIImage *)otherImage {
    NSData *imagePixelsData = (NSData *)CFBridgingRelease(CGDataProviderCopyData(CGImageGetDataProvider(oneImage.CGImage)));
    NSData *otherImagePixelsData = (NSData *)CFBridgingRelease(CGDataProviderCopyData(CGImageGetDataProvider(otherImage.CGImage)));

    BOOL comparison = [imagePixelsData isEqualToData:otherImagePixelsData];


    CGDataProviderRelease((CGDataProviderRef)imagePixelsData);
    CGDataProviderRelease((CGDataProviderRef)otherImagePixelsData);
    return comparison;
}

big image

small image

Ramaraj T
  • 5,184
  • 4
  • 35
  • 68
  • Look also at the image-recognition tag http://stackoverflow.com/questions/tagged/image-recognition – Wain Jun 05 '14 at 08:35
  • @wain I want this to be done in Objective-C, not any webservice or other platforms. That's why I have added objective-c related tags. None of the links help me. Also, I don't want just a face detection. Please unmark the question from duplicate. – Ramaraj T Jun 05 '14 at 09:01
  • @Vitaliy1, Yes, I need to find out one image (that is definitely an UIImage) contains another. And all the terms and names I have mentioned here are correct. Please let me know what I am saying wrong. Also, UIImage is not the subclass of UIView. – Ramaraj T Jun 05 '14 at 09:02
  • 1
    Template matching is what you want. I've directed this to at least one question that talks about this on iOS, but it's not a simple process. That's why Wain was pointing you to the image processing questions. Another question that asks what you do: http://stackoverflow.com/questions/20562103/check-presence-of-subimage-in-image-in-ios , with the same sort of solution. – Brad Larson Jun 05 '14 at 17:29

0 Answers0