MATLAB Answers

0

How to make an image straightener like that of cam scanner app?

Asked by GMD Baloch on 17 Apr 2019
Latest activity Commented on by GMD Baloch on 19 Apr 2019
Hello, everyone, I want to make an application just like camScanner which lets the user to select the corners of the object and then straights the image according to those corners in such a way that the text is still readable. I need help in this context

  0 Comments

Sign in to comment.

1 Answer

Answer by Clay Swackhamer on 17 Apr 2019
Edited by Clay Swackhamer on 17 Apr 2019

Hi GMD,
Here is a bit of code where I implemented this type of thing. The objective was to straighten a calibration ruler so that it would be aligned with the image borders. I'll attach the image showing the scale before it was rotated and an image showing the rotated scale. The gist of the code is that I find the "hypotenuse" as in the diagonal line that connects the far corners of the scale, then depending on which way it is going I decide whether to rotate the image clockwise or counterclockwise. Since your implementation will be a bit different I'll skip the rest of the code but hopefully this gives you the main idea.
%Decide which way to rotate the image
if (slope > 0) %Look like negative slopes
angle_rotate = 45 - abs(angle_hypot);
field_rotated = imrotate(field, -angle_rotate);
elseif (slope <= 0) %Look like positive slopes
angle_rotate = 45 - abs(angle_hypot);
field_rotated = imrotate(field, angle_rotate);
end

  1 Comment

Thankyou for answering but you didn't get my point, I have an image given in attachment and I want to extract the whiteboard's pixels and then want to straight it like a rectangle

Sign in to comment.