[SciPy-user] ndimage.convolve and NaN...

Eike Welk eike.welk@gmx....
Mon Jul 2 11:22:12 CDT 2007


On Monday 02 July 2007 15:20, fred wrote:
> anirudh vij a écrit :
> > hi fred,
> > this is'nt a solution,but you might try replacing NaN by 0.That
> > would ensure that they have no effect on the surrounding pixels.
>
> Hmm, 0 are _real_ values.
>
> > Edges work fine because of padding.
>
> Yes, but can't we think replace NaN by padding ?

Padding with zero is one of the possible padding modes. You could just 
choose this and say that the results are consistent this way. From a 
quick look at:
http://www.scipy.org/SciPyPackages/Ndimage
mode="constant", cval=0   
should do it.

Maybe you could use morphological operators to get an effect 
comparable to the nearest mode:
1. replace nan with 0
2. use dilation or closing to copy the neighboring values into the 
holes.
3. use the results of the morphological operators only where the holes 
were.

Regards,
Eike.


More information about the SciPy-user mailing list