8
$\begingroup$

As Vitaliy Kaurov's answer mentioned, anyone can use a method based on Neural Network (NN) to give a try? Then the bounty is deserved.


Suppose I have a empty paper like

Then I write some text on the paper,then the result paper have been distorted,rotated and translated.like

How to adjust the result papper according the original empty paper? As you see,some empty transverse line can align this two images. The result like following is expected.

Actually I think the ImageAlign can help me(it cannot align a distorted image as its documentation).

ImageAlign[template, img, TransformationClass -> "Similarity"]

But it is a very slow and give me a poor result.Can anybody give a better solution for this?

$\endgroup$
  • 1
    $\begingroup$ Can you post images with clear external borders - this could help significantly. $\endgroup$ – Vitaliy Kaurov Aug 13 '17 at 7:37
  • $\begingroup$ @VitaliyKaurov But it don't have a clear external borders...The post have all information I have. $\endgroup$ – yode Aug 13 '17 at 7:40
  • 2
    $\begingroup$ ImageAlign works with the following transformations (as per the help): Translation, Rigid, Similarity, Affine, Perspective. The transformation of your paper looks to be nonlinear and/or spatially varying, so it is unlikely to work. $\endgroup$ – bill s Aug 13 '17 at 14:13
  • $\begingroup$ @bills Yes,I have read that before I post this question. $\endgroup$ – yode Aug 13 '17 at 14:58
  • $\begingroup$ "The result like following is expected." --- how did you get that result? $\endgroup$ – Vitaliy Kaurov Aug 13 '17 at 22:07
7
+600
$\begingroup$

I will give just a start, which I think is not bad already. First just for faster computing times I resize your images:

i1 = ImageResize[Import["https://i.stack.imgur.com/nerv4.jpg"], 400];
i2 = ImageResize[Import["https://i.stack.imgur.com/czNNK.jpg"], 400];

Next FindGeometricTransform

{e, t} = FindGeometricTransform[i1, i2]

enter image description here

Then you can go both ways which give you same result, but 1st is faster:

ImagePerspectiveTransformation[i2, t, DataRange -> Full]

or

ImageForwardTransformation[i2, t, DataRange -> Full]

enter image description here

The same result could be obtained as

pts = ImageCorrespondingPoints[i1, i2];
{cpe, cpt} = FindGeometricTransform @@ pts
ImagePerspectiveTransformation[i2, t, DataRange -> Full]

You can try playing with ImageFeatureTrack, ImageLines, and some manual manipulation of extracted features, for example manual specification or editing points/lines after ImageCorrespondingPoints/ImageLines before they go into FindGeometricTransform. You could also try training a Neural Network (NN) on a bunch if similar simulated transformations. Advantage of NN is it could potentially be very fast.

$\endgroup$
  • $\begingroup$ As I know,those matrix just can process linear transformation.. $\endgroup$ – yode Aug 14 '17 at 1:37
  • 1
    $\begingroup$ @yode, why do you believe the distortion in your images cannot be approximated by a linear fractional transformation? $\endgroup$ – J. M. will be back soon Aug 14 '17 at 1:53
  • $\begingroup$ @J.M. I just juess,I think that cannot be solved by a matrix transformation.I think we need a new solution. And I think this answer is a good start. $\endgroup$ – yode Aug 14 '17 at 1:57
  • $\begingroup$ I'm confused still.If we use a NN method. How to get those trianning image. I mean if I just trainnig the image posted in the question with different transform. Then we can deal with other image with different transform? $\endgroup$ – yode Sep 14 '17 at 6:52
  • 1
    $\begingroup$ I don't very familar thos NN thing..I have to give you still. $\endgroup$ – yode Sep 20 '17 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.