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).

Asked By: Martin Perry

||

Answers:

This is elementwise division. See NumPy for Matlab Users in the category of ndarray operators. ndarray: All operations (*, /, +, ** etc.) are elementwise

Answered By: Bort
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.