vigra
vigra copied to clipboard
skeleton border region issu
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:
Connected Comp:
Without Any Padding :
With Padding:
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
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).
(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