[Insight-users] ImageFilter problems

Fleysher, Lazar lazar.fleysher at mountsinai.org
Fri Dec 23 16:23:16 EST 2011


Hello Bill

Yes of course I have tried your version. As I said, I will not be
able to use your approach in the final application, but for test
purposes I did run your program with the same segmentation violation.
(in my final application I will need the pointer to filtered image as I will
do more things to it)

ProcessObject::UpdateOutputData and calls inside it
cause segmentation violation whether update() is called directly or not.

Thank you very much for your help

Lazar
________________________________________
From: Bill Lorensen [bill.lorensen at gmail.com]
Sent: Friday, December 23, 2011 16:09
To: Fleysher, Lazar
Cc: Insight-users at itk.org
Subject: Re: [Insight-users] ImageFilter problems

itk does not use intermediate storage. When you say image1 = image2 it
is just assigning pointers.

I'll try compiling and running your test program if I get a chance.

Did you try my test program?

On Fri, Dec 23, 2011 at 3:42 PM, Fleysher, Lazar
<lazar.fleysher at mountsinai.org> wrote:
> Dear Bill
>
> You suggest to feed the output of filter directly into the writer without
> the use of an intermediate storage. While in my end application
> this will not work, I have tried it here and the same thing happens.
>
> The segmentation violation is generated on filter->update() call...
>
> There is  something wong with ITK or libc
>
> What do you think?
>
> Lazar
>
> ________________________________________
> From: Bill Lorensen [bill.lorensen at gmail.com]
> Sent: Friday, December 23, 2011 15:01
> To: Fleysher, Lazar
> Cc: Insight-users at itk.org
> Subject: Re: [Insight-users] ImageFilter problems
>
> Try my attached version
>
> On Fri, Dec 23, 2011 at 2:48 PM, Fleysher, Lazar
> <lazar.fleysher at mountsinai.org> wrote:
>> Hello Bill
>>
>> Sorry for not being clear. Attached is the example which I am trying to work out.
>>
>> The way to execute is :
>>
>> TestFilter blah.nii.gz r16slice.nii.gz
>>
>> (unfortunately the image file is too large to be accepted by the mailing list)
>>
>> The function reads the file r16slice and applies filter to it and saves it on disk into blah.nii.gz
>>
>> If I do not exectute shFilter->Update(); than averageimage has no pixels just before write.
>> If I do execute shFilter->Update(); then this causes segmentation violation.
>> If I do not execute shFilter->Update(); and do not execute averageimage =  shFilter->GetOutput();
>> then the function works as copy and blah.nii.gz is identical to the r16slice.nii.gz....
>>
>> Thank you very much for your help
>>
>> Lazar
>> ________________________________________
>> From: Bill Lorensen [bill.lorensen at gmail.com]
>> Sent: Friday, December 23, 2011 12:44
>> To: Fleysher, Lazar
>> Cc: Insight-users at itk.org
>> Subject: Re: [Insight-users] ImageFilter problems
>>
>> 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
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com



--
Unpaid intern in BillsBasement at noware dot com


More information about the Insight-users mailing list