[Insight-users] ImageFilter problems

Bill Lorensen bill.lorensen at gmail.com
Fri Dec 23 12:44:21 EST 2011


itk is a demand driven pipelined system. Typically you set the input
to the next filter to be the output of the previous filter. Setting
the input/output chain just establishes the pipeline and does not
execute it. When you do an Updtae() on the last filter, the pipeline
executes.

averageimage=shFilter->GetOutput() is OK, but in your first email you had said:
shFilter->SetInput( averageimage );
shFilter->SetSValue(0.5);
//  shFilter->Update();
averageimage =  shFilter->GetOutput();

This modified averageimage was was the input to shFilter.


Please post a complete small, compilable example that fails. Including
snippets in e-mails is too prone to error and misinterpretation.

thanks,

Bill

On Fri, Dec 23, 2011 at 11:39 AM, Fleysher, Lazar
<lazar.fleysher at mountsinai.org> wrote:
> Dear Bill Lorensen
>
> averageimage is decleared as float 3D and then it is read from a (NIFTI) file....
>
>  typename ImageFileReader::Pointer reader = ImageFileReader::New();
>  reader->SetFileName(argv[bigimage]);
>  reader->Update();
>  averageimage=reader->GetOutput();
>
> If I understood you correctly, I should run filter-> Update()
> than to save the image do writer->SetInput(shFilter->GetOutput());
> What is wrong with doing averageimage=shFilter->GetOutput()
> followed by writer->SetInput(averageimage) ?
>
>
> Regardless, shFilter->Update() generates a segmentation violation.
> If I comment out the filter part, the image gets saved in to a file
> and everything seem to work correctly.
>
> So there is something strange with the filter ... but what?
>
> Here is the output of gdb. Definitely there is a problem with some threads...
>
>
> [New Thread 2122320192 (LWP 15648)]
> [New Thread 46912496267840 (LWP 15512)]
> [New Thread 46913547483456 (LWP 15649)]
> [New Thread 46914596063552 (LWP 15650)]
> [Thread 2122320192 (LWP 15648) exited]
> [Thread 46914596063552 (LWP 15650) exited]
> [Thread 46913547483456 (LWP 15649) exited]
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 46912496267840 (LWP 15512)]
> 0x0000003482c076e8 in pthread_join () from /lib64/libpthread.so.0
>
> Here we see that the filter created 4 threads, but could not join them correctly.
> Furthermore:
>
> (gdb) where
> #0  0x0000003482c076e8 in pthread_join () from /lib64/libpthread.so.0
> #1  0x00000000007dd2b5 in itk::MultiThreader::WaitForSingleMethodThread (this=0x1a11160, threadHandle=3)
>    at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/src/itkMultiThreaderPThreads.cxx:210
> #2  0x00000000007dd9af in itk::MultiThreader::SingleMethodExecute (this=0x1a11160)
>    at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/src/itkMultiThreader.cxx:332
> #3  0x00000000007207fb in itk::ImageSource<itk::Image<double, 3u> >::GenerateData (this=0x19cf700)
>    at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/include/itkImageSource.hxx:275
> #4  0x00000000007d36a6 in itk::ProcessObject::UpdateOutputData (this=0x19cf700)
>    at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/src/itkProcessObject.cxx:1500
> #5  0x00000000007e18f8 in itk::DataObject::UpdateOutputData (this=0x19c3830) at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/src/itkDataObject.cxx:434
> #6  0x0000000000705f43 in itk::ImageBase<3u>::UpdateOutputData (this=0x19c3830) at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/include/itkImageBase.hxx:285
> #7  0x00000000007e1816 in itk::DataObject::Update (this=0x19c3830) at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/src/itkDataObject.cxx:359
> #8  0x00000000007d3bc1 in itk::ProcessObject::Update (this=0x19cf700) at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/src/itkProcessObject.cxx:1096
> #9  0x000000000077a82a in itk::OptimalSharpeningImageFilter<itk::Image<float, 3u>, itk::Image<float, 3u> >::GenerateData (this=0x19ce520)
>    at /work/home/xxx/ANTS/ANTS_SOURCE/ANTS/Examples/../Utilities/itkOptimalSharpeningImageFilter.hxx:142
> #10 0x00000000007d36a6 in itk::ProcessObject::UpdateOutputData (this=0x19ce520)
>    at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/src/itkProcessObject.cxx:1500
> #11 0x00000000007e18f8 in itk::DataObject::UpdateOutputData (this=0x19b52b0) at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/src/itkDataObject.cxx:434
> #12 0x0000000000705f43 in itk::ImageBase<3u>::UpdateOutputData (this=0x19b52b0) at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/include/itkImageBase.hxx:285
> #13 0x00000000007e1816 in itk::DataObject::Update (this=0x19b52b0) at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/src/itkDataObject.cxx:359
> #14 0x00000000007d3bc1 in itk::ProcessObject::Update (this=0x19ce520) at /work/home/xxx/ANTS/ITK_SOURCE/ITK/Modules/Core/Common/src/itkProcessObject.cxx:1096
> #15 0x000000000077d9ad in AverageImages1<3u, 1u> (argc=10, argv=0x7fffffffd7f8) at /work/home/xxx/ANTS/ANTS_SOURCE/ANTS/Examples/AverageImages.cxx:121
> #16 0x0000000000633770 in main (argc=10, argv=0x7fffffffd7f8) at /work/home/xxx/ANTS/ANTS_SOURCE/ANTS/Examples/AverageImages.cxx:308
>
> Does this provide some information about what is happening????
>
> The system I am running on is CentOS5, I guess:
>
> cat /etc/redhat-release
> Red Hat Enterprise Linux ES release 5
>
> cat /etc/redhat-release.CENTOS5.orig
> CentOS release 5.4 (Final)
>
> yum gives me this:
>
> yum list|grep libc
> glibc.i686                                  2.5-42                     installed
> glibc.x86_64                                2.5-42                     installed
> glibc-common.x86_64                         2.5-42                     installed
> glibc-devel.i386                            2.5-42                     installed
> glibc-devel.x86_64                          2.5-42                     installed
> glibc-headers.x86_64                        2.5-42                     installed
>
>
> Is this a problem with libc6?
>
> Thanks
>
> Lazar
>
> ________________________________________
> From: Bill Lorensen [bill.lorensen at gmail.com]
> Sent: Friday, December 23, 2011 08:37
> To: Fleysher, Lazar
> Cc: Insight-users at itk.org
> Subject: Re: [Insight-users] ImageFilter problems
>
> For a filter to run, you must either explicitly call Update() on it,
> or a filter down stream.
>
> Can you show the code that creates averageimage?
>
> Also, you should remove the statement:
> averageimage =  shFilter->GetOutput();
>
> It is already used as input to your filter. You are probably
> introducing some sort of cycle in the pipeline.
>
> Try
> writer->SetInput(shFilter->GetOutput());
>
>
> On Fri, Dec 23, 2011 at 8:19 AM, Fleysher, Lazar
> <lazar.fleysher at mountsinai.org> wrote:
>>
>>
>> Hello insight-users at itk.org.
>>
>> I am new to ITK and I am experiencing a strange problem with the image filters.
>> So I was wondering if someone could shed some light on this.
>>
>> I have this code
>>
>>
>>  typedef itk::OptimalSharpeningImageFilter<ImageType,ImageType > sharpeningFilter;
>>  typename sharpeningFilter::Pointer shFilter = sharpeningFilter::New();
>>  shFilter->SetInput( averageimage );
>>  shFilter->SetSValue(0.5);
>> //  shFilter->Update();
>>  averageimage =  shFilter->GetOutput();
>>
>>
>> which should filter the averageimage.
>>
>> Unfortunately, when I run this code the resulting averageimage contains zero pixels.
>> If I uncomment the "Update()" call (which I do not know if is needed) then
>> the Update() generates a segmentation violation.
>>
>>
>> I have ITK installed from sources using git clone git://itk.org/ITK.git from
>> 2 days ago. I think it is version 4.1.
>>
>> Also, I have noticed that if I do not call Update() and try to save the image with
>>
>> typename writertype::Pointer writer = writertype::New();
>> writer->SetFileName("aaa");
>> writer->SetInput( averageimage );
>> writer->Update();
>>
>> writer->Update() never returns. That is, it cannot write an empty image.
>>
>> Am I doing something wrong? What is going on?
>>
>> Thank you very much for your help
>>
>> Lazar
>> _____________________________________
>> 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
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com



-- 
Unpaid intern in BillsBasement at noware dot com


More information about the Insight-users mailing list