[Insight-users] How to write "image reader" code in mfc application using msVC 6.0

vic roc victorxstc at yahoo.com
Wed Jun 14 13:45:30 EDT 2006


Hi everybody

i have placed this code in MainFrame.cpp
(CMainFrame::OnFileOpen(char& argv) )

#include "itkObject.h"
#include "itkImageIOBase.h"
#include "itkImage.h"
#include <iostream>
#include "itkImageFileReader.h"
#include "itkRGBPixel.h"
#include "itkVector.h"
#include "itkImportImageFilter.h"
#include "itkPointSet.h"
#include "itkRGBPixel.h"
#include "itkCovariantVector.h"

#include <string>
#include "stdafx.h"
#include "itk3.h"
#include "MainFrm.h"
..... ... 
using namespace itk;
. . .
. . .
. .
.
void CMainFrame::OnFileOpen() 
{
   typedef unsigned char     PixelType;
	const unsigned int        Dimension = 3;
	typedef Image< PixelType, Dimension >    ImageType;
	typedef ImageFileReader < ImageType >   ReaderType;
	ReaderType::Pointer reader = ReaderType::New();
	const char * filename = "SomePic.jpg";;
	reader->SetFileName( filename );
	reader->Update();
	ImageType::Pointer image = reader->GetOutput();	
}

compiler created this ERRORS:
MainFrm.cpp
error C2871: 'itk' : does not exist or is not a
namespace
 error C2143: syntax error : missing ';' before '<'
 error C2143: syntax error : missing ';' before '<'
 error C2143: syntax error : missing ';' before '<'
 error C2143: syntax error : missing ';' before '<'
 error C2653: 'ReaderType' : is not a class or
namespace name
 error C2065: 'Pointer' : undeclared identifier
 error C2146: syntax error : missing ';' before
identifier 'reader'
 error C2065: 'reader' : undeclared identifier
 error C2653: 'ReaderType' : is not a class or
namespace name
 error C2065: 'New' : undeclared identifier
 warning C4129: 'S' : unrecognized character escape
sequence
 error C2227: left of '->SetFileName' must point to
class/struct/union
 error C2227: left of '->Update' must point to
class/struct/union
 error C2653: 'ImageType' : is not a class or
namespace name
 error C2146: syntax error : missing ';' before
identifier 'image'
 error C2065: 'image' : undeclared identifier
 error C2227: left of '->GetOutput' must point to
class/struct/union

Can any one HELP ME Please?
it doeasn't accept itk as a namespace , but clicking
on "itk" IDE says that its a namespace!! but compiler
doesn't accept;
also many rediculous errors as you see above


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Insight-users mailing list