[Insight-users] To get ITK-VTK working

Caleb Johnston cjj37 at cornell.edu
Tue May 18 20:26:10 EDT 2010


The code seems fine except what are you using as an input argument? It does
not link correctly on my machine, so I have not been able to test it yet.

Caleb


On Tue, May 18, 2010 at 6:35 PM, Qian Cheng <qianc at ee.ethz.ch> wrote:

>  Hi Caleb,
> The code is here, very simple:
> /*****************************************/
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageToVTKImageFilter.h"
>
> #include "vtkImageViewer.h"
> #include "vtkRenderWindowInteractor.h"
>
> int main(int argc, char **argv){
>
>     typedef itk::Image<unsigned short, 2> ImageType;
>     typedef itk::ImageFileReader<ImageType> ReaderType;
>     typedef itk::ImageToVTKImageFilter<ImageType> FilterType;
>
>     ReaderType::Pointer reader = ReaderType::New();
>     FilterType::Pointer connector = FilterType::New();
>
>     reader->SetFileName(argv[1]);
>     connector->SetInput(reader->GetOutput());
>
>     vtkImageViewer *viewer = vtkImageViewer::New();
>
>     vtkRenderWindowInteractor *renderWindowInteractor =
> vtkRenderWindowInteractor::New();
>
>     viewer->SetupInteractor(renderWindowInteractor);
>     viewer->SetInput(connector->GetOutput());
>     viewer->Render();
>     viewer->SetColorWindow(2000);
>     viewer->SetColorLevel(1000);
>     renderWindowInteractor->Start();
>
>     return 0;
> }
> /**************************************************/
> Best,
> Cheng
> 于 2010/5/18 18:44, Caleb Johnston 写道:
>
> I see the code listed in the example PDF. However, could you send me your
> example source file? Or you can paste it in an email if it is just that one
> example c file.
>
> A segmentation fault is caused by your program attempting to access a
> protected region of memory. Its possible that is happening in your code
> accidentally.
>
> Caleb
>
>
> On Tue, May 18, 2010 at 10:38 AM, Qian Cheng <qianc at ee.ethz.ch> wrote:
>
>> Dear all,
>> I am compiling the simple example given by
>> "http://www.itk.org/CourseWare/Training/GettingStarted-II.pdf".
>> It seems working(showing a picture in a window). But whenever I close
>> the rendered window, "Segmentation fault" shows up in the command line.
>> Does anybody know what's wrong? I am running ITK+VTK in my lab's
>> sever("Linux 2.6.18-194.3.1.el5 #1 SMP Sun May 2 04:17:42 EDT 2010
>> x86_64 x86_64 x86_64 GNU/Linux") without TCL, QT and FLTK wrapped.
>> I am new to VTK&ITK, I would appreciate if anybody can help out.
>> Best,
>> Cheng
>>
>> _____________________________________
>> 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
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100518/e970aef0/attachment.htm>


More information about the Insight-users mailing list