Python ndarray division
Question:
I have this piece of code
from scipy import misc
from numpy import fft
orig = misc.imread('lena256.png')
blur = misc.imread('lena256blur.png')
orig_f = fft.rfft2(orig)
blur_f = fft.rfft2(blur)
kernel_f = blur_f / orig_f # do the deconvolution
From another question here on stackoverflow (Link). But I know nothing about python. What is this line kernel_f = blur_f / orig_f
supposed to do ? Is it dividing element by element or its matrix division, that can be “rewritten” using matrix inverse ? I tried google that, but found nothing usefull. If someone could post me code in C that do the same (I am using alglib for mathematic, but there is no division of matrices, afaik).
Answers:
This is elementwise division. See NumPy for Matlab Users in the category of ndarray operators. ndarray: All operations (*, /, +, ** etc.) are elementwise
I have this piece of code
from scipy import misc
from numpy import fft
orig = misc.imread('lena256.png')
blur = misc.imread('lena256blur.png')
orig_f = fft.rfft2(orig)
blur_f = fft.rfft2(blur)
kernel_f = blur_f / orig_f # do the deconvolution
From another question here on stackoverflow (Link). But I know nothing about python. What is this line kernel_f = blur_f / orig_f
supposed to do ? Is it dividing element by element or its matrix division, that can be “rewritten” using matrix inverse ? I tried google that, but found nothing usefull. If someone could post me code in C that do the same (I am using alglib for mathematic, but there is no division of matrices, afaik).
This is elementwise division. See NumPy for Matlab Users in the category of ndarray operators. ndarray: All operations (*, /, +, ** etc.) are elementwise