Nitin Alabur
Nitin Alabur

Reputation: 5812

UIImage part of the image in focus

I'm trying to extend my understanding of the AVFoundation framework.

I want to add a Bezier Path (not necessarily a high resolution one) around the area of an image that is in focus.

So, given an UIImage, is it possible to know which points of the UIImage are in focus and which points aren't?

(not sure if any of the GPUImage "detection filters" would be useful to achieve what I'm trying).

Upvotes: 1

Views: 285

Answers (1)

user1118321
user1118321

Reputation: 26345

One way would be to look for areas of high frequencies vs. low frequencies. The low frequency areas are more likely to be out-of-focus.

You could do this with a fast fourier transform. But a cheap hack might be to blur your input image and then compare the blurred version to the original. The lower the absolute difference, the lower frequency the input image is at that point. However, this has the downside of detecting areas of flat color as "out-of-focus". Though, I guess it's hard for a human to distinguish those, as well, unless there's other context in the image.

Upvotes: 1

Related Questions