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

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

[Octave-bug-tracker] [bug #62192] [octave forge](image) bwdist gives inc


From: Anders Höglund
Subject: [Octave-bug-tracker] [bug #62192] [octave forge](image) bwdist gives incorrect result in rare cases
Date: Wed, 16 Mar 2022 07:13:24 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?62192>

                 Summary: [octave forge](image) bwdist gives incorrect result
in rare cases
                 Project: GNU Octave
            Submitted by: andersh
            Submitted on: Wed 16 Mar 2022 11:13:22 AM UTC
                Category: Octave Forge Package
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: other
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

Tested with Octave 6.4.0 on Ubuntu with image from repository as well as
Octave 4.4.0 on Debian with image 2.10.0


pkg load image
a = zeros(200,200);
a(158,100) = 1;
a(141,141) = 1;
a(156,115) = 1;
d = bwdist(a);

d(100,100)
% Gives ans =  57.983
% Expected 57.974

sqrt((141-100)**2 + (141-100)**2)
% Gives ans =  57.983

sqrt((156-100)**2 + (115-100)**2)
% Gives ans =  57.974


bwdist finds the shortest distance from 100,100 to be to the pixel at 141,141
while the actual shortest distance is to the pixel at 156,115.

The algorithm is based on the assumption that the closest pixel can be found
among the closest pixel of the surrounding eight points even though the
distance might need to be recalculated.  This is not true in the discrete case
as the above example illustrates.

I have no idea if there are any other algorithm that is as fast as the current
one but always give correct results.  The error is fairly small so a better
fix might be to add to the documentation that there might be a small error in
rare cases.  As far as I am concerned, the current implementation suffices for
my application.





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62192>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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