Does anybody have a 2D convolution function that can handle NaNs (the
NaNs should not be taken into account into the convolution sum)?
It's fairly straightforward to code, but I was wondering if there's
an efficient implementation around. An example problem:
>> A = randn(100,100);
>> INDr=randperm(10000);A(INDr(1:100))=NaN;
>> pcolor(A); shading flat
>> [x y]=meshgrid(-2:4/24:2);H=exp(-(x.^2+y.^2)./2);
>> pcolor(conv2(A,H));shading flat
Most of the convolution contains NaNs, since it is set to NaN if at
least one of the values within the region (size(H)) is NaN.
???
Temu
Does setting all NaN regions to zero solve your problem? If not what
should happen with the NaNs in the convolution?
-Herbert
> Does setting all NaN regions to zero solve your problem? If not
> what
> should happen with the NaNs in the convolution?
You're absolutely right! I was a bit confused (was thinking about
mean, rather than sum).
Thanks!
Temu