[Insight-users] ProgressEvent and pipes ?

Maximilien Renard iixamaxii at gmail.com
Mon Aug 31 06:26:39 EDT 2009


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 ?

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
>


More information about the Insight-users mailing list