ITK5 - Bug in itkPolygonSpatialObject (SpatialObjectToImage3.cxx)

The example SpatialObjectToImage3.cxx does not create a binary image from a polygon using the new ITKv5, it only generates black images. The problem is probably in itkPolygonSpatialObject. Other spatial objects (i.e. itkEllipseSpatialObject, itkTubeSpatialObject, itkGaussianSpatialObject) work correctly. Do you know any way to fix it up?

Welcome to the community John!

@Stephen_Aylward should be able to offer some advice.

@johnaddams there have been a number of recent changes related to Spatial Objects – what version of ITK are you using?

I am using ITK version 5.0.0 (master branch). Although the example SpatialObjectToImage3.cxx follows the ITK5 migration rules, it does not work as expected.

There was a bug in the implementation of IsInsideObjectSpace(pnt) for the PolygonSpatialObject, this is now fixed in pull request #747.

Thanks for the report!

Thanks @Stephen_Aylward! But unfortunately, it seems that the bug is not completely fixed. The example SpatialObjectToImage3.cxx still doesn’t work using your latest ITKv5 commit. Could you please check this example out?

forum

Hello @johnaddams,

When you say that @Stephen_Aylward’s PR doesn’t completely solve your issue, do you mean that you downloaded his PR (as opposed to master)?

Thank you @fbudin for pointing out my mistake. Using @Stephen_Aylward’s PR works perfectly fine. My apologies, I was using before the master.

@Stephen_Aylward, thank you again for solving the bug so fast.

@johnaddams: Thanks for testing! I merged #752 which is the same as #747 with one style comment addressed. Hopefully you should be able to use ITK on master now.

The patch has now been merged.

1 Like