[ITK-users] [ITK] Inside value and outside value for itk::OtsuThresholdImageFilter
Timothee Evain
tevain at telecom-paristech.fr
Fri Apr 8 03:30:03 EDT 2016
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