BlurGenerator


NameBlurGenerator JSON
Version 1.0.4 PyPI version JSON
download
home_pagehttps://github.com/NatLee/Blur-Generator
SummaryFast generate blur image.
upload_time2023-03-27 07:43:54
maintainer
docs_urlNone
authorNat Lee
requires_python>=3.6
license
keywords blur generator blur-image cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Blur Generator

[![Test](https://github.com/NatLee/Blur-Generator/actions/workflows/test.yml/badge.svg)](https://github.com/NatLee/Blur-Generator/actions/workflows/test.yml)[![Release](https://github.com/NatLee/Blur-Generator/actions/workflows/release.yml/badge.svg)](https://github.com/NatLee/Blur-Generator/actions/workflows/release.yml)

This tool is for generating blur on images.

There are 3 types of blur modes of `motion`, `lens`, or `gaussian`.

We can use the results on model training or something else.

## Installation

```bash
pip install blurgenerator
```

Check it on [Pypi](https://pypi.org/project/BlurGenerator/).

## Usage

```bash
blurgenerator --help
```

```bash
usage: blurgenerator [-h] [--input INPUT] [--input_depth_map INPUT_DEPTH_MAP] [--output OUTPUT] [--type TYPE] [--motion_blur_size MOTION_BLUR_SIZE] [--motion_blur_angle MOTION_BLUR_ANGLE] [--lens_radius LENS_RADIUS] [--lens_components LENS_COMPONENTS]
                     [--lens_exposure_gamma LENS_EXPOSURE_GAMMA] [--gaussian_kernel GAUSSIAN_KERNEL] [--depth_num_layers DEPTH_NUM_LAYERS] [--depth_min_blur DEPTH_MIN_BLUR] [--depth_max_blur DEPTH_MAX_BLUR]
                        Size for motion blur. Default is 100.
  --motion_blur_angle MOTION_BLUR_ANGLE
                        Angle for motion blur. Default is 30.
  --lens_radius LENS_RADIUS
                        Radius for lens blur. Default is 5.
  --lens_components LENS_COMPONENTS
                        Components for lens blur. Default is 4.
  --lens_exposure_gamma LENS_EXPOSURE_GAMMA
                        Exposure gamma for lens blur. Default is 2.
  --gaussian_kernel GAUSSIAN_KERNEL
                        Kernel for gaussian. Default is 100.
  --depth_num_layers DEPTH_NUM_LAYERS
                        Layer for depth blur. Default is 3.
  --depth_min_blur DEPTH_MIN_BLUR
                        Min. blur for depth blur. Default is 1.
  --depth_max_blur DEPTH_MAX_BLUR
                        Max. blur for depth blur. Default is 100.
```

## Example and Result

### Common use

- Original image

![original image](https://github.com/NatLee/Blur-Generator/raw/main/doc/test.png)

#### Usage

- Motion blur

`blurgenerator --type motion --input ./doc/test.png --output ./doc/motion.png`

```python
import cv2
from blurgenerator import motion_blur
img = cv2.imread('test.png')
result = motion_blur(img, size=100, angle=30)
cv2.imwrite('./output.png', result)
```

![motion blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/motion.png)

- Lens blur

`blurgenerator --type lens --input ./doc/test.png --output ./doc/lens.png`

```python
import cv2
from blurgenerator import lens_blur
img = cv2.imread('test.png')
result = lens_blur(img, radius=5, components=4, exposure_gamma=2)
cv2.imwrite('./output.png', result)
```

![lens blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/lens.png)

- Gaussian blur

`blurgenerator --type gaussian --input ./doc/test.png --output ./doc/gaussian.png`

```python
import cv2
from blurgenerator import gaussian_blur
img = cv2.imread('test.png')
result = gaussian_blur(img, 100)
cv2.imwrite('./output.png', result)
```

![gaussian blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/gaussian.png)

### With depth map

Feature from this [issue](https://github.com/NatLee/Blur-Generator/issues/1).

- Original image

![photo](https://github.com/NatLee/Blur-Generator/raw/main/doc/depth-test.jpg)

- Depth map

![depth map](https://github.com/NatLee/Blur-Generator/raw/main/doc/depth-map-test.png)

#### Usage

- Motion blur with depth map

`blurgenerator --input .\doc\depth-test.jpg --type motion --input_depth_map .\doc\depth-map-test.png --depth_num_layers 5 --depth_min_blur 1 --depth_max_blur 50 --output .\doc\depth-motion-output.png`

```python
import cv2
from blurgenerator import motion_blur_with_depth_map
img = cv2.imread('test.jpg')
depth_img = cv2.imread('test-depth.png')
result = motion_blur_with_depth_map(
   img,
   depth_map=depth_img,
   angle=30,
   num_layers=10,
   min_blur=1,
   max_blur=50
)
cv2.imwrite('./output.png', result)
```

![depth motion blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/depth-motion-output.png)

- Lens blur with depth map

`blurgenerator --input .\doc\depth-test.jpg --type lens --input_depth_map .\doc\depth-map-test.png --depth_num_layers 3 --depth_min_blur 1 --depth_max_blur 50 --output .\doc\depth-lens-output.png`

```python
import cv2
from blurgenerator import lens_blur_with_depth_map
img = cv2.imread('test.jpg')
depth_img = cv2.imread('test-depth.png')
result = lens_blur_with_depth_map(
   img,
   depth_map=depth_img,
   components=5,
   exposure_gamma=5,
   num_layers=10,
   min_blur=1,
   max_blur=50
)
cv2.imwrite('./output.png', result)
```

![depth lens blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/depth-lens-output.png)

- Gaussian blur with depth map

`blurgenerator --input .\doc\depth-test.jpg --type gaussian --input_depth_map .\doc\depth-map-test.png --depth_num_layers 3 --depth_min_blur 1 --depth_max_blur 50 --output .\doc\depth-gaussian-output.png`

```python
import cv2
from blurgenerator import gaussian_blur_with_depth_map
img = cv2.imread('test.jpg')
depth_img = cv2.imread('test-depth.png')
result = gaussian_blur_with_depth_map(
   img,
   depth_map=depth_img,
   sigma=5,
   num_layers=10,
   min_blur=1,
   max_blur=50
)
cv2.imwrite('./output.png', result)
```

![depth gaussian blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/depth-gaussian-output.png)

## Contributor

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tbody>
    <tr>
      <td align="center"><a href="https://github.com/NatLee"><img src="https://avatars.githubusercontent.com/u/10178964?v=3?s=100" width="100px;" alt="Nat Lee"/><br /><sub><b>Nat Lee</b></sub></a></td>
    </tr>
  </tbody>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

## LICENSE

[MIT](LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NatLee/Blur-Generator",
    "name": "BlurGenerator",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "blur,generator,blur-image,cli",
    "author": "Nat Lee",
    "author_email": "natlee.work@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bb/fe/905fc32b5ec94774a19e08b5a27c015298a29af25c17b30fe815c5655252/BlurGenerator-1.0.4.tar.gz",
    "platform": null,
    "description": "# Blur Generator\n\n[![Test](https://github.com/NatLee/Blur-Generator/actions/workflows/test.yml/badge.svg)](https://github.com/NatLee/Blur-Generator/actions/workflows/test.yml)[![Release](https://github.com/NatLee/Blur-Generator/actions/workflows/release.yml/badge.svg)](https://github.com/NatLee/Blur-Generator/actions/workflows/release.yml)\n\nThis tool is for generating blur on images.\n\nThere are 3 types of blur modes of `motion`, `lens`, or `gaussian`.\n\nWe can use the results on model training or something else.\n\n## Installation\n\n```bash\npip install blurgenerator\n```\n\nCheck it on [Pypi](https://pypi.org/project/BlurGenerator/).\n\n## Usage\n\n```bash\nblurgenerator --help\n```\n\n```bash\nusage: blurgenerator [-h] [--input INPUT] [--input_depth_map INPUT_DEPTH_MAP] [--output OUTPUT] [--type TYPE] [--motion_blur_size MOTION_BLUR_SIZE] [--motion_blur_angle MOTION_BLUR_ANGLE] [--lens_radius LENS_RADIUS] [--lens_components LENS_COMPONENTS]\n                     [--lens_exposure_gamma LENS_EXPOSURE_GAMMA] [--gaussian_kernel GAUSSIAN_KERNEL] [--depth_num_layers DEPTH_NUM_LAYERS] [--depth_min_blur DEPTH_MIN_BLUR] [--depth_max_blur DEPTH_MAX_BLUR]\n                        Size for motion blur. Default is 100.\n  --motion_blur_angle MOTION_BLUR_ANGLE\n                        Angle for motion blur. Default is 30.\n  --lens_radius LENS_RADIUS\n                        Radius for lens blur. Default is 5.\n  --lens_components LENS_COMPONENTS\n                        Components for lens blur. Default is 4.\n  --lens_exposure_gamma LENS_EXPOSURE_GAMMA\n                        Exposure gamma for lens blur. Default is 2.\n  --gaussian_kernel GAUSSIAN_KERNEL\n                        Kernel for gaussian. Default is 100.\n  --depth_num_layers DEPTH_NUM_LAYERS\n                        Layer for depth blur. Default is 3.\n  --depth_min_blur DEPTH_MIN_BLUR\n                        Min. blur for depth blur. Default is 1.\n  --depth_max_blur DEPTH_MAX_BLUR\n                        Max. blur for depth blur. Default is 100.\n```\n\n## Example and Result\n\n### Common use\n\n- Original image\n\n![original image](https://github.com/NatLee/Blur-Generator/raw/main/doc/test.png)\n\n#### Usage\n\n- Motion blur\n\n`blurgenerator --type motion --input ./doc/test.png --output ./doc/motion.png`\n\n```python\nimport cv2\nfrom blurgenerator import motion_blur\nimg = cv2.imread('test.png')\nresult = motion_blur(img, size=100, angle=30)\ncv2.imwrite('./output.png', result)\n```\n\n![motion blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/motion.png)\n\n- Lens blur\n\n`blurgenerator --type lens --input ./doc/test.png --output ./doc/lens.png`\n\n```python\nimport cv2\nfrom blurgenerator import lens_blur\nimg = cv2.imread('test.png')\nresult = lens_blur(img, radius=5, components=4, exposure_gamma=2)\ncv2.imwrite('./output.png', result)\n```\n\n![lens blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/lens.png)\n\n- Gaussian blur\n\n`blurgenerator --type gaussian --input ./doc/test.png --output ./doc/gaussian.png`\n\n```python\nimport cv2\nfrom blurgenerator import gaussian_blur\nimg = cv2.imread('test.png')\nresult = gaussian_blur(img, 100)\ncv2.imwrite('./output.png', result)\n```\n\n![gaussian blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/gaussian.png)\n\n### With depth map\n\nFeature from this [issue](https://github.com/NatLee/Blur-Generator/issues/1).\n\n- Original image\n\n![photo](https://github.com/NatLee/Blur-Generator/raw/main/doc/depth-test.jpg)\n\n- Depth map\n\n![depth map](https://github.com/NatLee/Blur-Generator/raw/main/doc/depth-map-test.png)\n\n#### Usage\n\n- Motion blur with depth map\n\n`blurgenerator --input .\\doc\\depth-test.jpg --type motion --input_depth_map .\\doc\\depth-map-test.png --depth_num_layers 5 --depth_min_blur 1 --depth_max_blur 50 --output .\\doc\\depth-motion-output.png`\n\n```python\nimport cv2\nfrom blurgenerator import motion_blur_with_depth_map\nimg = cv2.imread('test.jpg')\ndepth_img = cv2.imread('test-depth.png')\nresult = motion_blur_with_depth_map(\n   img,\n   depth_map=depth_img,\n   angle=30,\n   num_layers=10,\n   min_blur=1,\n   max_blur=50\n)\ncv2.imwrite('./output.png', result)\n```\n\n![depth motion blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/depth-motion-output.png)\n\n- Lens blur with depth map\n\n`blurgenerator --input .\\doc\\depth-test.jpg --type lens --input_depth_map .\\doc\\depth-map-test.png --depth_num_layers 3 --depth_min_blur 1 --depth_max_blur 50 --output .\\doc\\depth-lens-output.png`\n\n```python\nimport cv2\nfrom blurgenerator import lens_blur_with_depth_map\nimg = cv2.imread('test.jpg')\ndepth_img = cv2.imread('test-depth.png')\nresult = lens_blur_with_depth_map(\n   img,\n   depth_map=depth_img,\n   components=5,\n   exposure_gamma=5,\n   num_layers=10,\n   min_blur=1,\n   max_blur=50\n)\ncv2.imwrite('./output.png', result)\n```\n\n![depth lens blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/depth-lens-output.png)\n\n- Gaussian blur with depth map\n\n`blurgenerator --input .\\doc\\depth-test.jpg --type gaussian --input_depth_map .\\doc\\depth-map-test.png --depth_num_layers 3 --depth_min_blur 1 --depth_max_blur 50 --output .\\doc\\depth-gaussian-output.png`\n\n```python\nimport cv2\nfrom blurgenerator import gaussian_blur_with_depth_map\nimg = cv2.imread('test.jpg')\ndepth_img = cv2.imread('test-depth.png')\nresult = gaussian_blur_with_depth_map(\n   img,\n   depth_map=depth_img,\n   sigma=5,\n   num_layers=10,\n   min_blur=1,\n   max_blur=50\n)\ncv2.imwrite('./output.png', result)\n```\n\n![depth gaussian blur image](https://github.com/NatLee/Blur-Generator/raw/main/doc/depth-gaussian-output.png)\n\n## Contributor\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tbody>\n    <tr>\n      <td align=\"center\"><a href=\"https://github.com/NatLee\"><img src=\"https://avatars.githubusercontent.com/u/10178964?v=3?s=100\" width=\"100px;\" alt=\"Nat Lee\"/><br /><sub><b>Nat Lee</b></sub></a></td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\n## LICENSE\n\n[MIT](LICENSE)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Fast generate blur image.",
    "version": "1.0.4",
    "split_keywords": [
        "blur",
        "generator",
        "blur-image",
        "cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d16b6b255ea6e326ef465ed62711127590daf1dda99ed26b26a9c86e5bda601",
                "md5": "022aa2b4896fd027afe9539fc80faf0f",
                "sha256": "bfb7e919e52f527793b835065541cd6530c92624e78dfdf200faa80bf1077d43"
            },
            "downloads": -1,
            "filename": "BlurGenerator-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "022aa2b4896fd027afe9539fc80faf0f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10671,
            "upload_time": "2023-03-27T07:43:52",
            "upload_time_iso_8601": "2023-03-27T07:43:52.124298Z",
            "url": "https://files.pythonhosted.org/packages/6d/16/b6b255ea6e326ef465ed62711127590daf1dda99ed26b26a9c86e5bda601/BlurGenerator-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bbfe905fc32b5ec94774a19e08b5a27c015298a29af25c17b30fe815c5655252",
                "md5": "cb7770f29ece6a5c718b2f8f7cd99814",
                "sha256": "98921ea8749e4996e30d26b4310e2db95d9391f9b2fb7dbabf18600312238063"
            },
            "downloads": -1,
            "filename": "BlurGenerator-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "cb7770f29ece6a5c718b2f8f7cd99814",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 19102691,
            "upload_time": "2023-03-27T07:43:54",
            "upload_time_iso_8601": "2023-03-27T07:43:54.645031Z",
            "url": "https://files.pythonhosted.org/packages/bb/fe/905fc32b5ec94774a19e08b5a27c015298a29af25c17b30fe815c5655252/BlurGenerator-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-27 07:43:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "NatLee",
    "github_project": "Blur-Generator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "blurgenerator"
}
        
Elapsed time: 0.04736s