<!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 All</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I want to display the original image in one 
renderer and the other renderer to display the image already filtered. I use ITK 
to read and filter the image, then display it using VTK. It can run 
but&nbsp;doesn't work properly. Below are the problems and the codes both of 
header file and implementation file. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I have some question:</FONT></DIV>
<DIV><FONT face=Arial size=2>1. Why after I close the dialog, there is an error 
occurs? When I trace, it goes to smartpointer source .... </FONT></DIV>
<DIV><FONT face=Arial size=2>2. Why each time I open the dialog, it also appear 
the image inside the dialog. I mean to display the image after the Load button 
is pressed. </FONT></DIV>
<DIV><FONT face=Arial size=2>3. I want to display the original image in renderer 
ren1 and the filtered image in renderer ren2. But it doesn't work. When I change 
the value of threshold value both image also change.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thank you in advance</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Greeting</FONT></DIV>
<DIV><FONT face=Arial size=2>Paulus</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>// BinaryThresholdDlg.h : Header 
file<BR></DIV></FONT><FONT face=Arial size=2></FONT>
<DIV><FONT face=Arial size=2>#if 
!defined(AFX_BINARYTHRESHOLDDLG1_H__2D2E73F5_F350_4BC6_A757_586AE2651DBF__INCLUDED_)<BR>#define 
AFX_BINARYTHRESHOLDDLG1_H__2D2E73F5_F350_4BC6_A757_586AE2651DBF__INCLUDED_</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>#if _MSC_VER &gt; 1000<BR>#pragma once<BR>#endif // 
_MSC_VER &gt; 1000</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>//itk and vtk <BR>#include 
"itkBinaryThresholdImageFilter.h"<BR>#include "itkImage.h"<BR>#include 
"itkImageFileReader.h"<BR>#include "vtkImageActor.h"<BR>#include 
"vtkImageViewer.h"<BR>#include "vtkRenderer.h"<BR>#include 
"vtkRenderWindow.h"<BR>#include "vtkRenderWindowInteractor.h"<BR>#include 
"itkImageToVTKImageFilter.h"<BR>#include "vtkImageShiftScale.h"</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>//#define Dimension 2</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV><FONT face=Arial size=2>
<DIV><BR>// BinaryThresholdDlg1.h : header file<BR>//</DIV>
<DIV>&nbsp;</DIV>
<DIV>/////////////////////////////////////////////////////////////////////////////<BR>// 
CBinaryThresholdDlg dialog</DIV>
<DIV>&nbsp;</DIV>
<DIV>class CBinaryThresholdDlg : public CDialog<BR>{<BR>// 
Construction<BR>public:<BR>&nbsp;CBinaryThresholdDlg(CWnd* pParent = 
NULL);&nbsp;&nbsp; // standard 
constructor<BR>&nbsp;//~CBinaryThresholdDlg();&nbsp;&nbsp; // standard 
destructor</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;typedef int integer;<BR>&nbsp; typedef unsigned 
short&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PixelType;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; typedef&nbsp; unsigned char&nbsp; InputPixelType;<BR>&nbsp; 
typedef&nbsp; unsigned char&nbsp; OutputPixelType;<BR>&nbsp; typedef 
itk::Image&lt; InputPixelType,&nbsp; 2 &gt;&nbsp;&nbsp; 
InputImageType;<BR>&nbsp; typedef itk::Image&lt; OutputPixelType, 2 
&gt;&nbsp;&nbsp; OutputImageType;<BR>&nbsp; typedef 
itk::BinaryThresholdImageFilter&lt;InputImageType, OutputImageType &gt;&nbsp; 
FilterType;<BR>&nbsp; typedef itk::ImageFileReader&lt; InputImageType &gt;&nbsp; 
ReaderType;<BR>&nbsp; typedef itk::ImageToVTKImageFilter&lt; InputImageType &gt; 
ConnectorType;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; ReaderType::Pointer reader;<BR>&nbsp; ConnectorType::Pointer 
connector;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; vtkRenderer *ren1,*ren2;<BR>&nbsp; vtkRenderWindow 
*renWin;<BR>&nbsp; vtkRenderWindowInteractor *iren;<BR>&nbsp; vtkImageActor 
*imageInActor,*imageOutActor;<BR>&nbsp; vtkImageShiftScale&nbsp; 
*shiftScale;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; OutputPixelType outsideValue;<BR>&nbsp; OutputPixelType 
insideValue;<BR>&nbsp; InputPixelType lowerThreshold;<BR>&nbsp; InputPixelType 
upperThreshold;<BR>&nbsp; FilterType::Pointer filter; <BR></DIV>
<DIV>// Dialog Data<BR>&nbsp;//{{AFX_DATA(CBinaryThresholdDlg)<BR>&nbsp;enum { 
IDD = IDD_BYNARYTHRESHOLDDLG 
};<BR>&nbsp;CSliderCtrl&nbsp;m_SliderOutsideOutput;<BR>&nbsp;CSliderCtrl&nbsp;m_SliderInsideOutput;<BR>&nbsp;CSliderCtrl&nbsp;m_SliderOutsideInput;<BR>&nbsp;CSliderCtrl&nbsp;m_SliderInsideInput;<BR>&nbsp;CSpinButtonCtrl&nbsp;m_SpinOutsideOutput;<BR>&nbsp;CSpinButtonCtrl&nbsp;m_SpinInsideOutput;<BR>&nbsp;CSpinButtonCtrl&nbsp;m_SpinOutsideInput;<BR>&nbsp;CSpinButtonCtrl&nbsp;m_SpinInsideInput;<BR>&nbsp;CEdit&nbsp;m_fileName;<BR>&nbsp;//}}AFX_DATA</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>// Overrides<BR>&nbsp;// ClassWizard generated virtual function 
overrides<BR>&nbsp;//{{AFX_VIRTUAL(CBinaryThresholdDlg)<BR>&nbsp;protected:<BR>&nbsp;virtual 
void DoDataExchange(CDataExchange* pDX);&nbsp;&nbsp;&nbsp; // DDX/DDV 
support<BR>&nbsp;//}}AFX_VIRTUAL</DIV>
<DIV>&nbsp;</DIV>
<DIV>// Implementation</DIV>
<DIV>&nbsp;</DIV>
<DIV>protected:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;// Generated message map 
functions<BR>&nbsp;//{{AFX_MSG(CBinaryThresholdDlg)<BR>&nbsp;afx_msg void 
OnLoad();<BR>&nbsp;afx_msg int OnCreate(LPCREATESTRUCT 
lpCreateStruct);<BR>&nbsp;afx_msg void OnPaint();<BR>&nbsp;virtual BOOL 
OnInitDialog();<BR>&nbsp;afx_msg void OnHScroll(UINT nSBCode, UINT nPos, 
CScrollBar* 
pScrollBar);<BR>&nbsp;//}}AFX_MSG<BR>&nbsp;DECLARE_MESSAGE_MAP()<BR>};</DIV>
<DIV>&nbsp;</DIV>
<DIV>//{{AFX_INSERT_LOCATION}}<BR>// Microsoft Visual C++ will insert additional 
declarations immediately before the previous line.</DIV>
<DIV>&nbsp;</DIV>
<DIV>#endif // 
!defined(AFX_BINARYTHRESHOLDDLG1_H__2D2E73F5_F350_4BC6_A757_586AE2651DBF__INCLUDED_)<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>// BinaryThresholdDlg.cpp : implementation file<BR>//</DIV>
<DIV>&nbsp;</DIV>
<DIV>#include "resource.h"<BR>#include "stdafx.h"<BR>#include 
"Uias3D.h"<BR>#include "BinaryThresholdDlg.h"</DIV>
<DIV>&nbsp;</DIV>
<DIV>#ifdef _DEBUG<BR>#define new DEBUG_NEW<BR>#undef THIS_FILE<BR>static char 
THIS_FILE[] = __FILE__;<BR>#endif</DIV>
<DIV>&nbsp;</DIV>
<DIV>/////////////////////////////////////////////////////////////////////////////<BR>// 
CBinaryThresholdDlg dialog</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>CBinaryThresholdDlg::CBinaryThresholdDlg(CWnd* pParent 
/*=NULL*/)<BR>&nbsp;: CDialog(CBinaryThresholdDlg::IDD, 
pParent)<BR>{<BR>&nbsp;//{{AFX_DATA_INIT(CBinaryThresholdDlg)<BR>&nbsp;//}}AFX_DATA_INIT<BR>&nbsp; 
reader = ReaderType::New();<BR>&nbsp; connector = 
ConnectorType::New();<BR>&nbsp; ren1 = vtkRenderer::New();<BR>&nbsp; ren2 = 
vtkRenderer::New();<BR>&nbsp; renWin = vtkRenderWindow::New();<BR>&nbsp; iren = 
vtkRenderWindowInteractor::New();<BR>&nbsp; imageInActor = 
vtkImageActor::New();<BR>&nbsp; imageOutActor = vtkImageActor::New();<BR>&nbsp; 
shiftScale=vtkImageShiftScale ::New();<BR>&nbsp; filter = 
FilterType::New();<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>CBinaryThresholdDlg::~CBinaryThresholdDlg()<BR>{<BR>&nbsp; 
reader-&gt;Delete();<BR>&nbsp; connector-&gt;Delete();<BR>&nbsp; 
ren1-&gt;Delete();<BR>&nbsp; ren2-&gt;Delete();<BR>&nbsp; 
renWin-&gt;Delete();<BR>&nbsp; iren-&gt;Delete();<BR>&nbsp; 
imageInActor-&gt;Delete();<BR>&nbsp; imageOutActor-&gt;Delete();<BR>&nbsp; 
shiftScale-&gt;Delete();<BR>&nbsp; filter-&gt;Delete();<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>void CBinaryThresholdDlg::DoDataExchange(CDataExchange* 
pDX)<BR>{<BR>&nbsp;CDialog::DoDataExchange(pDX);<BR>&nbsp;//{{AFX_DATA_MAP(CBinaryThresholdDlg)<BR>&nbsp;DDX_Control(pDX, 
IDC_SLIDEROUTSIDEOUTPUT, m_SliderOutsideOutput);<BR>&nbsp;DDX_Control(pDX, 
IDC_SLIDEROUTSIDEINPUT, m_SliderInsideOutput);<BR>&nbsp;DDX_Control(pDX, 
IDC_SLIDERINSIDEOUTPUT, m_SliderOutsideInput);<BR>&nbsp;DDX_Control(pDX, 
IDC_SLIDERINSIDEINPUT, m_SliderInsideInput);<BR>&nbsp;DDX_Control(pDX, 
IDC_SPINOUTSIDEOUTPUT, m_SpinOutsideOutput);<BR>&nbsp;DDX_Control(pDX, 
IDC_SPINOUTSIDEINPUT, m_SpinInsideOutput);<BR>&nbsp;DDX_Control(pDX, 
IDC_SPININSIDEOUTPUT, m_SpinOutsideInput);<BR>&nbsp;DDX_Control(pDX, 
IDC_SPININSIDEINPUT, m_SpinInsideInput);<BR>&nbsp;//}}AFX_DATA_MAP<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>BEGIN_MESSAGE_MAP(CBinaryThresholdDlg, 
CDialog)<BR>&nbsp;//{{AFX_MSG_MAP(CBinaryThresholdDlg)<BR>&nbsp;ON_BN_CLICKED(IDC_LOAD, 
OnLoad)<BR>&nbsp;ON_WM_CREATE()<BR>&nbsp;ON_WM_PAINT()<BR>&nbsp;ON_WM_HSCROLL()<BR>&nbsp;//}}AFX_MSG_MAP<BR>END_MESSAGE_MAP()</DIV>
<DIV>&nbsp;</DIV>
<DIV>/////////////////////////////////////////////////////////////////////////////<BR>// 
CBinaryThresholdDlg message handlers</DIV>
<DIV>&nbsp;</DIV>
<DIV>void CBinaryThresholdDlg::OnLoad() <BR>{&nbsp; // this code is&nbsp;called 
when the load button is pushed</DIV>
<DIV><BR>&nbsp;// TODO: Add your control notification handler code 
here<BR>&nbsp; reader-&gt;SetFileName("brain.png");<BR></DIV>
<DIV>&nbsp; this-&gt;ren1-&gt;SetViewport(0.0,0.0,0.5,0.5);<BR>&nbsp; 
this-&gt;ren1-&gt;SetBackground(0.2,0.3,0.3); </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; this-&gt;ren2-&gt;SetViewport(0.5,0.0,1.0,0.5);<BR>&nbsp; 
this-&gt;ren2-&gt;SetBackground(0.4,0.5,0.6); </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; this-&gt;connector-&gt;SetInput(this-&gt;reader-&gt;GetOutput()); 
&nbsp;&nbsp; <BR>&nbsp; 
this-&gt;shiftScale-&gt;SetInput(this-&gt;connector-&gt;GetOutput());<BR>&nbsp; 
this-&gt;shiftScale-&gt;SetOutputScalarTypeToUnsignedChar();<BR>&nbsp; 
this-&gt;imageInActor-&gt;SetInput(this-&gt;shiftScale-&gt;GetOutput());<BR>&nbsp;&nbsp;</DIV>
<DIV>&nbsp; // Actors are added to the renderer. <BR>&nbsp; 
this-&gt;ren1-&gt;AddActor(this-&gt;imageInActor);<BR>&nbsp; 
this-&gt;ren2-&gt;AddActor(this-&gt;imageOutActor);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; //writer-&gt;SetInput( filter-&gt;GetOutput() );<BR>&nbsp; 
this-&gt;renWin-&gt;AddRenderer(this-&gt;ren1);<BR>&nbsp; 
this-&gt;renWin-&gt;AddRenderer(this-&gt;ren2);<BR>&nbsp; 
//this-&gt;iren-&gt;SetRenderWindow(this-&gt;renWin);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; renWin-&gt;Render();<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>int CBinaryThresholdDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
<BR>{<BR>&nbsp;if (CDialog::OnCreate(lpCreateStruct) == 
-1)<BR>&nbsp;&nbsp;return -1;<BR>&nbsp;<BR>&nbsp; // setup the parent 
window<BR>&nbsp; this-&gt;renWin-&gt;SetParentId(this-&gt;m_hWnd);<BR>&nbsp; 
this-&gt;renWin-&gt;SetPosition(250,0);<BR>&nbsp; 
this-&gt;renWin-&gt;SetSize(1024,1024);<BR>&nbsp; return 0;<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>void CBinaryThresholdDlg::OnPaint() <BR>{<BR>&nbsp;CPaintDC dc(this); 
// device context for painting<BR>&nbsp;<BR>&nbsp;// TODO: Add your message 
handler code here<BR>&nbsp;<BR>&nbsp;// Do not call CDialog::OnPaint() for 
painting messages<BR>&nbsp; 
this-&gt;filter-&gt;SetInput(this-&gt;reader-&gt;GetOutput() );<BR>&nbsp; 
this-&gt;filter-&gt;SetOutsideValue(outsideValue );<BR>&nbsp; 
this-&gt;filter-&gt;SetInsideValue(insideValue&nbsp; );<BR>&nbsp; 
this-&gt;filter-&gt;SetLowerThreshold(lowerThreshold );<BR>&nbsp; 
this-&gt;filter-&gt;SetUpperThreshold(upperThreshold );<BR>&nbsp; 
//this-&gt;filter-&gt;Update();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; this-&gt;connector-&gt;SetInput(this-&gt;filter-&gt;GetOutput()); 
&nbsp;&nbsp; <BR>&nbsp; 
this-&gt;shiftScale-&gt;SetInput(this-&gt;connector-&gt;GetOutput());<BR>&nbsp; 
this-&gt;shiftScale-&gt;SetOutputScalarTypeToUnsignedChar();<BR>&nbsp; 
this-&gt;imageOutActor-&gt;SetInput(this-&gt;shiftScale-&gt;GetOutput());</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; this-&gt;renWin-&gt;Render();</DIV>
<DIV>&nbsp;</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>BOOL CBinaryThresholdDlg::OnInitDialog() 
<BR>{<BR>&nbsp;CDialog::OnInitDialog();<BR>&nbsp;<BR>&nbsp;// TODO: Add extra 
initialization 
here<BR>&nbsp;m_SpinInsideInput.SetRange(0,255);<BR>&nbsp;m_SpinOutsideInput.SetRange(0,255);<BR>&nbsp;m_SpinInsideOutput.SetRange(0,255);<BR>&nbsp;m_SpinOutsideOutput.SetRange(0,255);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;m_SliderInsideInput.SetRange(0,255);<BR>&nbsp;m_SliderOutsideInput.SetRange(0,255);<BR>&nbsp;m_SliderInsideOutput.SetRange(0,255);<BR>&nbsp;m_SliderOutsideOutput.SetRange(0,255);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;m_SliderInsideInput.SetPos(0);<BR>&nbsp;m_SliderOutsideInput.SetPos(255);<BR>&nbsp;m_SliderInsideOutput.SetPos(0);<BR>&nbsp;m_SliderOutsideOutput.SetPos(255);</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;return TRUE;&nbsp; // return TRUE unless you set the focus to a 
control<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// EXCEPTION: OCX Property Pages should return FALSE<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>void CBinaryThresholdDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* 
pScrollBar) <BR>{<BR>&nbsp;// TODO: Add your message handler code here and/or 
call default<BR>&nbsp; &nbsp;lowerThreshold = 
m_SliderInsideInput.GetPos();<BR>&nbsp;upperThreshold = 
m_SliderOutsideInput.GetPos();<BR>&nbsp;insideValue&nbsp;&nbsp;&nbsp; = 
m_SliderInsideOutput.GetPos();<BR>&nbsp;outsideValue&nbsp;&nbsp; = 
m_SliderOutsideOutput.GetPos();<BR>&nbsp;InvalidateRect(NULL,FALSE);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;CDialog::OnHScroll(nSBCode, nPos, 
pScrollBar);<BR>}<BR></DIV></FONT></BODY></HTML>