[Insight-users] ProgressEvent and pipes ?

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Mon Aug 31 09:42:29 EDT 2009


Le 31 août 09 à 12:26, Maximilien Renard a écrit :

> Hi there again,
>
> So actually I'm facing another problem :
>
> When, in my callback, I print the output of
> processObject->GetProgress(), the value is not limited to [0;1]. I get
> values like 2.8,...
>
> How is that possible ? Here is the code of my Callback function and of
> my median filter. Am I doing something wrong ?

It may be a bug in one on the filter you use, but I'm quite sure  
MedianImageFilter and RescaleIntensityImageFilter are ok on that side.  
Or you using other kind of filters?
You can check the progress report of a filter by adding a line like  
this one before calling Update():

   itk::SimpleFileWatcher watcher( median, "median" );

It will display the progress report event sent by the filters on the  
standard output.

reinterpret_cast seems to be a good place to make a mistake. Are you  
sure to manipulate the right type there?

Gaëtan



>
> Thank you !
>
> Regards,
>
>
> Maximilien
>
> void CVolumeData::ITKProgressCallback(itk::Object * caller, const
> itk::EventObject &event, void * clientData) {
> 	itk::ProcessObject * processObject = (itk::ProcessObject *)caller;
>
> 	if (typeid(event) == typeid(itk::ProgressEvent)) {
> 		CVolumeData * VolumeData = reinterpret_cast<CVolumeData  
> *>(clientData);
>
> 		if(VolumeData != NULL)
> 			VolumeData->UpdateProgressDialog(processObject->GetProgress());
> 	}
> }
>
> void CVolumeData::Median(int Radius) {
> 	typedef itk::MedianImageFilter < ITK3DImageType, ITK3DImageType>  
> FilterType;
> 	FilterType::Pointer Filter = FilterType::New();
>
> 	typedef itk::CStyleCommand CommandType;
> 	typedef CommandType::Pointer CommandPointer;
>
> 	CommandPointer ProgressDialogCallback = CommandType::New();
>
> 	ProgressDialogCallback- 
> >SetCallback((CommandType::FunctionPointer)&ITKProgressCallback);
> 	ProgressDialogCallback->SetClientData(this);
>
> 	ITK3DImageType::SizeType indexRadius;
> 	indexRadius[0] = Radius;
> 	indexRadius[1] = Radius;
> 	indexRadius[2] = Radius;
> 	Filter->SetRadius(indexRadius);
>
> 	Filter->SetInput(GetITK3DImage());
>
> 	unsigned long int ObserverID1 =
> Filter->AddObserver(itk::ProgressEvent(), ProgressDialogCallback);
>
> 	typedef itk::RescaleIntensityImageFilter<ITK3DImageType,
> ITK3DImageType> RescaleFilterType;
> 	RescaleFilterType::Pointer RescaleFilter = RescaleFilterType::New();
>
> 	unsigned short Min, Max;
> 	GetMinMaxValue(Min, Max);
>
> 	RescaleFilter->SetInput(Filter->GetOutput());
> 	RescaleFilter->SetOutputMaximum(Max);
> 	RescaleFilter->SetOutputMinimum(Min);
> 	GetProgressDialog()->close();
>
> 	unsigned long int ObserverID2 =
> RescaleFilter->AddObserver(itk::ProgressEvent(),
> ProgressDialogCallback);
>
> 	RescaleFilter->Update();
> 	SetITK3DImage(RescaleFilter->GetOutput());
>
> 	if(m_MainView != NULL)
> 		for(unsigned int i = 0, size = m_MainView->GetImageSubView().size();
> i < size; i++) {
> 			m_MainView->GetImageSubView().at(i)->PrepareCache();
> 		}
>
> 	Filter->RemoveObserver(ObserverID1);
> 	RescaleFilter->RemoveObserver(ObserverID2);
>
> 	GetProgressDialog()->close();
> }
>
>
>
> 2009/8/31 Maximilien Renard <iixamaxii at gmail.com>
>>
>> Ok, so I guess I have no other choice than change what I've already  
>> done!
>>
>> Thank you very much,
>>
>> Regards,
>>
>>
>> Maximilien Renard
>>
>> 2009/8/31 Karthik Krishnan <karthik.krishnan at kitware.com>
>>>
>>> On Sun, Aug 30, 2009 at 4:16 PM, Maximilien Renard <iixamaxii at gmail.com 
>>> > wrote:
>>>>
>>>> Dear ITK Users,
>>>>
>>>> I'm facing a problem. I was not able to figure out how to get the  
>>>> progression of multiple filters linked together via a pipe  
>>>> (meaning the input of the second filter is the output of the  
>>>> first : Filter2->SetInput(Filter1->GetOutput());
>>>>
>>>> I'm currently setting the observer on the last filter but it only  
>>>> sends the progressEvent when the 2nd filter starts.
>>>
>>> That is the expected behaviour. Filter2 will emit a progress event  
>>> only when Filter2's is doing its job. Its not going to forward  
>>> progress events that result from updates down the pipeline. For  
>>> that you should observe filter1 as well.
>>>
>>> --
>>> karthik
>>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.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

-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr  http://www.itk.org
http://www.mandriva.org  http://www.bepo.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090831/83cf900e/attachment.pgp>


More information about the Insight-users mailing list