pyvp


Namepyvp JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/SajjadAemmi/PyVP
SummaryVanishing Point Detector
upload_time2023-03-28 09:15:24
maintainer
docs_urlNone
authorSajjad Aemmi
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Automated Rectification of Image

Implements the modified version of the following paper:  

[Chaudhury, Krishnendu, Stephen DiVerdi, and Sergey Ioffe. "Auto-rectification
of user photos." 2014 IEEE International Conference on Image Processing (ICIP).
 IEEE, 2014.](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/42532.pdf)

Modifcation note: Instead of finding edge direction using structural tensor and its eigenvectors as in paper, I have used more reliable canny edge detection and probabalistic hough line transform.

##  Results

Input image:

![Input Image](/results/shelf.jpg)

After rectification:

![Rectified Image](/results/shelf_warped.png)

## How it works

First, compute list of 'edgelets'. An edgelet is a tuple of edge location, edge direction and edge strength. 

```python
edgelets1 = compute_edgelets(image)
vis_edgelets(image, edgelets1) # Visualize the edgelets
```

![Edgelets](/results/edgelets.png)

Next, find dominant vanishing point using ransac algorithm. In our case it turns out to be horizontal.

```python
vp1 = ransac_vanishing_point(edgelets1, num_ransac_iter=2000, 
                             threshold_inlier=5)
vp1 = reestimate_model(vp1, edgelets1, threshold_reestimate=5)
vis_model(image, vp1) # Visualize the vanishing point model
```

![Horizontal Vanishing Point](/results/horizontal_vp.png)

Remove the inliers for horizontal vanishing point. Vertical lines should now be dominant. Recompute the vanishing point using ransac should give us vertical vanishing point. 

```python
edgelets2 = remove_inliers(vp1, edgelets1, 10)
vp2 = ransac_vanishing_point(edgelets2, num_ransac_iter=2000,
                             threshold_inlier=5)
vp2 = reestimate_model(vp2, edgelets2, threshold_reestimate=5)
vis_model(image, vp2) # Visualize the vanishing point model
```

![Vertical Vanishing Point](/results/vertical_vp.png)

Finally, compute homography and warp the image so that we have a fronto parellel view with orthogonal axes: 

```
warped_img = compute_homography_and_warp(image, vp1, vp2,
                                         clip_factor=clip_factor)
```

![Rectified Image](/results/shelf_warped.png)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SajjadAemmi/PyVP",
    "name": "pyvp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Sajjad Aemmi",
    "author_email": "sajjadaemmi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b3/3a/270cf6fa05f1fc79fdcfb319efe809d33fb8beb588e354e5e29d89a6b0dc/pyvp-0.1.1.tar.gz",
    "platform": null,
    "description": "# Automated Rectification of Image\n\nImplements the modified version of the following paper:  \n\n[Chaudhury, Krishnendu, Stephen DiVerdi, and Sergey Ioffe. \"Auto-rectification\nof user photos.\" 2014 IEEE International Conference on Image Processing (ICIP).\n IEEE, 2014.](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/42532.pdf)\n\nModifcation note: Instead of finding edge direction using structural tensor and its eigenvectors as in paper, I have used more reliable canny edge detection and probabalistic hough line transform.\n\n##  Results\n\nInput image:\n\n![Input Image](/results/shelf.jpg)\n\nAfter rectification:\n\n![Rectified Image](/results/shelf_warped.png)\n\n## How it works\n\nFirst, compute list of 'edgelets'. An edgelet is a tuple of edge location, edge direction and edge strength. \n\n```python\nedgelets1 = compute_edgelets(image)\nvis_edgelets(image, edgelets1) # Visualize the edgelets\n```\n\n![Edgelets](/results/edgelets.png)\n\nNext, find dominant vanishing point using ransac algorithm. In our case it turns out to be horizontal.\n\n```python\nvp1 = ransac_vanishing_point(edgelets1, num_ransac_iter=2000, \n                             threshold_inlier=5)\nvp1 = reestimate_model(vp1, edgelets1, threshold_reestimate=5)\nvis_model(image, vp1) # Visualize the vanishing point model\n```\n\n![Horizontal Vanishing Point](/results/horizontal_vp.png)\n\nRemove the inliers for horizontal vanishing point. Vertical lines should now be dominant. Recompute the vanishing point using ransac should give us vertical vanishing point. \n\n```python\nedgelets2 = remove_inliers(vp1, edgelets1, 10)\nvp2 = ransac_vanishing_point(edgelets2, num_ransac_iter=2000,\n                             threshold_inlier=5)\nvp2 = reestimate_model(vp2, edgelets2, threshold_reestimate=5)\nvis_model(image, vp2) # Visualize the vanishing point model\n```\n\n![Vertical Vanishing Point](/results/vertical_vp.png)\n\nFinally, compute homography and warp the image so that we have a fronto parellel view with orthogonal axes: \n\n```\nwarped_img = compute_homography_and_warp(image, vp1, vp2,\n                                         clip_factor=clip_factor)\n```\n\n![Rectified Image](/results/shelf_warped.png)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Vanishing Point Detector",
    "version": "0.1.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d321faf41716685e709b9af721a8df3f8cc233dbc1d44e2d606047387d5e3d01",
                "md5": "1bf052da02e375604ad0bcfde43f887b",
                "sha256": "c55856e7aa4a8077a305bebdf47f3ae2edacad5d28c44f29f6e25a729e818fdc"
            },
            "downloads": -1,
            "filename": "pyvp-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1bf052da02e375604ad0bcfde43f887b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7588,
            "upload_time": "2023-03-28T09:15:22",
            "upload_time_iso_8601": "2023-03-28T09:15:22.519760Z",
            "url": "https://files.pythonhosted.org/packages/d3/21/faf41716685e709b9af721a8df3f8cc233dbc1d44e2d606047387d5e3d01/pyvp-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b33a270cf6fa05f1fc79fdcfb319efe809d33fb8beb588e354e5e29d89a6b0dc",
                "md5": "ae9b33c125f0a9a81be77e052f219ebd",
                "sha256": "41c922edc6b8afd9f4f87ba69034cd708f5c20c4a2f32942804d713d4844a7d3"
            },
            "downloads": -1,
            "filename": "pyvp-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ae9b33c125f0a9a81be77e052f219ebd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7485,
            "upload_time": "2023-03-28T09:15:24",
            "upload_time_iso_8601": "2023-03-28T09:15:24.620560Z",
            "url": "https://files.pythonhosted.org/packages/b3/3a/270cf6fa05f1fc79fdcfb319efe809d33fb8beb588e354e5e29d89a6b0dc/pyvp-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-28 09:15:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "SajjadAemmi",
    "github_project": "PyVP",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pyvp"
}
        
Elapsed time: 0.10961s