I was trying to convert a piece of code in Matlab to python. There I could find a Standard deviation filter function "stdfilt()" for which I could not find any equivalent API in python. The Matlab code is given below,
Ig_med = medfilt2(Input_Image);
h_gauss = fspecial('gaussian',11,2);
h_avg = fspecial('average',121);
I = imfilter(Ig_med,h_gauss,'corr','replicate');
P = stdfilt(I,ones(121));
P = P.^2;
Q = imfilter(P,h_avg,'corr','replicate');
Can anyone help me out in implementing the above piece of code in Python ?
Thanks in Advance
I found something on
https://nickc1.github.io/python,/matlab/2016/05/17/Standard-Deviation-(Filters)-in-Matlab-and-Python.html
from scipy.ndimage.filters import generic_filter
import numpy as np
I_filt = generic_filter(I, np.std, size=3)
maybe it can help! (not you I guess, given the 3 years delay, but someone on the net)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With