Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

conv2 with NaNs?

671 views
Skip to first unread message

Temu Gautama

unread,
Dec 23, 2003, 3:01:40 AM12/23/03
to
Hi guys,

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

herbert(DOT)ramoser

unread,
Dec 23, 2003, 5:04:25 AM12/23/03
to

Does setting all NaN regions to zero solve your problem? If not what
should happen with the NaNs in the convolution?

-Herbert

Alois Schloegl

unread,
Dec 23, 2003, 5:42:44 AM12/23/03
to Temu Gautama

Temu Gautama wrote:


Try the attached function

and see if this is what you expect
pcolor(conv2nan(A,H));shading flat


Alois

conv2nan.m

Temu Gautama

unread,
Dec 23, 2003, 10:59:32 AM12/23/03
to
Hi 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

Temu Gautama

unread,
Dec 23, 2003, 11:00:54 AM12/23/03
to
Alois, I didn't see an attachment, there?

Tim Zaman

unread,
Jan 15, 2013, 1:03:10 PM1/15/13
to
Alois Schloegl <a.sch...@ieee.org> wrote in message <3FE81C24...@ieee.org>...
>
> (...)
>
>
> Try the attached function
>
> and see if this is what you expect
> pcolor(conv2nan(A,H));shading flat
>
>
> Alois
>
>
> (...)


Alois, this is EXCELLENT!
0 new messages