[Insight-users] Problem with curvature flow filter
pieter Mollemans
pmolle at gmail.com
Mon Oct 15 11:00:02 EDT 2007
the variable "image" is a file volume that i created myself. (the input
is from ct data)
I did what you suggested, but when i directly connect the input to the
writer i don't recieve any errors.
I also tried another filter instead ( the gradient magnitude filter) and
this one works correctly.
------------------------------------------------------
The output from the importfilter :
RTTI ; itk::Image <short , 3>
Reff count : 1
modified Time : 16
Debug : off
observers : none
source output index :0
Release data : off
PipelimeMTime : 11
UpdateMTime 17
Largest possible region : Dim 3
index 0 , 0 ,0
Size 512, 512, 166
Buffered region : Dim 3
index 0 , 0 ,0
Size 512, 512, 166
Spacing 1, 1, 1
Origin 0,0,0
Direction 1 0 0
0 1 0
0 0 1
Pixelcontainer
reff count 1
Size : 43515905
Capacity : 43515905
Luis Ibanez wrote:
>
> Hi Pieter,
>
> Thanks for posting your code.
>
>
> The error is most likely in your construction of the imported image.
>
> Where are you getting "image" from ?
>
>
> Please remove the CurvatureFlow filter from the pipeline and connect
> your imported image directly to the reader. That should crash too at
> run time, and if so, it will discard the CurvatureFlowFilter as
> a suspect.
>
> Then, modify your code to print out the characteristics of the image
> just after you import it. You can do this as:
>
> importFilter->Update()
> importFilter->GetOutput()->Print( std::cout );
>
> Chances are that you will find some of the image size entries
> to be set to zero. (which are obviously wrong values).
>
> Please post to the mailing list the output of this command,
> so we can give you more detailed help.
>
>
>
> Thanks
>
>
> Luis
>
>
> ----------------------
> pieter Mollemans wrote:
>> Hello,
>>
>> I try to use a itk curvature flow filter on a 3D image volume. I load
>> this image into a (3 dimensional) buffer with
>> itk::ImportImageFilter, then i apply the filter and eventually write
>> everything back to a buffer. When i run my program to test my code
>> (no compile errors) , the program throws a breakpoint when the buffer
>> gets applied,
>>
>> The code stops at :
>> this->GetMultiThreader()->SetNumberOfThreads(this->GetNumberOfThreads());
>>
>> in file: itkDenseFiniteDifferenceImageFilter.txx
>> the output says : "Access violation reading location"
>>
>> i tried to set the number of threads manually but the error stays.
>>
>> Anyone has any idea what could be the error or where to look for a
>> solution? I added my code at the bottom , i use VS2005 and itk 3.4.0
>>
>> thx
>>
>> ------------------------------ CODE
>> ----------------------------------------------------------
>>
>> typedef short InputPixelType;
>> const unsigned int Dimension = 3;
>> typedef itk::Image< InputPixelType, Dimension > ImageType;
>>
>> typedef itk::ImportImageFilter< InputPixelType, Dimension >
>> ImportFilterType;
>>
>> ImportFilterType::Pointer importFilter = ImportFilterType::New();
>> ImportFilterType::SizeType size = {{ image->imageSize()[0],
>> image->imageSize()[1], image->imageSize()[2] }};
>> ImportFilterType::IndexType index = {{ 0, 0, 0 }};
>>
>> ImportFilterType::RegionType region;
>> region.SetSize( size );
>> region.SetIndex( index );
>> importFilter->SetRegion( region );
>>
>> double origin[ Dimension ];
>> origin[0] = 0; // X coordinate origin[1] = 0; // Y coordinate
>> origin[2] = 0; // Z coordinate
>> importFilter->SetOrigin( origin );
>>
>> double spacing[ Dimension ];
>> spacing[0] = 0; // along X direction
>> spacing[1] = 0; // along Y direction
>> spacing[2] = 0; // along Z direction
>> importFilter->SetSpacing( spacing );
>>
>> const unsigned int numberOfPixels = size[0] * size[1] * size[2];
>> InputPixelType * localBuffer = new InputPixelType[ numberOfPixels ];
>> image->loadSlices(0,160, (char *) localBuffer);
>>
>> const bool importImageFilterWillOwnTheBuffer = true;
>> importFilter->SetImportPointer( localBuffer, numberOfPixels,
>> importImageFilterWillOwnTheBuffer );
>>
>> typedef float OutputPixelType;
>> typedef itk::Image< InputPixelType, Dimension > InputImageType;
>> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>>
>> typedef itk::CurvatureFlowImageFilter< InputImageType,
>> OutputImageType > FilterType;
>> FilterType::Pointer filter = FilterType::New();
>>
>> filter->SetInput( importFilter->GetOutput() );
>>
>> const unsigned int numberOfIterations = 10;
>> const double timeStep = 0.065 ;
>>
>> filter->SetNumberOfIterations( numberOfIterations );
>> filter->SetTimeStep( timeStep );
>> try
>> {
>> filter->Update(); //here the breakpoint occurs
>> }
>> catch( itk::ExceptionObject & err )
>> {
>> std::cerr << "ExceptionObject caught !" << std::endl;
>> std::cerr << err << std::endl;
>> }
>>
>> // ... then i write the image back to a buffer
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>
More information about the Insight-users
mailing list