Gazza_d
Gazza_d

Reputation: 31

iOS: compare a slice of an image to library of options

I'm basically trying to work out how to take a slice of an image, say a screenshot of an iPhone home screen, slice out the first icon and compare it to a set array of images in a library. Any help on where to start?

Upvotes: 3

Views: 1108

Answers (2)

George Profenza
George Profenza

Reputation: 51857

I'm no iPhone programmer, but I might be able to suggest a few things:

A quick & dirty way might be to use the difference blend mode which should return the difference between the 1st image(top) and the 2nd image(bottom). If there is no difference the result will be completely black. So, the more black pixels in the difference result, potentially, the more similarities between the compared images.

I'm not an iOS developer, so I don't know if there is an image library that ships with sdk or if there's a free/opensource library for basic image processing. Still this should be trivial to implement:

e.g.

- (int)difference((int)topPixel,(int)bottomPixel)
{
    return abs(topPixel-bottomPixel);
}

Note: Syntax might not be correct :)

HTH

Upvotes: 3

August
August

Reputation: 708

This may not help you with taking a screenshot of the iOS home screen... But these articles show how to take snapshots from within a UIKit application:

https://developer.apple.com/library/prerelease/ios/#qa/qa1703/_index.html

https://developer.apple.com/library/prerelease/ios/#qa/qa1714/_index.html

Perhaps you would instruct the user to press home-power (buttons) to take a snapshot and store in the photo roll, then load that screenshot into an app to process the screenshot.

Hope this helps!

Upvotes: 0

Related Questions