[ITK] [ITK-users] itkConnectedThresholdImageFilter does not support Progress?

zagwin zagwin at gmail.com
Mon Jun 8 17:21:00 EDT 2015


Hello Brad,

Thanks for your suggestions.
<1>I did compile my project in release mode, and the
ConnectedThresholdImageFilter does not show progress.

<2>I tried your suggested FastApproximageRankImageFilter, it works, however,
very strange, it is much slower than using medianfilter. 
First, I check this using my project and see the progress of my progressBar. 
Second, I created a simple project with two functions, the first is to load
image, the second is to run median and fast rank as this:
ProcessData()
{
        typedef itk::MedianImageFilter<InputImageType, InputImageType>
MedianFilterType;
	typedef itk::FastApproximateRankImageFilter<InputImageType, InputImageType> 
FastRankFilterType;
	typedef InputImageType::SizeType  ImageSizeType;

	MedianFilterType::Pointer smooth1 = MedianFilterType::New();
	FastRankFilterType::Pointer smooth2 = FastRankFilterType::New();

	ImageSizeType radius1;
	radius1.Fill(1);
	smooth1->SetRadius( radius1 );
	smooth2->SetRadius( radius1 );

	smooth1->SetInput(m_itkImage);
	smooth2->SetInput(m_itkImage);

	QTime time;
	time.start(); //ms
	int iter_num = 5;
	for (int i=0; i< iter_num; ++i)
	{
		smooth1->Modified();
		smooth1->Update();
	}
	int time_Diff = time.elapsed();
	std::cerr << "Median time ms  " << time_Diff << std::endl;
	
	time.start();
	for (int i=0; i< iter_num; ++i)
	{
		smooth2->Modified();
		smooth2->Update();
	}
	time_Diff = time.elapsed();
	std::cerr << "FastRank time ms  " << time_Diff << std::endl;
}
The result is "Median time ms 90" and "FastRank time ms 27998"

<3> I created simple project with one function to test
ConnectedThresholdImageFilter.
MainWindow::ProcessData()
{
       typedef itk::ConnectedThresholdImageFilter <InputImageType,
UCharImageType>  ConnectedThresholdFilterType;
	typedef InputImageType::IndexType SeedIndexType;

	ConnectedThresholdFilterType::Pointer  ccthreshold   =
ConnectedThresholdFilterType::New();

	ItkQtProgress *progress = new ItkQtProgress(this); 
	progress->Observe(ccthreshold.GetPointer());
	connect(progress, SIGNAL(postValue(float)), this,
SLOT(slot_progress(float)));

	ccthreshold->SetLower(-1000);
	ccthreshold->SetUpper(-300);
	ccthreshold->SetReplaceValue(255);

	SeedIndexType seed;
	seed[0] = 156;
	seed[1] = 250;
	ccthreshold->SetSeed(seed);

	ccthreshold->SetInput(m_itkImage);

	ccthreshold->Update();
}
void MainWindow::slot_progress(float progress)
{
	std::cout << "Progress value  " << progress << std::endl;
}

The result is "Progress value 0" and "Progress value 1", no other value, it
is the same as my "big" project using my progress bar. 
I also try this simple project to test others, such as MeadianFilter, it
DOES have other value beside 0/1

<4> I don't understand, since the output of ConnectedThresholdFilter is
Binary, why use GrayscaleDilateImageFilter other than
BinaryDilateImageFilter? I think the BinaryDilateFilter should be faster, am
I right?


Bradley Lowekamp wrote
> Please make sure you are compiling your code in Release mode. It can make
> over a 10X performance difference.
> 
> The median image filter is not fast for large regions. You may want to
> look into the FastApproximageRankImageFilter [1, 2], or just the
> RankImageFilter.
> 
> You can look at how The ConnectedThresholdImageFitler reports progress in
> the code [3]. It does as good of a job as possible reporting progress. It
> will go smoothly for the number of pixels in the region, then just at the
> end for the number of pixels not visited.
> 
> You may want to look into teh GrayscaleDilateImageFilter to do you binary
> morphology [4].
> 
> HTH,
> Brad
> 
> [1]
> http://www.itk.org/Doxygen/html/classitk_1_1FastApproximateRankImageFilter.html
> [2] http://www.insight-journal.org/browse/publication/160
> [3]
> https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Segmentation/RegionGrowing/include/itkConnectedThresholdImageFilter.hxx#L268-L328
> [4]
> http://www.itk.org/Doxygen/html/classitk_1_1GrayscaleDilateImageFilter.html





--
View this message in context: http://itk-users.7.n7.nabble.com/itkConnectedThresholdImageFilter-does-not-support-Progress-tp35782p35785.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
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.php

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://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list