AW: [Insight-users] itk::QtProgressBar doesn't work with itk::ThresholdSegmentationLevelSetImageFilter

jiang jiang at TI.Uni-Trier.DE
Wed, 7 Jan 2004 09:51:38 +0100


Hi Luis,
I have set some parameters for ThresholdSegmentationLevelSetImageFilter in
ls->Segment(), including
filter->SetMaximumIterations( 100 );
And I also try filter->SetNumberOfIterations( 100 ). But there are error
message in compiling. The "SetNumberOfIterations" is not member of
ThresholdSegmentationLevelSetImageFilter.
Is there some other possibilities that why process bar doesn't work?

Thank you very much!

Chunyan

-----Ursprungliche Nachricht-----
Von: Luis Ibanez [mailto:luis.ibanez at kitware.com]
Gesendet: Dienstag, 6. Januar 2004 19:08
An: jiang
Cc: ITK
Betreff: Re: [Insight-users] itk::QtProgressBar doesn't work with
itk::ThresholdSegmentationLevelSetImageFilter



Hi Chunyan,

The ThresholdSegmentationLevelSetImageFilter computes progress
based on the number of elapsed iterations versus the maximum
number of iterations allowed.

The actual progress is computed in the superclass

   Insight/Code/Algorithms/itkSegmentationLevelSetImageFilter.h

lines 438-440

>    // Estimate the progress of the filter
>     this->SetProgress( (float) ((float)this->GetElapsedIterations()
>                               / (float)this->GetNumberOfIterations()) );


In your code, it seems that you haven't set up explicitly
the maximum number of iterations. Therefore the default
value is being used, which is set in the constructor of
the superclass

    Insight/Code/Common/itkFiniteDifferenceImageFilter.h

and has the value:

      NumericTraits< unsigned int >::max()

which typically is  =  2^32 = 4x10^9

So...
what is happening in your case is that the elapsed iterations
are being compared to a very large number (2^32), hence the progress
gets reduced to a pityful value and probably rounded up to zero.

Please set the maximum number of iterations, probably a number
on the range 100 to 800 is a good initial guess. Something like

       filter->SetNumberOfIterations( 100 );

You can always refine this value once you observe how many
iteration it actually takes to compute the process on your
particular images.  Simply at the end of the filter execution
print out the value of

         filter->GetElapsedIterations();



Regards,


    Luis


-----------------
jiang wrote:

> Hi Luis,
> I try to connect QtProgressBar with
> itk::ThresholdSegmentationLevelSetImageFilter. The code is following. It
> works before when I connect it with itk::MedianImageFilter as a test.
>
> 	ThresholdSegmentationLevelSetImageFilterType::Pointer m_Filter;
> 	m_Filter=ls->GetLSFilter();//"ls" is the pointer of the class which does
> segmentation
>   // Connect the progress bar to the ITK processObject
>   qs->Observe( m_Filter.GetPointer() );
>
>   typedef itk::QtSlotAdaptor<ThresholdSegmentationLevelSetImageFilterType>
> SlotAdaptorType;
>   SlotAdaptorType slotAdaptor;
>
>   // Connect the adaptor to a method of the ITK filter
>   slotAdaptor.SetCallbackFunction( m_Filter, &
> ThresholdSegmentationLevelSetImageFilterType::Update );
>
>   // Connect the adaptor's Slot to the Qt Widget Signal
>   connect(LevelSetBt , SIGNAL(clicked()), &slotAdaptor, SLOT(Slot()) );
>
> And the button is also connected with the function which performs the
> threshold level set segmentation.
> connect( LevelSetBt, SIGNAL(clicked()), this, SLOT(LevelSetSegment()));
>
> LevelSetSegment()
> {
> 	ls->Segment();
> }
> In ls->Segment, all parameters for
> ThresholdSegmentationLevelSetImageFilterType are set up, and "Update()" is
> called.
>
> The progress bar works before when I connected it with
> itk::MedianImageFilter as a test. The code is exactly same. But it doesn't
> work now. I use Qt as UI, and ITK 1.4.
>
> Furtheremore I have the documents you recommended in the last email,
> however, I still have no idea about how to use IterationEvent to show
> something when ThresholdSegmentationLevelSetImageFilter is running
> iteratively, including the progress bar problem.
> Thank you for your kind help!
>
>
> Chunyan
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>