I'm not sure about "numpy.array won't convert a matlab matrix directly", but py.numpy.array(I) works fine, so I don't think it's need to create a vector and reshape.
The following modified code will work fine.
py.importlib.import_module('silx');
py.importlib.import_module('numpy');
I = imread('ngc6543a.jpg');
I = I(:,:,3);
Im = medfilt2(I,[20,20]);
I = double(I);
npI = py.numpy.array(I);
npI2 = npI.copy();
pyIm = py.silx.math.medianfilter.medfilt(npI2,uint8(21),0);
pyIm = double(pyIm);
subplot(2,2,1)
imagesc(I)
title('original image')
subplot(2,2,2)
imagesc(Im)
title('matlab filter')
subplot(2,2,3)
imagesc(pyIm)
title('python filter')
Best Answer