Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

image deblurring python

from scipy.ndimage import convolve

blurred_image = # Load image
kernel = # Load kernel/psf
learning_rate = # You need to find this yourself, do a logarithmic line search. Small rate will always converge, but slowly. Start with 0.4 and divide by 2 every time it fails.
maxit = 100

def loss(image):
    return np.sum(convolve(image, kernel) - blurred_image)

def gradient(image):
    return convolve(convolve(image, kernel) - blurred_image)

deblurred = blurred_image.copy()
for _ in range(maxit):
    deblurred -= learning_rate*gradient(image)
Comment

PREVIOUS NEXT
Code Example
Python :: django-tool-bar 
Python :: django iterate manytomanyfield template 
Python :: first step creating python project 
Python :: return variable python 
Python :: python calculator source code 
Python :: beautiful soup find 
Python :: list.add in python 
Python :: html element python 
Python :: df to dict 
Python :: write a python program to find the second largest number in a list 
Python :: python check if string contains one of characters list 
Python :: python while variable is not 
Python :: how to extract values from a dictionary 
Python :: python turtle 
Python :: to get the number of unique values for each column 
Python :: open multiple urls 
Python :: requesting with aiohttp 
Python :: ** in python 
Python :: how to append a tuple to a list 
Python :: what is indentation in python 
Python :: django insert bulk data 
Python :: shape 
Python :: python get pattern from string 
Python :: join function python 
Python :: best python books python 3 
Python :: merge pdf 
Python :: check if a word is a noun python 
Python :: queue peek python 
Python :: index of and last index of in python 
Python :: connect with database python 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =