[Insight-users] Dynamic Threshold Filter

Luis Ibanez luis.ibanez at kitware.com
Sun Mar 7 12:20:45 EST 2010


Hi Lassi,

Thanks for pointing out the Insight Journal paper:

   "An Adaptive Thresholding Image Filter"
   by Kishore Mosaliganti, Arnaud Gelas and Sean Megason
   http://www.insight-journal.org/browse/publication/702
   http://hdl.handle.net/10380/3133


That certainly can be helpful for what Christian is doing.

This paper provides a filter that locally computes
an Otsu threshold at every pixel of the image.

---


Christian,

Just for completeness,
we just wrote the filter that you were asking for.
Please find it attached to this email.

Starting from the code of the itkMeanImageFilter it took
20 minutes to modify it in order to compute the difference
between the input central pixel, the mean of the
neighborhood and then to threshold that value.

The core of the code is:

    while ( ! bit.IsAtEnd() )
      {
      sum = NumericTraits<InputRealType>::Zero;
      for (i = 0; i < neighborhoodSize; ++i)
        {
        sum += static_cast<InputRealType>( bit.GetPixel(i) );
        }

      InputRealType mean = sum / double(neighborhoodSize);
      InputRealType difference = bit.GetCenterPixel() - mean;

      if( difference > this->m_ThresholdValue )
        {
        it.Set( this->m_ForegroundValue );
        }
      else
        {
        it.Set( this->m_BackgroundValue );
        }

      ++bit;
      ++it;
      progress.CompletedPixel();
      }


Please find attached the source code,
along with a minimal test to run it.


This is, as the rest of ITK, distributed under a BSD license.


It will be great if you test this filter for your images and
post a report to the Insight Journal, so that we can add
the filter to the toolkit in a future release.


     Thanks


             Luis


----------------------------------------------------------------------------------
On Sun, Mar 7, 2010 at 10:09 AM, Lassi Paavolainen
<lassi.paavolainen at jyu.fi> wrote:
> Hi,
>
> On Sat, 6 Mar 2010, Luis Ibanez wrote:
>
>> Hi Christian,
>>
>> You could do:
>>
>> 1) Pass the input image through the
>>   MeanImageFilter (with your kernel size)
>>
>> 2) Subtract the outcome of (1) from the input
>>   image by using the SubtractImageFilter
>>
>> 3) Threshold the output of (2) with the standard
>>    BinaryThreshold image filter.
>>
>>
>> Of course, you could also implement this filter
>> by merging together the code of the Mean
>> subtract and threshold filters (not in a pipeline,
>> but as a single pass filter).
>>
>> If you take this last option, it will be great if you
>> share the filter with the ITK community by posting
>> the code as a paper to the Insight Journal   :-)
>>
>>     http://www.insight-journal.org
>
> This is exactly what itkDynamicThreshold3DImageFilter does in BioImageXD:
> http://bioimagexd.svn.sourceforge.net/viewvc/bioimagexd/bioimagexd/trunk/itkBXD/Algorithms/itkDynamicThreshold3DImageFilter.txx?revision=1568&view=markup
> http://bioimagexd.svn.sourceforge.net/viewvc/bioimagexd/bioimagexd/trunk/itkBXD/Algorithms/itkDynamicThreshold3DImageFilter.h?revision=1473&view=markup
>
> Its GPL licensed, but I think that if there is need for it, we can release
> it as BSD and make a Insight Journal article. Though, I don't have time for
> this before May.
>
> Maybe the Adaptive Thresholding Image Filter published in Insight Journal:
> http://www.insight-journal.org/browse/publication/702
>
> can already do the same thing and more. Haven't checked it yet.
>
> Lassi
>
>> -------------------------------
>> On Fri, Mar 5, 2010 at 1:24 PM, Christian Werner
>> <christian.werner at rwth-aachen.de> wrote:
>>>
>>> Hello!
>>>
>>> I didn't get to find a dynamic threshold filter in ITK, is there such? It
>>> is
>>> typically used to extract pixel/voxels who's value differ about a certain
>>> threshold from the average of a neigborhood in a given distance (kernel
>>> size).
>>>
>>> In contrast to the simple BinaryThresholdImageFilter it catches elements
>>> that "stand out" from the neighborhood.
>>>
>>> Any suggestions?
>>>
>>>
>>> Best regards,
>>> Christian
>>> _____________________________________
>>> 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.html
>>>
>>> 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://www.itk.org/mailman/listinfo/insight-users
>>>
>> _____________________________________
>> 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.html
>>
>> 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://www.itk.org/mailman/listinfo/insight-users
>>
>
> --
> Lassi Paavolainen, M.Sc
> Software Engineer, PhD Student in Computer Science
> BioImageXD (http://www.bioimagexd.net)
> University of Jyväskylä
> lassi.paavolainen at jyu.fi
> _____________________________________
> 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.html
>
> 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://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AdaptiveThresholding.tgz
Type: application/x-gzip
Size: 4391 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100307/af55d316/attachment.bin>


More information about the Insight-users mailing list