[ITK-users] [ITK] Inside value and outside value for itk::OtsuThresholdImageFilter

沈庄明 zhuangming.shen at sphic.org.cn
Fri Apr 8 04:06:02 EDT 2016


Hi Tim,

Thank you for your prompt response. I got it.


Regards,

Zhuangming Shen
________________________________________
From: Timothee Evain <tevain at telecom-paristech.fr>
Sent: Friday, April 8, 2016 3:30 PM
To: 沈庄明
Cc: insight-users at itk.org
Subject: Re: [ITK] [ITK-users] Inside value and outside value   for     itk::OtsuThresholdImageFilter

Hi,

That's definitely not a bug, but how this was designed.

OtsuThresholdImageFilter uses the BinaryThresholdImageFilter to do the thresholding, and this filter allows to get only a part of the value range using 2 threshold values (lower/upper).
That's why you have the inside/outside notion : what is the output value of pixels inside/outside these 2 thresholds.

In the case of OtsuThreshold, the filter computes 1 optimal value and feeds it to the BinaryThresholder as the "Upper Threshold", and set the lower one as the minimum of your ValueType.
This will results in the "inside value" being the output value for the range that is lower than the calculated optimal threshold.

In your case, let say your have uchar range ([0,255]), and the calculated otsu threshold is for example 50.
If you set the inside value to 255 and the outside one to 0, you will have the darkest part as 255 because your threshold range is [0 (min of your value type) ,50], and the brightest as 0, which is your Fig3.

HTH,

Tim

----- Mail original -----
De: "沈庄明" <zhuangming.shen at sphic.org.cn>
À: insight-users at itk.org
Envoyé: Vendredi 8 Avril 2016 03:42:35
Objet: [ITK] [ITK-users] Inside value and outside value for     itk::OtsuThresholdImageFilter



Hi all,





It seems to be a bug for itk.OtsuThresholdImageFilter. When I use SetInsideValue(0) and SetOutsideValue(255), I got the result displayed in Fig. 2, where inside voxel value is 255 and outside voxel value is 0. Inversely, when I use SetInsideValue(255) and SetOutsideValue(0), I got the result displayed in Fig. 3, where the inside voxel value is 0 and the outside voxel value is 255. It seems totally inversely. Is that right? Have someone else met this situation before? Thanks in advance.








Regards,





Zhuangming Shen








=============== My code =================


import itk





reader = itk.ImageFileReader[itk.Image.SS3].New()


reader.SetFileName("ct.nrrd")


reader.Update()





otsu_filter = itk.OtsuThresholdImageFilter​[itk.Image.SS3, itk.Image.UC3].New()


otsu_filter.SetInput(reader.GetOutput())


otsu_filter.SetInsideValue(0)


otsu_filter.SetOutsideValue(255)


otsu_filter.Update()





writer = itk.ImageFileWriter[itk.Image.UC3].New()


writer.SetInput(otsu_filter.GetOutput())


writer.SetFileName("otsu.nrrd")


writer.Update()











Fig. 1 ct.nrrd











Fig. 2 otsu segmentation result for SetInsideValue(0) and SetOutsideValue(255)











Fig. 3 otsu segmentation result for SetInsideValue(255) and SetOutsideValue(0)










_____________________________________
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

_______________________________________________
Community mailing list
Community at itk.org
http://public.kitware.com/mailman/listinfo/community


More information about the Insight-users mailing list