2012/4/16 Jordi Gutiérrez Hermoso <jord...@octave.org>

> 2012/4/16 Carnë Draug <carandraug+...@gmail.com>:
> > On 16 April 2012 02:04, Sunghyun Cho <sodo...@gmail.com> wrote:
> >> Thanks for the reply, Carnë.
> >> I tracked down the source of the bug, and found that conv2 works
> >> incorrectly, when the shape parameter is 'valid'.
> >> imfilter uses filter2, and filter2 calls conv2, which causes the
> problem.
> >> It looks like there is already a bug report about this.
> >
> > OK. Just for sake of completeness, I'll add that the bug report in
> > question is #34893 and is marked to be fixed for the 3.8 releases
> > https://savannah.gnu.org/bugs/?func=detailitem&item_id=34893
>
> There is still no fix for that bug. I tried to attack it, but it looks
> like the bug is in the Fortran code, and I'm having trouble
> understanding that code. If you care to help, it looks like the bug is
> somewhere here in the *conv2.f functions:
>
>
> http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra
>
> Thanks,
> - Jordi G. H.
>


I think I figured out how to fix it.

The inner convolution routines have some bug.
Following is a part of dconv2.f

65<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l65>integer
ma,na,mb,nb
66<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l66>double
precision a(ma,na),b(mb,nb)
67<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l67>double
precision c(ma-mb+1,na-nb+1)
68<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l68>integer
i,j,k
69<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l69>external
daxpy
70<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l70>do
k = 1,na-nb+1
71<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l71>do
j = 1,nb
72<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l72>do
i = 1,mb
73<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l73>call
daxpy(ma-mb+1,b(i,j),a(mb+1-i,k+j-1),1,c(1,k),1)
74<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l74>end
do
75<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l75>end
do
76<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l76>end
do
77<http://hg.savannah.gnu.org/hgweb/octave/file/a459d42bb0a6/libcruft/blas-xtra/dconv2.f#l77>end
subroutine

Line 73 has a bug.
The column indices of a and b moves in the same direction in the current
implementation.
It should be reversed. It might be fixed like below:

call daxpy(ma-mb+1,b(i,j),a(mb+1-i,k+nb-j),1,c(1,k),1)

I hope someone to be able to double-check this.

Thanks,
Sunghyun

------------------------
Sunghyun Cho
http://scho.pe.kr
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to