<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7232.77">
<TITLE>In / out</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Hello,</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Terribly sorry. I have read the UG and looked over the tutorials concerning reading and writing to a buffer. My code compiles and runs …. but does nothing. To troubleshoot, I have implemented as fast and naïve threshold filter. Could someone please look this over and tell me what I am doing wrong? </FONT></P>
<P><FONT SIZE=2 FACE="Arial">Regards,</FONT>
<BR><FONT SIZE=2 FACE="Arial">Dan</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">void myfunction::helloWorldFilter(float *fdata, int xdim, int ydim, int zdim,</FONT>
<BR><FONT SIZE=2 FACE="Arial"> int numiter, QApplication *app)</FONT>
<BR><FONT SIZE=2 FACE="Arial">{</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">// </FONT>
<BR><FONT SIZE=2 FACE="Arial">// ***********************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">// Preliminaries to read the array into an ITK Image class *</FONT>
<BR><FONT SIZE=2 FACE="Arial">// ***********************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial"> typedef float PixelType;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> const unsigned int Dimension = 3;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> typedef itk::Image< PixelType, Dimension > ImageType;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> typedef itk::ImportImageFilter< PixelType, Dimension > ImportFilterType; </FONT>
<BR><FONT SIZE=2 FACE="Arial"> ImportFilterType::Pointer importer = ImportFilterType::New(); </FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> ImportFilterType::SizeType size;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> size[0] = xdim; // size along X</FONT>
<BR><FONT SIZE=2 FACE="Arial"> size[1] = ydim; // size along Y</FONT>
<BR><FONT SIZE=2 FACE="Arial"> size[2] = zdim; // size along Z</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> ImportFilterType::IndexType start;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> start[0]=0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> start[1]=0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> start[2]=0;</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> ImportFilterType::RegionType region;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> region.SetIndex( start );</FONT>
<BR><FONT SIZE=2 FACE="Arial"> region.SetSize( size );</FONT>
<BR><FONT SIZE=2 FACE="Arial"> importer->SetRegion( region );</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> double origin[ Dimension ];</FONT>
<BR><FONT SIZE=2 FACE="Arial"> origin[0] = 0.0; // X coordinate </FONT>
<BR><FONT SIZE=2 FACE="Arial"> origin[1] = 0.0; // Y coordinate</FONT>
<BR><FONT SIZE=2 FACE="Arial"> origin[2] = 0.0; // Z coordinate</FONT>
<BR><FONT SIZE=2 FACE="Arial"> importer->SetOrigin( origin );</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> double spacing[ Dimension ];</FONT>
<BR><FONT SIZE=2 FACE="Arial"> spacing[0] = 1.0; // along X direction </FONT>
<BR><FONT SIZE=2 FACE="Arial"> spacing[1] = 1.0; // along Y direction</FONT>
<BR><FONT SIZE=2 FACE="Arial"> spacing[2] = 1.0; // along Z direction</FONT>
<BR><FONT SIZE=2 FACE="Arial"> importer->SetSpacing( spacing );</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> const bool importFilterWillDeleteTheInputBuffer = false;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> PixelType * pixeldata = static_cast< PixelType * >( fdata );</FONT>
<BR><FONT SIZE=2 FACE="Arial"> const unsigned int numberOfPixels = size[0] * size[1] * size[2];</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> importer->SetImportPointer( pixeldata, numberOfPixels, </FONT>
<BR><FONT SIZE=2 FACE="Arial"> importFilterWillDeleteTheInputBuffer );</FONT>
<BR><FONT SIZE=2 FACE="Arial"> importer->Update();</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">// ****************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">// End preliminaries *</FONT>
<BR><FONT SIZE=2 FACE="Arial">// ****************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">// THRESHOLDING EXAMPLE</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">typedef itk::ThresholdImageFilter< ImageType > FilterType;</FONT>
<BR><FONT SIZE=2 FACE="Arial">FilterType::Pointer filter = FilterType::New();</FONT>
<BR><FONT SIZE=2 FACE="Arial">filter->SetInput( importer->GetOutput() );</FONT>
<BR><FONT SIZE=2 FACE="Arial">filter->ThresholdBelow( 180 );</FONT>
<BR><FONT SIZE=2 FACE="Arial">filter->Update();</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">// **************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">// End Filter *</FONT>
<BR><FONT SIZE=2 FACE="Arial">// **************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">// **************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">// Write back to array *</FONT>
<BR><FONT SIZE=2 FACE="Arial">// **************************************************************</FONT>
<BR><FONT SIZE=2 FACE="Arial">ImageType::PixelContainer * container;</FONT>
<BR><FONT SIZE=2 FACE="Arial">container = filter->GetOutput()->GetPixelContainer();</FONT>
<BR><FONT SIZE=2 FACE="Arial">container->SetContainerManageMemory( false );</FONT>
<BR><FONT SIZE=2 FACE="Arial">fdata = container->GetImportPointer();</FONT>
<BR><FONT SIZE=2 FACE="Arial">// </FONT>
<BR><FONT SIZE=2 FACE="Arial">//</FONT>
<BR><FONT SIZE=2 FACE="Arial">}</FONT>
</P>
<BR>
<BR>
<P><FONT SIZE=2 FACE="Arial">Best Regards,</FONT>
<BR><FONT SIZE=2 FACE="Arial">Dan</FONT>
<BR><FONT FACE="Times New Roman">Daniel R Einstein, PhD<BR>
Biological Monitoring and Modeling<BR>
Pacific Northwest National Laboratory<BR>
P.O. Box 999; MSIN P7-59<BR>
Richland, WA 99352<BR>
Tel: 509/ 376-2924<BR>
Fax: 509/376-9064<BR>
</FONT><A HREF="mailto:daniel.einstein@pnl.gov"><U><FONT COLOR="#0000FF" FACE="Times New Roman">daniel.einstein@pnl.gov</FONT></U></A>
</P>
<BR>
</BODY>
</HTML>