# How to flatten a scanned image which is from scanner [duplicate]

I have a image from scanner:

You can see that the right side of this paper is very flat, but it's curved in the left side. I think maybe I can detect the edge of this paper and then build some model and make it deform to a flat paper. But it's a little difficult.

p = Import["https://i.stack.imgur.com/r6g4b.png"];
p2 = DeleteSmallComponents@Binarize[p, 0.1];
corners = ImageCorners[p2, 10, .001, MaxFeatureDisplacement -> 10];
Show[HighlightImage[p2, corners], ImageSize -> 400]

• You might want to take a look at this thread (mathematica.stackexchange.com/questions/5676/…), which discusses taking an image of a curved object (in this case, a label on a jar), and flattening it. Though, in the procedure shown there, it appears some resolution is lost. Thus, if you were perhaps hoping that, in flattening the image, you would improve the readability of the characters at the left, that procedure might not help you. – theorist Apr 15 '18 at 4:54
• @theorist This helped greatly! Thanks. – Apple Apr 18 '18 at 9:27