[Insight-users] bug caught in BinaryMedianImageFilter example

Dan Mueller dan.muel at gmail.com
Mon Sep 22 15:26:43 EDT 2008


Hi Eliana,

Actually you haven't so much uncovered a bug as an inconsistency with
how ITK handles binary images, as detailed here:
   http://www.itk.org/Wiki/Proposals:Consistent_usage_of_label_and_binary_images

Basically some ITK binary filters assume input images with values 0
and 1, while others assume NumericTraits<PixelType>::Zero and
NumericTraits<PixelType>::max() (eg. 0 and 255 for unsigned char).
BinaryMedianImageFilter assumes the second (you can verify this by
looking at the constructor in itkBinaryMedianImageFilter.txx).

Therefore the example works as expected with an input image with
values 0 and 255 (notice the pixel type is unsigned char).

Hope this helps.

Regards, Dan

2008/9/22 Eliana Vasquez Osorio <e.vasquezosorio at erasmusmc.nl>:
> Hello itk-users,
>
> Just a little bug on the BinaryMedianImageFilter example
>  (Examples/Filtering/BinaryMedianImageFilter.cxx).
>
> It does not work unless you include ...
>
> *  filter->SetBackgroundValue( bgValue );  // in my case bgValue = 0;
>  filter->SetForegroundValue( fgValue );  // in my case fgValue = 1;
>
> *... before updating the filter (or the pipeline).
>
> It took me some time to find out that the error was in the code and not in
> my data. :-)  I hope someone else can benefit from this.
>
> Regards,
>
>
> --
> Eliana M. Vásquez Osorio
> PhD Student (OIO)
> Erasmus Medical Center - Daniel den Hoed Cancer Center
> Department of Radiation Oncology
> Groene Hilledijk 301 3075 EA Rotterdam
> The Netherlands
>
> T: +31 10 70 41 491
> F: +31 10 70 41 012
> E-mail: e.vasquezosorio at erasmusmc.nl
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list