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

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

[Octave-bug-tracker] [bug #56141] [octave forge] (image) bwmorph option


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #56141] [octave forge] (image) bwmorph option 'endpoints' not implemented
Date: Sat, 20 Apr 2019 16:22:30 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299

Follow-up Comment #2, bug #56141 (project octave):

ok, I didn't dive into that python code, but just playing with your 3 step
process the following seems to work:



%stencil
>> A = [1,1,1;1,0,1;1,1,1]
A =

   1   1   1
   1   0   1
   1   1   1

%single line image
>> B = logical([0,0,0,0,0,0,0,0,0,0,0,0,0,0;...
                0,0,1,1,1,1,1,1,1,1,1,1,0,0;...
                0,0,0,0,0,0,0,0,0,0,0,0,0,0])
B =

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

%find number of neighbors
>> C = convn(B,A,"same")
C =

   0   1   2   3   3   3   3   3   3   3   3   2   1   0
   0   1   1   2   2   2   2   2   2   2   2   1   1   0
   0   1   2   3   3   3   3   3   3   3   3   2   1   0


%find pixels from image with only 1 neighbor
>> D = and(B,C==1)
D =

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



tested it on the skeleton image on the matlab help page and it seems to find
the endpoints properly.

I just peeked at that function.  seems it expects each case to output a morph
anonymous function that is then applied to the image at the end. So I need to
turn that into a one line function. 

I think this should work:



>> morph = @(x) and(x,conv(x,[1,1,1;1,0,1;1,1,1],'same')==1);

>> morph(B)
ans =

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



I'll work up a patch.


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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