image-js icon indicating copy to clipboard operation
image-js copied to clipboard

Correction a picture of a rectangle - Quadrilateral extract

Open lpatiny opened this issue 2 years ago • 1 comments

When taking a picture of a visit card for example of a black background we can extract the ROI (region of interest) corresponding to the visit card.

However the obtained image will likely not be a perfect rectangle and I would like a way to convert the image contained in the ROI to a perfect rectangle.

  • we have an algorithm that allows to extract the minimal bounding rectangle. How to create an algorithm to create a general minimal bounding convex shape where the shape is defined as an array of Point (https://github.com/image-js/image-js-typescript/blob/d315c630840ff22941dd3fe20f2d38dab9818bc7/src/utils/geometry/points.ts#L8). If this seems too difficult we can reduce the shape to a convex quadrilateral
  • can we transform an image to correct for example the perspective ? So a method like 'transform' that would accept 4 points to describe the part to cut in the original image and a final width / height

lpatiny avatar Jan 22 '23 08:01 lpatiny

image

Some external links:

  • https://stackoverflow.com/questions/22656698/perspective-correction-in-opencv-using-python
  • https://pyimagesearch.com/2014/09/01/build-kick-ass-mobile-document-scanner-just-5-minutes/
  • https://pyimagesearch.com/2014/08/25/4-point-opencv-getperspective-transform-example/

lpatiny avatar Mar 26 '23 15:03 lpatiny