vigra icon indicating copy to clipboard operation
vigra copied to clipboard

skeleton border region issu

Open DerThorsten opened this issue 6 years ago • 2 comments

Hi Ullrich ,

When using the skeletonizeImage I noticed that regions at the border have a strange behavior. In fact, when I zero-pad the labels passed to skeletonizeImage and un-pad after that, I get different results compared to the unpadded version:

Image: vbug

Connected Comp: figure_1

Without Any Padding : figure_1-1

With Padding: figure_1-2

Here is the code

import vigra
import numpy

img = vigra.impex.readImage('vbug.png')[...,0]
img = 255 - img
img = img.astype('uint32')

cc = vigra.analysis.labelImageWithBackground(img)
vigra.imshow(cc)


skeleton = vigra.filters.skeletonizeImage(cc) != 0
skeleton = vigra.taggedView(skeleton, "xy")
vigra.imshow(skeleton)

padded_cc = numpy.pad(cc, 1, mode='constant')
skeleton = vigra.filters.skeletonizeImage(padded_cc) != 0
skeleton = skeleton[1:-1,1:-1]
skeleton = vigra.taggedView(skeleton, "xy")
vigra.imshow(skeleton)

Greetings Thorsten

DerThorsten avatar Sep 12 '18 07:09 DerThorsten

This is expected because the underlying distance transform only considers distances to pixels inside the image domain. Looking at your results, the padding solution might be more desirable.

Besides this, two observations are strange: (1) Without apparent reason, regions behave quite differently in terms of skeleton side arms. (2) In the unpadded result, the skeleton of the upper left region is disconnected -- this shouldn't happen. It would be interesting to compare with results from flipped/rotated versions of the input. Theoretically, the skeleton should be equivariant (modulo tie breaking).

ukoethe avatar Sep 13 '18 09:09 ukoethe

(1) I totaly agree, all brush strokes have been made with same brush size. I was also suprised to see these results.

Flipping does not seem to change the result at all

DerThorsten avatar Sep 13 '18 11:09 DerThorsten