knime-ip / knip

KNIME Image Processing Extension
https://www.knime.com/community/image-processing
50 stars 10 forks source link

Segment Feature Node - Perimeter Computation #455

Open tibuch opened 7 years ago

tibuch commented 7 years ago

I am implementing Pixelbased Features in imagej-ops and took a look at the KNIP perimeter computation. It looks like there is a bug in the KNIP implementation:

https://github.com/knime-ip/knip/blob/master/org.knime.knip.core/src/org/knime/knip/core/features/CalculatePerimeter.java#L111-L115 a OutOfBoundsMirrorFactory.Single is used.

I assume this is wrong, because outline pixels touching the border will get mirrored and this will lead to a wrong convolution result, which will lead to different "length" of segments touching the border than segments within the image.

image The straight lines on top/bottom will have different length, than the straight lines in the middle.

To fix this bug, Views.extend(op, new OutOfBoundsMirrorFactory<BitType, Img<BitType>>( Boundary.SINGLE)) in https://github.com/knime-ip/knip/blob/master/org.knime.knip.core/src/org/knime/knip/core/features/CalculatePerimeter.java#L113-L114 should be changed to Views.extendValue(op, new BitType(false)). But the node has to be deprecated. Question: Should this be fixed in this node? Feature Calculator (BETA) will have the correct implementation, as soon as the feature set is complete.

dietzc commented 7 years ago

is it correct in Ops?