[Insight-users] Median filter on Volume: Performance
Gaëtan Lehmann
gaetan.lehmann at jouy.inra.fr
Thu Feb 24 04:39:35 EST 2011
Hi Mark,
I don't think you'll find an example for this specific class, but the
usage is the same as for all the classes which are inheriting
KernelImageFilter.
Typically, something like:
typedef itk::Image<signed short, 2>
ImageType;
typedef itk::FlatStructuringElement<2> SEType;
typedef itk::RankImageFilter<ImageType, ImageType, SEType>
FilterType;
FilterType::Pointer filter = FilterType::New();
SEType::RadiusType rad;
rad.Fill(10);
filter->SetKernel( SEType::Ball( rad ) );
Regards,
Gaëtan
Le 23 févr. 11 à 19:19, sacrif a écrit :
>
> Hi Gaëtan!
> Hi John!
>
> Thank you for your replies! I really used the Debug mode, and the
> computation already accelarated significantly with RelDebInfo
> compilation.
>
> For the previous test run I used a volume of 96^3 and a filter of
> 10^3. Now
> I am running a volume with 256^256^128 and a filter of 20^3. This is
> running
> for 30 minutes now. So I still hope to find a faster solution. Maybe
> with
> the RankImageFilter.
>
> Are there any examples on the usage of the RankImageFIlter.
> Especially on
> how to define the neighborhood? At least I could not find any ones
> included
> which are part of the ITK-Examples.
>
> Regards,
> Mark
>
>
>
> Gaëtan Lehmann-2 wrote:
>>
>>
>> Hi Mark,
>>
>> What is the image size you are trying to filter?
>>
>> Please make sure that your application is built in Release mode -
>> this
>> can make a HUGE difference.
>>
>> For the efficiency and the spherical neighborhood, you may want to
>> try
>> the RankImageFilter which is in the Review directory.
>> For large neighborhoods, it may improve significantly the
>> performance.
>>
>> Regards,
>>
>> Gaëtan
>>
>>
>>
>> Le 23 févr. 11 à 14:36, sacrif a écrit :
>>
>>>
>>> Hello!
>>>
>>> Actually I simply want to load a volume, run a median filter on it
>>> and write
>>> the resulting volume back to disk. Therefore I implemented the
>>> following
>>> code:
>>>
>>>
>>> typedef signed short PixelType;
>>> static const unsigned int Dimension = 3;
>>> typedef itk::Image<PixelType, Dimension> InputImageType;
>>> typedef itk::Image<PixelType, Dimension> OutputImageType;
>>> typedef itk::ImageFileReader<InputImageType> ReaderType;
>>> typedef itk::ImageFileWriter< InputImageType > WriterType;
>>> typedef itk::MedianImageFilter< InputImageType, OutputImageType >
>>> MedianFilterType;
>>>
>>> void MyClass::createMedianHdrFile(std::string filename)
>>> {
>>> ReaderType::Pointer reader = ReaderType::New();
>>> reader->SetFileName(filename.c_str());
>>>
>>> MedianFilterType::Pointer medianFilter = MedianFilterType::New();
>>> InputImageType::SizeType indexRadius;
>>> indexRadius[0] = 10; // radius along x
>>> indexRadius[1] = 10; // radius along y
>>> indexRadius[2] = 10; // radius along z
>>> medianFilter->SetRadius( indexRadius );
>>> medianFilter->SetInput(reader->GetOutput());
>>>
>>> std::string fnNoEnding = getFilenameWithErasedEnding(filename,
>>> ".hdr");
>>> std::string fnNewEnding = getFilenameWithNewEnding(fnNoEnding,
>>> "_Median.hdr");
>>>
>>> WriterType::Pointer writer = WriterType::New();
>>> writer->SetFileName( fnNewEnding.c_str());
>>> writer->SetInput( medianFilter->GetOutput() );
>>> writer->Update();
>>> cout << "Median End" << endl;
>>> }
>>>
>>>
>>> Basically this works if I use a very small filter with
>>> "indexRadius[0/1/2] =
>>> 1;". However, as soon as I use "indexRadius[0/1/2] = 10;" the
>>> calculation
>>> seems to take for ever.
>>> In the meanwhile the program ran for approximately 3 hours and did
>>> not
>>> finish yet. Is it really possible that the calculation of a "median
>>> volume"
>>> takes such a long time? And is there any way to reduce this time
>>> span?
>>>
>>> My input and output volume are in the Analyze format. For the
>>> current test
>>> run my input and output volume dimensions are 96x96x96 and the
>>> filter size
>>> is 10x10x10. However, I would also like to create "median volumes"
>>> of even
>>> larger data sets and with larger Filter dimensions.
>>> The test input volume min and max intensity are -1093 and 1086,
>>> respectively.
>>>
>>> Additionally I wanted to ask whether there is a simple way to run
>>> apply a
>>> spherical median filter of a certain radius instead of using the
>>> cuboid
>>> defined by "indexRadius[0/1/2]".
>>>
>>> Thank you for your help & Kind regards
>>> Mark
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Median-filter-on-Volume%3A-Performance-tp30994977p30994977.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.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
>>
>>
>>
>> _____________________________________
>> 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.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
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Median-filter-on-Volume%3A-Performance-tp30994977p30997534.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.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/20110224/6072a419/attachment.pgp>
More information about the Insight-users
mailing list