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: Thu, 31 Aug 2017 03:33:32 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0

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

In order to get a correct (i.e. not negated) result for "n==0" we 
test for this case ...


 case "thicken"

   if (n > 0)   
      ## 31-Aug-2017 MeJ:: going for a >>bwmorph(bw, 'thicken', n)<< and
including the "add border workaround"
      add_border = 2*(min([ max(size(bw)), n ]));
      bw_framed = false(size(bw,1)+(2*add_border),size(bw,2)+(2*add_border));
      lb1 = (add_border+1); ub1 = (size(bw,1)+add_border);
      lb2 = (add_border+1); ub2 = (size(bw,2)+add_border);
      bw_framed(lb1:ub1,lb2:ub2) = bw;
      bw = bwmorph (! bw_framed, "thin", n);
      loop_once = true;
      morph = @(x) bwmorph (x, "diag");
      post_morph = @(x) ! x(lb1:ub1,lb2:ub2);
   endif 
         
   ## --------- original code fragement (as of octave forge package image
2.6.1)
   ## This implementation also "thickens" the border. To avoid this,
   ## a simple solution could be to add a border of 1 to the reversed
   ## image.
   #  
   #    bw = bwmorph (! bw, "thin", n);
   #    loop_once = true;
   #    morph = @(x) bwmorph (x, "diag");




Test case:


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

octave:6> bw0=bwmorph(test_bw, 'thicken', 0)
bw0 =

  0  0  0
  0  0  0
  1  0  0





    _______________________________________________________

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]