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

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

[Octave-bug-tracker] [bug #51884] [octave forge] (image) bwmorph(blackNw


From: anonymous
Subject: [Octave-bug-tracker] [bug #51884] [octave forge] (image) bwmorph(blackNwhiteMatrix, "thicken", 1) returns negated result (+ strange behavior at border)
Date: Mon, 4 Sep 2017 16:24:52 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:50.0) Gecko/20100101 Firefox/50.0

Follow-up Comment #9, bug #51884 (project octave):

I guess the "border" (padding margin) to be added needs to be large enough.
Otherwise we might fail to reach the corners. Please test your (HG1 version;
attached file #41717) this
way:


octave:11> test_bw = false(3,3); test_bw(3,1)=true;disp(test_bw);
  0  0  0
  0  0  0
  1  0  0

octave:12> bw=bwmorph(test_bw, 'thicken', 2)
bw =

  1  0  0
  1  1  0
  1  1  1

octave:13> bw=bwmorph(test_bw, 'thicken', Inf)
bw =

  1  1  0
  1  1  1
  1  1  1



If we use a large enough (say patch version HG1.1) padding
as in code: 


    case "thicken"
      if (n > 0)
        n_pad = 2 * min ([ max(size (bw)), n ]);
        bw_padded = padarray (bw, [n_pad, n_pad], "zeros");
        bw = bwmorph (! bw_padded, "thin", n);
        loop_once = true;
        morph = @(x) bwmorph (x, "diag");
        post_morph = @(x) ! x(1+n_pad : end-n_pad, 1+n_pad : end-n_pad);
      endif


Now, even our "academic" (synthetic) test case works (the image gets filled up
for n=4):


octave:18> test_bw = false(3,3); test_bw(3,1)=true;disp(test_bw);
  0  0  0
  0  0  0
  1  0  0
octave:19> bw=bwmorph(test_bw, 'thicken', 4)
bw =

  1  1  1
  1  1  1
  1  1  1


I guess this relates to the fact that the "thicken" operation actually is
implemented by its dual: thinning of the background.

Thanks for the code cleanup (I learned more about GNU Octave ;-)



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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