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

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

[Octave-bug-tracker] [bug #51724] [octave forge] (image) imregionalmax m


From: Hartmut
Subject: [Octave-bug-tracker] [bug #51724] [octave forge] (image) imregionalmax misbehaves on float images
Date: Tue, 29 Aug 2017 14:02:10 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Follow-up Comment #8, bug #51724 (project octave):

Here is a generalized version of my code in comment #5 :


    if (isfloat (img))
      ## calculate the biggest difference between two neighboring pixels
      ## (this is always done with the maximum neighborhood, for code
simplicity)
      nd = ndims (img);
      num_neighbors = 3 ^ nd;
      pos_center = 1 + 0.5 * (num_neighbors-1);
      all_neighbors = [1:pos_center-1 , pos_center+1:num_neighbors];
      all_deltas = [];
      for n = all_neighbors
        filt = zeros (repmat(3, [1,nd]));
        filt(pos_center) = 1;
        filt(n) = -1;
        differences = imfilter (img, filt, "replicate");
        this_delta = min (abs (differences));
        all_deltas = [all_deltas, this_delta];
      endfor
      delta = min (all_deltas);
      ## float type regional maxima "only" need to be bigger by this delta
      recon = imreconstruct (img, img + delta, conn);
    else
      recon = imreconstruct (img, img + 1, conn);
    end


This version
* still has the fast run time (0.09s for peaks(300) on my PC)
** (The run time is probably not yet optimal, but it is way better than
before.)
* works fine on the sample data from comment #7
* should work fine for 2d, 3d and nd (float) images

What do you think of this version?

    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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