--- /dev/null
+#----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR EXECUTABLE
+# Replace 'MyExe' by the name you want to give your executable.
+# (a good policy is to give the executable the same name that the directory)
+
+#########################
+SET ( EXE_NAME qtvtkviewer )
+#########################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# EXECUTABLE SOURCES (TO BE COMPILED)
+# EITHER LIST ALL .cxx, *.cpp, *.cc IN CURRENT DIR USING NEXT LINE:
+
+FILE(GLOB ${EXE_NAME}_SOURCES *.cxx *.cpp *.cc)
+
+# OR MANUALLY LIST YOUR FILES WITH NEXT COMMAND (WITHOUT EXTENSION)
+# SET ( ${EXE_NAME}_SOURCES
+#
+# )
+#----------------------------------------------------------------------------
+
+INCLUDE_DIRECTORIES (
+
+# USER! : Add here the directories holding th extra .h files you need
+# e.g.
+# ../../lib/<my_library_I_just_created>
+
+)
+
+#----------------------------------------------------------------------------
+# DEPENDENCIES (LIBRARIES TO LINK WITH)
+SET ( ${EXE_NAME}_LINK_LIBRARIES
+ GUIQtViewers
+ GUIQtVolumeRenderer
+ KernelVolumeRenderer
+ KernelViewerWidgets
+ ${VTK_LIBRARIES}
+ ${QT_LIBRARIES}
+ QVTK
+ # ${WXWIDGETS_LIBRARIES}
+ # ${KWWidgets_LIBRARIES}
+ # ${VTK_LIBRARIES}
+ ${ITK_LIBRARIES}
+ # ${GDCM_LIBRARIES}
+ # ${BOOST_LIBRARIES}
+
+ # USER! : Add here those agmonst the various (?) PROJECT LIBRARIES
+ # you need for the current executable
+ # (If you created only one Library, don't forget it !...)
+
+ )
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# USER! : UNCOMMENT NEXT LINE IF YOU WANT A CONSOLE ON WINDOWS
+# NB : YOUR MAIN MUST BE ADAPTED ALSO
+# SEE THE MACRO CREA_WXMAIN_WITH_CONSOLE IN creaWx.h
+#SET(${EXE_NAME}_CONSOLE TRUE)
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# CREATES AND INSTALLS THE EXE
+CREA_ADD_EXECUTABLE( ${EXE_NAME} )
+#----------------------------------------------------------------------------
+
+
--- /dev/null
+
+//----------------------------------------------------------------------
+// File: ann_sample.cpp
+// Programmer: Sunil Arya and David Mount
+// Last modified: 03/04/98 (Release 0.1)
+// Description: Sample program for ANN
+//----------------------------------------------------------------------
+// Copyright (c) 1997-2005 University of Maryland and Sunil Arya and
+// David Mount. All Rights Reserved.
+//
+// This software and related documentation is part of the Approximate
+// Nearest Neighbor Library (ANN). This software is provided under
+// the provisions of the Lesser GNU Public License (LGPL). See the
+// file ../ReadMe.txt for further information.
+//
+// The University of Maryland (U.M.) and the authors make no
+// representations about the suitability or fitness of this software for
+// any purpose. It is provided "as is" without express or implied
+// warranty.
+//----------------------------------------------------------------------
+
+#include "qtvtkviewerwidget.h"
+#include <QMainWindow>
+#include <QApplication>
+
+#include "itktovtkimageimport.h"
+#include "itkImage.h"
+#include "itkRGBPixel.h"
+#include "itkImageFileReader.h"
+
+
+#include "itkvtkcolortransferfunction.h"
+
+
+#include "iostream"
+
+
+
+
+
+using namespace std; // make std:: accessible
+
+
+int main(int argc, char **argv)
+{
+
+
+
+
+
+
+
+
+ if (argc < 2)
+ {
+ std::cout << "ERROR: data file name argument missing."
+ << std::endl ;
+ return EXIT_FAILURE;
+ }
+
+ std::string inputFilename = argv[1];
+ //std::string inputFilename2 = argv[2];
+
+
+ typedef unsigned char PixelType;
+ typedef itk::RGBPixel< PixelType > RGBPixelType;
+ typedef itk::Image< RGBPixelType, 2 > RGBImageType;
+
+ typedef itk::ImageFileReader< RGBImageType > ImageReaderType ;
+ ImageReaderType::Pointer imageReader = ImageReaderType::New() ;
+ imageReader->SetFileName(inputFilename.c_str());
+ imageReader->Update();
+ RGBImageType::Pointer imagergb = imageReader->GetOutput();
+
+
+ typedef itk::ITKToVTKImageImport< RGBImageType > ITKToVTKRGBType;
+ ITKToVTKRGBType::Pointer itktovtkrgb = ITKToVTKRGBType::New();
+ itktovtkrgb->SetITKImage(imagergb);
+
+
+
+
+ typedef itk::Image< RGBPixelType, 3> RGBImage3DType;
+ RGBImage3DType::Pointer image = RGBImage3DType::New();
+ RGBImage3DType::RegionType region;
+ region.SetSize(0, 256);
+ region.SetSize(1, 256);
+ region.SetSize(2, 256);
+ region.SetIndex(0,0);
+ region.SetIndex(1,0);
+ region.SetIndex(2,0);
+
+ image->SetRegions(region);
+ image->Allocate();
+
+ typedef itk::ITKToVTKImageImport< RGBImage3DType > ITKToVTKType;
+ ITKToVTKType::Pointer itktovtk = ITKToVTKType::New();
+ itktovtk->SetITKImage(image);
+
+
+ typedef itk::Image< unsigned char, 2 > LuminanceImageType;
+ typedef itk::RGBToLuminanceImageFilter< RGBImageType, LuminanceImageType> RGBToLumType;
+ RGBToLumType::Pointer rgbtolum = RGBToLumType::New();
+ rgbtolum->SetInput(imagergb);
+ rgbtolum->Update();
+ LuminanceImageType::Pointer lumimage = rgbtolum->GetOutput();
+
+
+ typedef itk::ITKToVTKImageImport< LuminanceImageType > ITKToVTKLuminanceType;
+ ITKToVTKLuminanceType::Pointer itktovtklum = ITKToVTKLuminanceType::New();
+ itktovtklum->SetITKImage(lumimage);
+
+
+ vtkImageData* vtkimage =itktovtklum->GetOutputVTKImage();
+
+
+
+ typedef itk::VTKColorTransferFunction< RGBImageType > VTKColorTransferType;
+ VTKColorTransferType::Pointer vtkcolortransfer = VTKColorTransferType::New();
+
+ vtkcolortransfer->SetInput(imagergb);
+ vtkcolortransfer->Update();
+ vtkColorTransferFunction* colortransfer = vtkcolortransfer->GetOutput();
+
+ QApplication app(argc, argv);
+
+
+ QMainWindow* mainwindow = new QMainWindow();
+
+ QtVTKViewerWidget *viewer = new QtVTKViewerWidget(mainwindow);
+
+ mainwindow-> setCentralWidget(viewer);
+
+
+ mainwindow->show();
+
+ viewer->setImage(vtkimage);
+ viewer->SetLookupTable((vtkLookupTable*)colortransfer);
+ int scalnum = vtkimage->GetNumberOfScalarComponents();
+
+ cout<<scalnum<<endl;
+
+
+
+
+
+ return app.exec();
+}
+