[ITK] [ITK-users] OtsuMultipleThresholdsImageFilter creates asymmetric classes for symmetric a distribution
Dženan Zukić
dzenanz at gmail.com
Tue Oct 17 11:15:10 EDT 2017
Hi Frederik,
what happens if you set number of histogram bins to 129 or 127?
Regards,
Dženan
On Tue, Oct 17, 2017 at 10:35 AM, hellman <fredrik.hellman at gmail.com> wrote:
> Hi all,
>
> I am planning to use OtsuMultipleThresholdsImageFilter to segment an image
> into a number of classes. I started by testing it for a small image with
> only a single threshold to see that I understand how it works. The results
> surprise me though.
>
> I create a 1D-image with four pixels: 1000, 2000, 3000 and 4000. Computing
> a
> threshold to split this distribution into two classes of maximum
> between-class variance should give a threshold between 2000 and 3000.
> However, OtsuMultipleThresholdsImageFilter gives me a value 1996.17, which
> puts 1000 in one class and 2000, 3000, 4000 in the other class. This does
> not give the smallest between-class variance.
>
> The code that I tried can be found below. Do I misunderstand how this
> filter
> should work or is there a bug in its implementation?
>
> Running the following code with ITK 4.12.0 and ITK 4.12.2 prints 1996.17:
>
> #include <itkOtsuMultipleThresholdsImageFilter.h>
>
> typedef itk::Image<float, 1> ImageType;
> typedef itk::Image<int, 1> LabelImageType;
>
> int main(int argc, char *argv[])
> {
> typename ImageType::Pointer input = ImageType::New();
>
> ImageType::RegionType region;
> region.GetModifiableSize()[0] = 4;
> input->SetRegions(region);
> input->Allocate();
>
> ImageType::IndexType index;
> index[0] = 0;
> input->SetPixel(index, 1000);
> index[0] = 1;
> input->SetPixel(index, 2000);
> index[0] = 2;
> input->SetPixel(index, 3000);
> index[0] = 3;
> input->SetPixel(index, 4000);
>
> auto otsuFilter = itk::OtsuMultipleThresholdsImageFilter<ImageType,
> LabelImageType>::New();
> otsuFilter->SetInput(input);
> otsuFilter->SetNumberOfHistogramBins(128);
> otsuFilter->SetNumberOfThresholds(1);
> otsuFilter->Update();
>
> std::cout << otsuFilter->GetThresholds()[0] << std::endl;
>
> return 0;
> }
>
> Best wishes,
> Fredrik Hellman
>
>
>
> --
> Sent from: http://itk-users.7.n7.nabble.com/
> The ITK community is transitioning from this mailing list to
> discourse.itk.org. Please join us there!
> ________________________________
> 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/community/attachments/20171017/3d8677d1/attachment.html>
-------------- next part --------------
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
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
More information about the Community
mailing list