Code Monkey home page Code Monkey logo

pyblur's Introduction

#Pyblur ##Python image blurring routines. Pyblur is a collection of simple image blurring routines.
It supports Gaussian, Disk, Box, and Linear Motion Blur Kernels as well as the Point Spread Functions used in Convolutional Neural Networks for Direct Text Deblurring.
Functions receive a PIL image as input, and return another as output.
Kernel sizes can either be specified as input, or randomized.
Finally, there's a RandomizedBlur function that applies a random type of blurring kernel with a random width/strength.

pypi: https://pypi.python.org/pypi?:action=display&name=pyblur&version=0.2.3

##Installation From Pip: pip install pyblur
Or alternatively git clone this repo and run locally

##Usage from pyblur import *

###Gaussian Blur Blurs image using a Gaussian Kernel

blurred = GaussianBlur(img, bandwidth)

Randomized kernel bandwidth (between 0.5 and 3.5)

blurred = GaussianBlur_random(img)

###Defocus (Disk) Blur Blurs image using a Disk Kernel

blurred = DefocusBlur(img, kernelsize)

Randomized kernel size (between 3 and 9)

blurred = DefocusBlur_random(img)

###Box Blur Blurs image using a Box Kernel

blurred = BoxBlur(img, kernelsize)

Randomized kernel size (between 3 and 9)

blurred = BoxBlur_random(img)

###Linear Motion Blur Blurs image using a Line Kernel

blurred = LinearMotionBlur(img, dim, angle, linetype)

####Parameters

  • dim Kernel Size: {3,5,7,9}
  • angle Angle of the line of motion. Will be floored to the closest one available for the given kernel size.
  • linetype = {left, right, full} Controls whether the blur kernel will be applied in full or only the left/right halves of it.

Randomized kernel size, angle, and line type

blurred = LinearMotionBlur_random(img)

PSF Blur

Blurs image using one of the Point Spread Functions (Kernels) used in:
Convolutional Neural Networks for Direct Text Deblurring

blurred = PsfBlur(img, psfid)

####Parameters

  • psfid Id of the Point Spread Function to apply [0, 99]

Randomized kernel size, angle, and line type

blurred = PsfBlur_random(img)

###Random Blur Randomly applies one of the supported blur types, with a randomized bandwidth/strenght.

blurred = RandomizedBlur(img)

pyblur's People

Contributors

lospooky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pyblur's Issues

No Disk

It says "Disk" in the description, which I would assume is Disk Blur, but there is no Disk anything?

RGB image?

Hi, it seems to work for grayscale images only? I get an error for RGB images.

python3 incompatibility

Hi,

I was using pip3 install pyblur but found cannot import pyblur after the installation.
error is like:
ModuleNotFoundError: No module named 'LineDictionary'

This is due to the different syntax for py2 and py3. To fix this issue, 3 places needs to modified.

  1. in pyblur/LinearMotionBlur.py line 8 change to : from .LineDictionary import LineDictionary
  2. in pyblur/Boxblur.py, change all from xxx import xxx =>from .xxx import xxx
  3. incompatibility in lickle load. change pyblur/PsfBlur.py", line 11:
    psfDictionary = pickle.load(pklfile) to psfDictionary = pickle.load(pklfile, encoding='latin1')

Then it should work.

Errors about scipy

File "C:/Users/15384/Desktop/deep_learning/end-to-end-for-chinese-plate-recognition/genplate.py", line 197, in generate
com = LinearMotionBlur_random(com)
File "C:\Users\15384\Desktop\deep_learning\end-to-end-for-chinese-plate-recognition\blur\linear_motion_blur.py", line 20, in LinearMotionBlur_random
return LinearMotionBlur(img, lineLength, lineAngle, lineType)
File "C:\Users\15384\Desktop\deep_learning\end-to-end-for-chinese-plate-recognition\blur\linear_motion_blur.py", line 25, in LinearMotionBlur
convolved = convolve2d(imgarray, kernel, mode='same', fillvalue=255.0).astype("uint8")
File "C:\Users\15384\Anaconda3\lib\site-packages\scipy\signal\signaltools.py", line 1033, in convolve2d
raise ValueError('convolve2d inputs must both be 2D arrays')
ValueError: convolve2d inputs must both be 2D arrays

The input image is (40, 148, 3).
Is this blur code only used to handle gray images ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.