[Insight-users] Inclusion of exception code in itkDenseFrequencyFilter.cxx crashes the program

Arunachalam Kana Kana.Arunachalam at fh-wels.at
Thu Aug 27 09:02:50 EDT 2009


Hi ,

 

I am using itkListSampleToHistogramGenerator.h to create a histogram. In
itkListSampleToHistogramGenerator.h,  itkDenseFrequencyContainer.h is
used

to construct the frequency bins. 

 

In the itkDenseFrequencyContainer.h, the FrequencyType is defined as
float.

 

In itk 3.12 revision the itkDenseFrequencyContainer.cxx, function
increase frequency is 

 

bool

DenseFrequencyContainer 

::IncreaseFrequency(const InstanceIdentifier id, const FrequencyType
value)

{

  if( id >= m_FrequencyContainer->Size() )

    {

    return false;

    }

  FrequencyType frequency = this->GetFrequency(id);

 

  const FrequencyType largestIntegerThatFitsInFloat = 16777216;

 

  if( largestIntegerThatFitsInFloat - frequency < value )

    {

    itkExceptionMacro("Frequency container saturated for Instance ");

    }

  else

    {

    (*m_FrequencyContainer)[id] = frequency + value; 

    }

 

  m_TotalFrequency += value;

 

  return true;

}

 

In my image dataset, frequency of one intensity (example: Intensity "0"
) exceeds the "16777216"  value, and my program

catches the exception, and crashes.  But my program was working fine
with the itk 3.10 revision. So checked the

itkDenseFrequencyContainer.cxx in itk 3.10 revision. This exception was
not available in the 3.10 revision (code below).

 

In itk 3.10 the itkDenseFrequencyContainer.cxx, function increase
frequency is 

bool

DenseFrequencyContainer 

::IncreaseFrequency(const InstanceIdentifier id, const FrequencyType
value)

{

  if( id >= m_FrequencyContainer->Size() )

    {

    return false;

    }

  FrequencyType frequency = this->GetFrequency(id) ;

  (*m_FrequencyContainer)[id] = frequency + value ; 

  m_TotalFrequency += value ;

  return true;

}

 

I would like to know:

1.       why is this checking required ?

2.       how to overcome the crash ?

 

Regards,

Kana

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090827/756c990e/attachment.htm>


More information about the Insight-users mailing list