MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Having problems finding skeleton of a binary image

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105666] Re: [mg105629] Having problems finding skeleton of a binary image
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Tue, 15 Dec 2009 07:24:03 -0500 (EST)
  • References: <200912121155.GAA19724@smc.vnet.net>

Hi,

in my Gonzales&Woold [1] they are using the same element for the erosion
and the opening.

img = ImageCrop[Image[ConstantArray[1, {25, 50}], "Bit"], {100, 100}]
kern = {{0, 1, 0}, {1, 1, 1}, {0, 1, 0}};

Fold[ImageAdd, First@#, Rest@#] &[
 ImageSubtract[#, Opening[#, kern]] & /@ NestWhileList[
   Erosion[#, kern] &, img, 
   Plus @@ Flatten@ImageData[ImageSubtract[#, Opening[#, kern]]] =!= 
     0 &]]

or in the way of the book you could define the function Sk(A) (page 543,
eq. 9.5-12) with

Sk[a_, b_, k_] := With[{akB = Nest[Erosion[#, b] &, a, k]},
  ImageSubtract[akB, Opening[akB, b]]
]

where a is the image, b is the structuring element and k is then number
of iterations. You take all images Sk[...] for k=1... until the erosion
a(-)kb is the empty image and add them together.

Cheers
Patrick

[1] http://www.imageprocessingplace.com/DIP-2E/dip2e_main_page.htm

On Sat, 2009-12-12 at 06:55 -0500, jalbers wrote:
> I am trying to find the skeletal subsets Skel(S;n) = (S (erosion) nE)
> - (S (erosion) nE) (open) E) for a simple rectangle.  Skel[n] is
> returning a completely black image for n=0,1,2,3,...
> 
> I think that I should be getting the classic dog bone shaped skeleton
> like you see with ImageAdjust[DistanceTransform[s]].  I am new to the
> concepts of morphological image processing.  Any help would be greatly
> appreciated.  Thanks
> 
> Here is some of the code I am trying to use:
> 
> EE = BoxMatrix[1]; (* structuring element *)
> nEE[n_] := BoxMatrix[n];
> Skel1[n_] := Erosion[s, nEE[n]]
> Skel2[n_] := Opening[Erosion[s, nEE[n]], EE]
> Skel[n_] := ImageSubtract[Skel1[n], Skel2[n]]
> 
> (* white rectangle with a black border *)
> s = Image[ArrayPad[ConstantArray[1, {90, 180}], 50]]
> 
> (* n=3 for example *)
> n = 3;
> Skel1[n]
> Skel2[n]
> Skel[n]
> 
> 



  • Prev by Date: Re: Finding simplest Fourier series between two given Fourier series
  • Next by Date: Re: Toolbar
  • Previous by thread: Having problems finding skeleton of a binary image using Lantuejoul's
  • Next by thread: Compute once question