octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #46160] image package: normxcorr2 returns comp


From: Hartmut
Subject: [Octave-bug-tracker] [bug #46160] image package: normxcorr2 returns complex values sometimes
Date: Thu, 08 Oct 2015 20:00:43 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0

URL:
  <http://savannah.gnu.org/bugs/?46160>

                 Summary: image package: normxcorr2 returns complex values
sometimes
                 Project: GNU Octave
            Submitted by: hardy
            Submitted on: Do 08 Okt 2015 20:00:42 GMT
                Category: Octave Forge Package
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Inaccurate Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.0.0
        Operating System: Any

    _______________________________________________________

Details:

This happens with the latest Octave (version 4.0.0) and the latest image
package (version 2.4.1). Here is a little script to show the behavior:


clear;
a =  [ 252  168   50   1    59;
       114    0    0   0    0]./255;
b = [1  171  255  255  255  255  240   71  131  254   255  255  255;
    0       109  254  255  255  233   59    0  131  254  255   255  255;
   76       13  195  253  194   34    0   19  217  255  255   255  255;
  110       0    0    0    0    0    3  181  255  255  255  255   255;
  153       0    0    0    0    2  154  254  255  255  255  255   255]./255; 
c = normxcorr2(a,b);
max(imag(c(:)))


As you can see, there is a small imaginary part (~1e-8 ... 1e-9) in the result
c in this case. Unfortunatelly, this unexpected complex valued result can
spoil the following calculations :(

The source of this behavior seems to be somewhere in line 64 of normxcorr2.m

  b = convn (b.^2, a1) .- convn (b, a1).^2 ./ (prod (size (a)));


For the above listed sample values, the result of this code line becomes
slightly negative (~ -eps), and in the following code lines the square root of
this negative number will be returned (~ sqrt(-eps)).

Unfortunatelly, I don't understand good enough what this line 64 does. It
looks fancy to me, probably because it can also deal with ND-images. Could
someone with more insight maybe fix this?





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?46160>

_______________________________________________
  Nachricht gesendet von/durch Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]