[Insight-users] read rgb values

alex Dowson alexdowson at hotmail.com
Mon Sep 17 06:36:36 EDT 2012


It’s compiler error of code mistake.


int main( int argc, char * argv[] );
char test;
{

should be
int main( int argc, char * argv[] )
{
    
    char test;



Alex

From: shirani kannangara 
Sent: Monday, September 17, 2012 4:03 PM
To: insight-users at itk.org 
Subject: [Insight-users] read rgb values

I am constructing a program to read rgb values  in a raw image  data set of a human abdomen obtained from a CT scan(VHP abdomen).Slice dimensions are 675,401,450 and spacing0.333 etc.) I used RGBImageSeriesReadeWrite.cxx.I am using itk version 4.2 and CMake2.8.9.  I have constructed and spent many hours on my last error. 



Error:error C2447: '{' : missing function header (old-style formal list?)


Pl help me get it corrected.
Thanks
Shirani


codes
#include "itkRGBPixel.h"
#include "itkImage.h"
#include "itkImageSeriesReader.h"
#include "itkImageSeriesWriter.h"
#include "itkNumericSeriesFileNames.h"
#include "itkPNGImageIO.h"

#include <string>

using namespace std;


// Software Guide : EndCodeSnippet


int main( int argc, char * argv[] );
char test;

{
  // Verify the number of parameters in the command line
  if( argc < 4 )
    {
    std::cout << "Usage: " << std::endl;
    std::cout << argv[0] << "first last  outputRGBImageFile " << std::endl;
    return EXIT_FAILURE;
    }


 
  typedef itk::RGBPixel< unsigned char >        PixelType;
  const unsigned int Dimension = 3;

  typedef itk::Image< PixelType, Dimension >    ImageType;
 
  // Software Guide : BeginCodeSnippet
  typedef itk::ImageSeriesReader< ImageType >  SeriesReaderType;
  typedef itk::ImageFileWriter<   ImageType >  WriterType;

  SeriesReaderType::Pointer seriesReader = SeriesReaderType::New();
  WriterType::Pointer       writer       = WriterType::New();
 
  reader->SetFileName("D:\\To_SMK\\VHPAbdomen.mhd");
  reader->Update();

  const unsigned int first = 1;
  const unsigned int last  = 450;

   const char*outputFilename=  argv[3];
 
  typedef itk::NumericSeriesFileNames NameGeneratorType;

  NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
 
  const char * outputFilename = argv[3];

 
  typedef itk::NumericSeriesFileNames    NameGeneratorType;

  NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();

  nameGenerator->SetStartIndex( first );
  nameGenerator->SetEndIndex( last );
  nameGenerator->SetIncrementIndex( 0.333 );

  nameGenerator->SetSeriesFormat( "vwe%03d.png" );

 
  seriesReader->SetImageIO( itk::PNGImageIO::New() );
 
  seriesReader->SetFileNames( nameGenerator->GetFileNames()  );
 
 
  writer->SetFileName( "test.png" );

  writer->SetInput( seriesReader->GetOutput() );
 
 
  try
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & excp )
    {
    std::cerr << "Error reading the series " << std::endl;
    std::cerr << excp << std::endl;
    }

  typedef itk::Image< PixelType, 2 >     Image2DType;

  typedef itk::ImageSeriesWriter< ImageType, Image2DType > SeriesWriterType;

  SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();

  seriesWriter->SetInput( seriesReader->GetOutput() );



  try
    {
    seriesWriter->Update();
    }
  catch( itk::ExceptionObject & excp )
    {
    std::cerr << "Error reading the series " << std::endl;
    std::cerr << excp << std::endl;
    }
 
  return EXIT_SUCCESS;
}





--------------------------------------------------------------------------------
_____________________________________
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.php

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/20120917/93d128d4/attachment.htm>


More information about the Insight-users mailing list