[Insight-users] Re: Please help with the ITK and VTK pipeline problem

ask ITK askitk at gmail.com
Fri Feb 3 01:23:22 EST 2006


Dear Luis,

        I somehow solve the problem....but I still don't know why ITK
requires us to do in this way. The solution is the ITK object has to
be created (New) in the function, instead of creating the ITK object
in the constructor of the class containing it.
e.g. I modify the code of my callViewer (just add one line, the
creation of the object
itkvtkconnector (as shown below):

I did check the reference count of the itkvtkconnector in my previous
version and in this modified version, both of them are equal
(reference == 1 )

So my question is why the ITK object has to be created in the local
function and cannot be created in the constructor of the main class in
order to make it function properly......

Please kindly tell me the answer!
Thanks a lot!

=====================================================
void ApplicationCore::callViewer(ImagePtr image, int choice)
{
// The creation of the object is moved to the function
// previously it is in the constructor of the main class ApplicationCore
m_itkvtkconnector[choice] = itkvtkConnectorType::New();

m_itkvtkconnector[choice]->SetInput( image );
m_itkvtkconnector[choice]->Update();
	
m_ImageViewer[choice]->SetupInteractor( m_renderWindowInteractor[choice]);
m_ImageViewer[choice]->SetInput( m_itkvtkconnector[choice]->GetOutput() );

m_ImageViewer[choice]->Render();
m_ImageViewer[choice]->SetColorWindow( 255);
m_ImageViewer[choice]->SetColorLevel( 128);

//	m_renderWindowInteractor[choice]->Start();
}
==========================================================




2006/2/3, ask ITK <askitk at gmail.com>:
> Dear,
>
>       I have a problem related to display the ITK data again, I
> cannot solve it with many trials, please help.
>
> I make a function called callViewer, by inputing different ITK images
> data, I attempt to display different images. And the callViewer is a
> member function with
> the itkvtk connector and vtkimageviewer and interactor as member
> variable of the
> class ApplicationCore.
>
> =======================================================
> void ApplicationCore::callViewer(ImagePtr image, int choice)
> {
> m_itkvtkconnector[choice]->SetInput( image );
> m_itkvtkconnector[choice]->Update();
>
> m_ImageViewer[choice]->SetupInteractor( m_renderWindowInteractor[choice]);
> m_ImageViewer[choice]->SetInput( m_itkvtkconnector[choice]->GetOutput() );
>
> m_ImageViewer[choice]->SetSize(image->GetLargestPossibleRegion().GetSize()[0],image->GetLargestPossibleRegion().GetSize()[1]);
>
> m_ImageViewer[choice]->Render();
> m_ImageViewer[choice]->SetColorWindow( 255);
> m_ImageViewer[choice]->SetColorLevel( 128);
>
> //      m_renderWindowInteractor[choice]->Start();
> }
> ========================================================
>
> Then I create an image and display it with callViewer, everything fine, i.e.
> callViewer(m_Image,0);
> A viewer pops up and display the image.
>
> Then I use the ITK gaussian filter to create another image
> m_gaussianimage from m_image. and call
> callViewer(m_gaussianimage,0);
> everything fine, the viewer display the filtered image.
>
> BUT PROBLEM arises here,
> when I call
> callViewer(m_Image,0);
> again.
> The viewer STILL displays the filtered image, I have no way to
> display the original image. I have tried to resetpipeline after the
> gaussianfilter
> output is obtained, but the problem still existed (I don't know the
> correct way to solve, just try different approaches).
>
> Actually if i further created a m_gradientimage from the
> m_gaussianimage (or even
> the m_Image), then the viewer will sticked with the m_gradientimage
> and cannot display the m_Image or m_gaussianimage, even the input to
> the
> callViewer
> are m_Image or m_gaussianimage .
>
> I really cannot find out the reason of the problem, is that due to the
> ITKfilter pipeline?
> Or is that due to the itkvtk filter?????
> Or the only solution is everytime I change the input image I have to
> create a new vtkviewer instead of using the same vtkviewer?
>
> Please kindly help me about this problem!!!!
> Thanks a lot!!!!!!!!!
>


More information about the Insight-users mailing list