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: Wed, 30 Aug 2017 06:33:49 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0

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

// this is the final edition (I hope)

This is my suggestion for the "thicken" case:


    case "thicken"
      ## This implementation also "thickens" the border. To avoid this,
      ## a simple solution could be to add a border of 1 to the reversed
      ## image.

      ## 30-Aug-2017 MeJ:: going for a 
      ##                bwmorph(bw, 'thicken', n) 
      ##             with "add a border" workaround
      max_dim = max( size(bw) );
      add_border = 2 * ( min([ max_dim, 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);

      ## --------- original code fragement 
      ##           (as of octave forge package image 2.6.1)
      ##   bw = bwmorph (! bw, "thin", n);
      ##   loop_once = true;
      ##   morph = @(x) bwmorph (x, "diag");



Some Tests:


## 1.)
octave:61> test_bw = false(8,7); test_bw(8,1)=true; disp(test_bw);
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  1  0  0  0  0  0  0
octave:62>
octave:62> bb = bwmorph(test_bw, "thicken", 6)
bb =

  0  0  0  0  0  0  0
  1  0  0  0  0  0  0
  1  1  0  0  0  0  0
  1  1  1  0  0  0  0
  1  1  1  1  0  0  0
  1  1  1  1  1  0  0
  1  1  1  1  1  1  0
  1  1  1  1  1  1  1


## 2.)
octave:63> test_bw = false(8,7); test_bw(2,4)=true; disp(test_bw);
  0  0  0  0  0  0  0
  0  0  0  1  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0


octave:65> thickened_bw=bwmorph(test_bw, "thicken", 2)
thickened_bw =

  0  0  1  1  1  0  0
  0  1  1  1  1  1  0
  0  0  1  1  1  0  0
  0  0  0  1  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  0  0
  0  0  0  0  0  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]