<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi Luis and ITK Mania</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I run the ITKImage2VTKImage.cxx with MSVC in
console mode. It work fine but when I tried to convert it to MFC based, it
fail in compilation stage. I plan to display the image in a Dialog. Below
are the codes.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>What part should I bring to constructor, destructor
and so on..</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thank you in advance.</FONT></DIV>
<DIV><FONT face=Arial size=2>Best Regards</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>//--- Console mode ---</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2>/*===================================================================<BR>
Program: Insight Segmentation & Registration Toolkit<BR>
Module: $RCSfile: ITKImage2VTKImage.cxx,v $<BR>
Language:
C++<BR>=================================================================*/</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>#include "itkImage.h"<BR>#include
"itkImageFileReader.h"<BR>#include "itkImageFileReader.h"<BR>#include
"vtkImageViewer.h"<BR>#include "vtkRenderWindowInteractor.h"<BR>#include
"itkImageToVTKImageFilter.h"</FONT></DIV>
<DIV> </DIV><FONT face=Arial size=2>
<DIV><BR>int main( int argc, char ** argv )<BR>{<BR> typedef unsigned
short PixelType;<BR> const
unsigned int Dimension = 2;</DIV>
<DIV> </DIV>
<DIV> typedef itk::Image< PixelType, Dimension >
ImageType;<BR> typedef itk::ImageFileReader< ImageType
> ReaderType;<BR> typedef
itk::ImageToVTKImageFilter< ImageType > ConnectorType;</DIV>
<DIV> </DIV>
<DIV> ReaderType::Pointer reader = ReaderType::New();<BR>
ConnectorType::Pointer connector = ConnectorType::New();<BR>
reader->SetFileName( argv[1] );<BR> //reader->Update();</DIV>
<DIV> </DIV>
<DIV> connector->SetInput(reader->GetOutput()); </DIV>
<DIV> </DIV>
<DIV> vtkImageViewer *viewer=vtkImageViewer::New();<BR>
vtkRenderWindowInteractor *renderWindowInteractor=vtkRenderWindowInteractor
::New();<BR> viewer->SetupInteractor(renderWindowInteractor);<BR>
viewer->SetInput(connector->GetOutput());<BR>
viewer->Render();<BR> viewer->SetColorWindow(255);<BR>
viewer->SetColorLevel(128);<BR>
//renderWindowInteractor->Start();</DIV>
<DIV> </DIV>
<DIV> return 0;<BR>}<BR></DIV>
<DIV> </DIV>
<DIV>//--- MFC based</DIV>
<DIV>#if
!defined(AFX_BINARYTHRESHOLDDLG1_H__2D2E73F5_F350_4BC6_A757_586AE2651DBF__INCLUDED_)<BR>#define
AFX_BINARYTHRESHOLDDLG1_H__2D2E73F5_F350_4BC6_A757_586AE2651DBF__INCLUDED_</DIV>
<DIV> </DIV>
<DIV>#if _MSC_VER > 1000<BR>#pragma once<BR>#endif // _MSC_VER >
1000</DIV>
<DIV> </DIV>
<DIV>//itk and vtk <BR>#include "itkImage.h"<BR>#include
"itkImageFileReader.h"<BR>#include "itkImageFileReader.h"<BR>#include
"vtkImageViewer.h"<BR>#include "vtkRenderWindowInteractor.h"<BR>#include
"itkImageToVTKImageFilter.h"</DIV>
<DIV> </DIV>
<DIV>// BinaryThresholdDlg1.h : header file<BR>//</DIV>
<DIV> </DIV>
<DIV>/////////////////////////////////////////////////////////////////////////////<BR>//
CBinaryThresholdDlg dialog (BinaryThreshold.h)</DIV>
<DIV> </DIV>
<DIV>class CBinaryThresholdDlg : public CDialog<BR>{<BR>//
Construction<BR>public:<BR> CBinaryThresholdDlg(CWnd* pParent =
NULL); // standard constructor<BR> typedef unsigned
short
PixelType; //
<---- error in this part (illegal pure syntax, must be '= 0')<BR>
const unsigned int
Dimension =
2; //
<---- error in this part (Dimension' : pure specifier can only be specified
for functions)<BR></DIV>
<DIV> typedef itk::Image< PixelType, Dimension >
ImageType; // </DIV>
<DIV> typedef itk::ImageFileReader< ImageType >
ReaderType; // </DIV>
<DIV> typedef itk::ImageToVTKImageFilter< ImageType >
ConnectorType; // </DIV>
<DIV> </DIV>
<DIV> ReaderType::Pointer reader;<BR> ConnectorType::Pointer
connector;</DIV>
<DIV> </DIV>
<DIV>// Dialog Data<BR> //{{AFX_DATA(CBinaryThresholdDlg)<BR> enum {
IDD = IDD_BYNARYTHRESHOLDDLG
};<BR> CEdit m_fileName;<BR> //}}AFX_DATA</DIV>
<DIV> </DIV>
<DIV><BR>// Overrides<BR> // ClassWizard generated virtual function
overrides<BR> //{{AFX_VIRTUAL(CBinaryThresholdDlg)<BR> protected:<BR> virtual
void DoDataExchange(CDataExchange* pDX); // DDX/DDV
support<BR> //}}AFX_VIRTUAL</DIV>
<DIV> </DIV>
<DIV>// Implementation</DIV>
<DIV> </DIV>
<DIV>protected:</DIV>
<DIV> </DIV>
<DIV> // Generated message map
functions<BR> //{{AFX_MSG(CBinaryThresholdDlg)<BR> afx_msg void
OnLoad();<BR> //}}AFX_MSG<BR> DECLARE_MESSAGE_MAP()<BR>};</DIV>
<DIV> </DIV>
<DIV>//{{AFX_INSERT_LOCATION}}<BR>// Microsoft Visual C++ will insert additional
declarations immediately before the previous line.</DIV>
<DIV> </DIV>
<DIV>#endif //
!defined(AFX_BINARYTHRESHOLDDLG1_H__2D2E73F5_F350_4BC6_A757_586AE2651DBF__INCLUDED_)<BR></DIV>
<DIV>// BinaryThresholdDlg.cpp : implementation file<BR>//</DIV>
<DIV> </DIV>
<DIV>#include "resource.h"<BR>#include "stdafx.h"<BR>#include
"Uias3D.h"<BR>#include "BinaryThresholdDlg.h"<BR></DIV>
<DIV>#ifdef _DEBUG<BR>#define new DEBUG_NEW<BR>#undef THIS_FILE<BR>static char
THIS_FILE[] = __FILE__;<BR>#endif</DIV>
<DIV> </DIV>
<DIV>/////////////////////////////////////////////////////////////////////////////<BR>//
CBinaryThresholdDlg dialog</DIV>
<DIV> </DIV>
<DIV><BR>CBinaryThresholdDlg::CBinaryThresholdDlg(CWnd* pParent
/*=NULL*/)<BR> : CDialog(CBinaryThresholdDlg::IDD,
pParent)<BR>{<BR> //{{AFX_DATA_INIT(CBinaryThresholdDlg)<BR> //
NOTE: the ClassWizard will add member initialization
here<BR> //}}AFX_DATA_INIT<BR> reader = ReaderType::New();<BR>
connector = ConnectorType::New();<BR>}</DIV>
<DIV> </DIV>
<DIV><BR>void CBinaryThresholdDlg::DoDataExchange(CDataExchange*
pDX)<BR>{<BR> CDialog::DoDataExchange(pDX);<BR> //{{AFX_DATA_MAP(CBinaryThresholdDlg)<BR> //}}AFX_DATA_MAP<BR>}</DIV>
<DIV> </DIV>
<DIV><BR>BEGIN_MESSAGE_MAP(CBinaryThresholdDlg,
CDialog)<BR> //{{AFX_MSG_MAP(CBinaryThresholdDlg)<BR> ON_BN_CLICKED(IDC_LOAD,
OnLoad)<BR> //}}AFX_MSG_MAP<BR>END_MESSAGE_MAP()</DIV>
<DIV> </DIV>
<DIV>/////////////////////////////////////////////////////////////////////////////<BR>//
CBinaryThresholdDlg message handlers</DIV>
<DIV> </DIV>
<DIV>void CBinaryThresholdDlg::OnLoad() <BR>{<BR>
reader->SetFileName("brain.png");<BR></DIV>
<DIV> connector->SetInput(reader->GetOutput()); </DIV>
<DIV> </DIV>
<DIV> vtkImageViewer *viewer=vtkImageViewer::New();<BR>
vtkRenderWindowInteractor *renderWindowInteractor=vtkRenderWindowInteractor
::New();<BR> viewer->SetupInteractor(renderWindowInteractor);<BR>
viewer->SetInput(connector->GetOutput());<BR>
viewer->Render();<BR> viewer->SetColorWindow(255);<BR>
viewer->SetColorLevel(128);<BR>}</DIV>
<DIV> </DIV>
<DIV><BR> </DIV>
<DIV> </DIV>
<DIV> </DIV></FONT></BODY></HTML>