[ITK-users] Python Bindings, Templates, and ConfidenceConnectedImageFilter
Bradley Lowekamp
blowekamp at mail.nih.gov
Fri Jun 12 13:05:23 EDT 2015
Justin,
The output of the ConfidenceConnectedImageFilter is a binary image. The output image only has 2 value the background ( 0 ) and the "ReplaceValue". While the templated code with a float output pixel would allow you to set the replace value to say an approximation of PI, the output image would still just have two value. Using a unsigned char output pixel type works for most normal cases. If not casting the output is not too hard.
Brad
On Jun 12, 2015, at 12:37 PM, Porter, Justin <porterj at wusm.wustl.edu> wrote:
> Thanks for your quick and helpful response!
>
> Whatever version of ITK I am running has the GetTypes method, and it looks like ConfidenceConnectedImageFilter allows 2 and 3 dimensional doubles, floats, SS, and UC on the input end, but only 2 and 3 dimensional UC and SS as output types.
>
> The output from ConfidenceConnectedImageFilter.GetTypes():
>
>> <itkTemplate itk::ConfidenceConnectedImageFilter>
>> Options:
>> [<class 'itkImagePython.itkImageD2'>, <class 'itkImagePython.itkImageSS2'>]
>> [<class 'itkImagePython.itkImageD2'>, <class 'itkImagePython.itkImageUC2'>]
>> [<class 'itkImagePython.itkImageD3'>, <class 'itkImagePython.itkImageSS3'>]
>> [<class 'itkImagePython.itkImageD3'>, <class 'itkImagePython.itkImageUC3'>]
>> [<class 'itkImagePython.itkImageF2'>, <class 'itkImagePython.itkImageSS2'>]
>> [<class 'itkImagePython.itkImageF2'>, <class 'itkImagePython.itkImageUC2'>]
>> [<class 'itkImagePython.itkImageF3'>, <class 'itkImagePython.itkImageSS3'>]
>> [<class 'itkImagePython.itkImageF3'>, <class 'itkImagePython.itkImageUC3'>]
>> [<class 'itkImagePython.itkImageSS2'>, <class 'itkImagePython.itkImageSS2'>]
>> [<class 'itkImagePython.itkImageSS2'>, <class 'itkImagePython.itkImageUC2'>]
>> [<class 'itkImagePython.itkImageSS3'>, <class 'itkImagePython.itkImageSS3'>]
>> [<class 'itkImagePython.itkImageSS3'>, <class 'itkImagePython.itkImageUC3'>]
>> [<class 'itkImagePython.itkImageUC2'>, <class 'itkImagePython.itkImageSS2'>]
>> [<class 'itkImagePython.itkImageUC2'>, <class 'itkImagePython.itkImageUC2'>]
>> [<class 'itkImagePython.itkImageUC3'>, <class 'itkImagePython.itkImageSS3'>]
>> [<class 'itkImagePython.itkImageUC3'>, <class 'itkImagePython.itkImageUC3'>]
>
> Is this by design? In the example script, both the input and the output for ConfidenceConnectedImageFilter are 3d floats…
>
> If not, I would be happy to try to fix the issue and commit a fix if there are guidelines somewhere for doing so.
>
> Cheers,
> Justin
>
>> On Jun 12, 2015, at 10:26 AM, Michka Popoff <michkapopoff at gmail.com> wrote:
>>
>> Hi
>>
>> one good way to know which types are available is to use the GetTypes method on your template (before calling New). This method way introduced in 4.7 or after, I don't remember. But it is definitively available in 4.8 rc 1.
>>
>> I am not in front on a computer so please check this out yourself. Looking at the code we wrap float combinations here:
>> https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Segmentation/RegionGrowing/wrapping/itkConfidenceConnectedImageFilter.wrap
>>
>> Michka
>>
>>
>>
>> Envoyé de mon iPhone
>>
>> Le 12 juin 2015 à 17:03, Porter, Justin <porterj at wusm.wustl.edu> a écrit :
>>
>>> Hey all,
>>>
>>> I’m just getting started with ITK, and I’m using the python bindings, which are really awesome. It looks like it was a fair bit of work to get such a heavily templated library to work in Python, but it’s really nice to be able to build scripts in python!
>>>
>>> I set out to reimplement Slicer’s “Simple Region Growing Segmentation” using ITK-Python, but I keep getting an error when I try to define a ConfidenceConnectedImageFilter template on a 3d float (and double, too). IMG_F == itk.Image[itk.F, 3] elsewhere in the script.
>>>
>>>> Traceback (most recent call last):
>>>> File "simple_region_growing_segmentation.py", line 169, in <module>
>>>> sys.exit(main(sys.argv))
>>>> File "simple_region_growing_segmentation.py", line 154, in main
>>>> args.seed)
>>>> File "simple_region_growing_segmentation.py", line 98, in attach_connect
>>>> ccif = ConfidenceConnectedImageFilter[IMG_F, IMG_F].New()
>>>> File "/home/jporter/usr/local/ITK/bin/Wrapping/Generators/Python/itkTemplate.py", line 263, in __getitem__
>>>> (str(parameters), self.__name__))
>>>> KeyError: "itkTemplate : No template (<class 'itkImagePython.itkImageF3'>, <class 'itkImagePython.itkImageF3'>) for the itk::ConfidenceConnectedImageFilter class"
>>>
>>> I’m pretty sure I built the bindings appropriately to get float support:
>>>
>>>> cmake -DITK_USE_REVIEW=ON -DITK_WRAP_PYTHON=ON -DBUILD_SHARED_LIBS=ON -DITK_LEGACY_SILENT=ON -DITK_WRAP_float=ON -DITK_WRAP_rgb_unsigned_char=ON -DITK_WRAP_vector_double=ON -DITK_WRAP_complex_double=ON -DITK_WRAP_double=ON
>>>
>>> Interestingly, I can build a CurvatureFlowImageFilter or a CastImageFilter templated against 3d floats. I can also instantiate a ConfidenceConnectedImageFilter templated against itk.UC (presumably unsigned char?). That made me think that it’s not possible to build a ConfidenceConnectedImageFilter templated on floats, but the ConfidenceConnected example segmentation script does just that.
>>>
>>> I’d love to hear thought/suggestions as to how I can proceed!
>>>
>>> Cheers,
>>> Justin
>>>
>>>
>>>
>>> The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.php
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/insight-users
>
>
>
>
> The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150612/8ef526c7/attachment.html>
More information about the Insight-users
mailing list