[ITK-users] itkConnectedThresholdImageFilter does not support Progress?
Bradley Lowekamp
blowekamp at mail.nih.gov
Tue Jun 9 10:16:29 EDT 2015
Hello,
I used SimpleITK in an IPython Jupiter Notebook to explore some of your questions. It can be found here:
http://nbviewer.ipython.org/github/blowekamp/SimpleITK-Notebook-Answers/blob/master/ConnectedThresholdAndOtherFilterPerformance.ipynb
2) I was able to reproduce you experiment that the Median filter was faster that either of the rank filters. However this is very dependent on the image size and the radius of the neighborhood.
3) I was able to confirm that the ConnectedThresholdImageFilter does report progress as the region is growing. This is either a problem with your Qt application or you have a very small region growing that is less the 1% of the image.
4) In the notebook I did a brief comparison of the Binary and Grayscale dilate. For binary images they will result in the same output. They implement different algorithms, so they have different performance characteristics. I'd recommend reading the InsightJournal article [1] [2], and their reference papers on the algorithms used.
HTH,
Brad
[1] http://hdl.handle.net/1926/173
[2] http://hdl.handle.net/1926/308
On Jun 8, 2015, at 5:21 PM, zagwin <zagwin at gmail.com> wrote:
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150609/35cbb5b9/attachment.html>
More information about the Insight-users
mailing list