Image distortion correction iOS

316 Views Asked by At

How is it possible to achieve something similar to this result? Not talking about the contrast and color, but the way the lines are corrected and straight.

This examples were taken from an iOS app

Original Edited

I already tried to use CIPerspectiveCorrection and CIPerspectiveTransform and other kind of filters but without any luck on straightening the lines.

My result with CIPerspectiveCorrection:

My Result

1

There are 1 best solutions below

6
timbre timbre On

There are multiple steps here. But what you are asking about is the perspective correction, that is (in photoshop terms) "drag" top corner of the image in direction up and out (to increase its size, and thus make it more proportionate to the rest of the page). With Apple frameworks there are several ways to do perspective correction, but most obvious is CIPerspectiveCorrection (here's an example on how it works).

Now how do you arrive at the conclusion that you need such correction (and which corner(s) need it) is a more interesting topic.

  • one option is that user decides so.
  • another option is to use Vision framework to detect a shape (rectangle), and do the correction based on the distortion of the rectangle. This is not error prone option, but that's what many apps are using.