[Insight-users] ITK Registration and VTK Checkerboard of RGB Images

Karthik Krishnan Karthik.Krishnan at kitware.com
Fri Feb 25 16:08:10 EST 2005


Hi,

ImageToVTKImageFilter uses VTKImageImport as its importer. To quote
http://www.itk.org/Insight/Doxygen/html/classitk_1_1VTKImageImport.html#_details

"images are assumed to be of 1, 2, or 3 dimensions. Scalar value types 
can be one of: float, double, char, unsigned char, short, unsigned 
short, int, unsigned int, long, unsigned long. The images must have 
pixel types with one component."

Maybe you can use adaptors or something else to break up and re-compose 
the RGB pixels before and after the connector.





alqatarneh at netscape.net wrote:

>Hi all,
>
>Can someone help me with this problem... Please!
>
>I am trying to get two RGB images registered then write the output to a file. I would like the written output image to show the two registered images as checkerboard.
>Regsitration works, but Checkerboard does not!!!
>I also tried to use the vtkimageluminance filter, but I got the same error mentioned below. 
>
>I tried to compile the code below but did not succeed in making VTK read my RGB images that were defined by ITK and then produce checkerboard.
>
>Can you also please tell me if my code is right to get the image written by ITK and viewed and written by VTK?
>
>The error message I got was about the last few lines in the code: Specifically:
>--------------------
>reader->SetFileName( argv[1] );
>  connector->SetInput( reader->GetOutput() );
>
>  reader2->SetFileName( argv[2] );
>  connector2->SetInput( reader2->GetOutput() );
>------------------
>
>Here is the error message:
>---------------------
>RGB_Checker.cxx
>C:\VTKITK_Tests\RGB_Reg_Checkerboard\RGB_Checker.cxx(332) : error C2664: 'SetInput' : cannot convert parameter 1 from 'class itk::Image<class itk::RGBPixel<float>,2> *' to 'const class itk::Image<float,2> *'
>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
>-------------------------
>And the code is:
>--------- START Code----------------
>#include "itkImageRegistrationMethod.h"
>#include "itkMeanSquaresImageToImageMetric.h"
>#include "itkLinearInterpolateImageFunction.h"
>#include "itkRegularStepGradientDescentOptimizer.h"
>#include "itkImage.h"
>#include "itkRGBPixel.h"
>#include "itkCenteredRigid2DTransform.h"
>#include "itkImageFileReader.h"
>#include "itkImageFileWriter.h"
>#include "itkResampleImageFilter.h"
>#include "itkCastImageFilter.h"
>#include "itkSquaredDifferenceImageFilter.h"
>#include "itkCommand.h"
>#include "itkAdaptImageFilter.h"
>#include "itkRedPixelAccessor.h"
>#include "itkGreenPixelAccessor.h"
>#include "itkBluePixelAccessor.h"
>#include "itkComposeRGBImageFilter.h"
>#include "itkImageToVTKImageFilter.h"
>
>//VTK include files
>#include "vtkImageViewer.h"
>#include "vtkRenderWindowInteractor.h"
>#include "vtkImageCheckerboard.h"
>#include <vtkPolyData.h>
>#include <vtkImageData.h>
>
>  /////////////// RGB REGISTRATION CODE HERE /////////////
> 
>  typedef itk::ImageToVTKImageFilter<ImageType> FilterType;
>
>  FixedImageReaderType::Pointer reader = FixedImageReaderType::New();
>  MovingImageReaderType::Pointer reader2 = MovingImageReaderType::New();
>
>  FilterType::Pointer connector = FilterType::New();
>  FilterType::Pointer connector2 = FilterType::New();
>
>  vtkImageViewer * viewer = vtkImageViewer::New();
>  vtkImageCheckerboard * checker = vtkImageCheckerboard::New();
>  vtkRenderWindowInteractor * interactor = vtkRenderWindowInteractor::New();
>
>  reader->SetFileName( argv[1] );
>  connector->SetInput( reader->GetOutput() );
>
>  reader2->SetFileName( argv[2] );
>  connector2->SetInput( reader2->GetOutput() );
>
>  checker->SetInput1( connector->GetOutput() );
>  checker->SetInput2( connector2->GetOutput() );
>
>  viewer->SetInput( checker->GetOutput() );
>  viewer->Render();
>  viewer->SetColorWindow( 256 );
>  viewer->SetColorLevel( 128 );
>  interactor->Start();
>  return 0;
>}
>------- END OF CODE -------------
>
>
>
>
>__________________________________________________________________
>Switch to Netscape Internet Service.
>As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register
>
>Netscape. Just the Net You Need.
>
>New! Netscape Toolbar for Internet Explorer
>Search from anywhere on the Web and block those annoying pop-ups.
>Download now at http://channels.netscape.com/ns/search/install.jsp
>_______________________________________________
>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