<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Dear Pedro,<br>
<br>
This is the code I used to compile the ThresholdImageFilter. I works
perfectly, so compile and execute it and see if it works to you. You
have to include the input image in the debug/release directory (if you
compile using Visual Studio).<br>
<br>
#if defined(_MSC_VER)<br>
#pragma warning ( disable : 4786 )<br>
#endif<br>
<br>
#ifdef __BORLANDC__<br>
#define ITK_LEAN_AND_MEAN<br>
#endif<br>
<br>
<br>
#include "itkThresholdImageFilter.h"<br>
#include "itkImage.h"<br>
#include "itkImageFileReader.h"<br>
#include "itkImageFileWriter.h"<br>
<br>
int main( int argc, char * argv[] )<br>
{<br>
<br>
if( argc < 3 )<br>
{<br>
std::cerr << "Usage: " << argv[0] << "
inputImageFile ";<br>
std::cerr << " outputImageFile1" << std::endl; <br>
return EXIT_FAILURE;<br>
}<br>
<br>
<br>
typedef float PixelType;<br>
typedef itk::Image< PixelType, 3 > ImageType;<br>
typedef itk::ThresholdImageFilter< ImageType > FilterType;<br>
typedef itk::ImageFileReader< ImageType > ReaderType;<br>
typedef itk::ImageFileWriter< ImageType > WriterType;<br>
<br>
ReaderType::Pointer reader = ReaderType::New();<br>
FilterType::Pointer filter = FilterType::New();<br>
WriterType::Pointer writer = WriterType::New();<br>
<br>
writer->SetInput( filter->GetOutput() );<br>
reader->SetFileName( argv[1] );<br>
reader->Update();<br>
<br>
<br>
filter->SetInput( reader->GetOutput() );<br>
filter->SetOutsideValue( 0 );<br>
<br>
filter->ThresholdBelow( 1 );<br>
filter->Update();<br>
<br>
<br>
writer->SetFileName( argv[2] );<br>
writer->Update();<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
Hope that helps<br>
Best<br>
Irene<br>
<br>
<br>
<br>
<br>
Pedro Madrigal Bayonas wrote:
<blockquote cite="midBAY134-W4724C34089C032097458E7D8E00@phx.gbl"
type="cite">
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>Hi, <br>
I´m new user, when I compile and execute ThresholdImageFilter.exe,
nothing happens.<br>
what I must change in the code to read an image(for example mri.png)
that is in the same directory of the .exe and put the ouptfiles there
too??<br>
<br>
Thanks!<br>
<br>
<br>
/*=========================================================================<br>
Program: Insight Segmentation & Registration Toolkit<br>
Module: $RCSfile: ThresholdImageFilter.cxx,v $<br>
Language: C++<br>
Date: $Date: 2005/08/31 13:55:22 $<br>
Version: $Revision: 1.28 $<br>
Copyright (c) Insight Software Consortium. All rights reserved.<br>
See ITKCopyright.txt or <a
href="http://www.itk.org/HTML/Copyright.htm">http://www.itk.org/HTML/Copyright.htm</a>
for details.<br>
This software is distributed WITHOUT ANY WARRANTY; without even <br>
the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR <br>
PURPOSE. See the above copyright notices for more information.<br>
=========================================================================*/<br>
#if defined(_MSC_VER)<br>
#pragma warning ( disable : 4786 )<br>
#endif<br>
#ifdef __BORLANDC__<br>
#define ITK_LEAN_AND_MEAN<br>
#endif<br>
<br>
#include "itkThresholdImageFilter.h"<br>
// Software Guide : EndCodeSnippet<br>
#include "itkImage.h"<br>
#include "itkImageFileReader.h"<br>
#include "itkImageFileWriter.h"<br>
int main( int argc, char *argv[])<br>
{<br>
<br>
if( argc < 5 )<br>
{<br>
std::cerr << "Usage: " << argv[0] << "
inputImageFile ";<br>
std::cerr << " outputImageFile1 outputImageFile2
outputImageFile3" << std::endl; <br>
return EXIT_FAILURE;<br>
}<br>
<br>
// Software Guide : BeginLatex<br>
//<br>
// Then we must decide what pixel type to use for the image. This
filter is<br>
// templated over a single image type because the algorithm only
modifies<br>
// pixel values outside the specified range, passing the rest through<br>
// unchanged.<br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
typedef unsigned char PixelType;<br>
// Software Guide : EndCodeSnippet<br>
// Software Guide : BeginLatex<br>
//<br>
// The image is defined using the pixel type and the dimension.<br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
typedef itk::Image< PixelType, 2 > ImageType;<br>
// Software Guide : EndCodeSnippet<br>
<br>
// Software Guide : BeginLatex<br>
//<br>
// The filter can be instantiated using the image type defined above.<br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
typedef itk::ThresholdImageFilter< ImageType > FilterType;<br>
// Software Guide : EndCodeSnippet<br>
<br>
// Software Guide : BeginLatex<br>
//<br>
// An \doxygen{ImageFileReader} class is also instantiated in order
to read<br>
// image data from a file. <br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
typedef itk::ImageFileReader< ImageType > ReaderType;<br>
// Software Guide : EndCodeSnippet<br>
// Software Guide : BeginLatex<br>
// <br>
// An \doxygen{ImageFileWriter} is instantiated in order to write the<br>
// output image to a file.<br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
typedef itk::ImageFileWriter< ImageType > WriterType;<br>
// Software Guide : EndCodeSnippet<br>
<br>
// Software Guide : BeginLatex<br>
//<br>
// Both the filter and the reader are created by invoking their
\code{New()}<br>
// methods and assigning the result to SmartPointers.<br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
ReaderType::Pointer reader = ReaderType::New();<br>
FilterType::Pointer filter = FilterType::New();<br>
// Software Guide : EndCodeSnippet<br>
WriterType::Pointer writer = WriterType::New();<br>
writer->SetInput( filter->GetOutput() );<br>
reader->SetFileName( argv[1] );<br>
<br>
// Software Guide : BeginLatex<br>
// <br>
// The image obtained with the reader is passed as input to the<br>
// \doxygen{ThresholdImageFilter}.<br>
//<br>
// \index{itk::ThresholdImageFilter!SetInput()}<br>
// \index{itk::FileImageReader!GetOutput()}<br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
filter->SetInput( reader->GetOutput() );<br>
// Software Guide : EndCodeSnippet<br>
<br>
// Software Guide : BeginLatex<br>
// <br>
// The method \code{SetOutsideValue()} defines the intensity value
to be<br>
// assigned to those pixels whose intensities are outside the range
defined<br>
// by the lower and upper thresholds. <br>
// <br>
// \index{itk::ThresholdImageFilter!SetOutsideValue()}<br>
// \index{SetOutsideValue()!itk::ThresholdImageFilter}<br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
filter->SetOutsideValue( 0 );<br>
// Software Guide : EndCodeSnippet<br>
<br>
// Software Guide : BeginLatex<br>
// <br>
// The method \code{ThresholdBelow()} defines the intensity value
below<br>
// which pixels of the input image will be changed to the
\code{OutsideValue}.<br>
// <br>
// \index{itk::ThresholdImageFilter!ThresholdBelow()}<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
filter->ThresholdBelow( 180 );<br>
// Software Guide : EndCodeSnippet<br>
// Software Guide : BeginLatex<br>
// <br>
// The filter is executed by invoking the \code{Update()} method. If
the<br>
// filter is part of a larger image processing pipeline, calling<br>
// \code{Update()} on a downstream filter will also trigger update
of this<br>
// filter.<br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
filter->Update();<br>
// Software Guide : EndCodeSnippet<br>
<br>
writer->SetFileName( argv[2] );<br>
writer->Update();<br>
<br>
// Software Guide : BeginLatex<br>
// <br>
// The output of this example is shown in<br>
// Figure~\ref{fig:ThresholdTransferFunctionBelow}. The second
operating mode of<br>
// the filter is now enabled by calling the method<br>
// \code{ThresholdAbove()}.<br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
filter->ThresholdAbove( 180 );<br>
filter->Update();<br>
// Software Guide : EndCodeSnippet<br>
<br>
writer->SetFileName( argv[3] );<br>
writer->Update();<br>
// Software Guide : BeginLatex<br>
// <br>
// Updating the filter with this new setting produces the output
shown in<br>
// Figure~\ref{fig:ThresholdTransferFunctionAbove}. The third
operating<br>
// mode of the filter is enabled by calling
\code{ThresholdOutside()}.<br>
//<br>
// Software Guide : EndLatex <br>
// Software Guide : BeginCodeSnippet<br>
filter->ThresholdOutside( 170,190 );<br>
filter->Update();<br>
// Software Guide : EndCodeSnippet<br>
<br>
writer->SetFileName( argv[4] );<br>
writer->Update();<br>
<br>
// Software Guide : BeginLatex<br>
// <br>
// The output of this third, ``band-pass'' thresholding mode is
shown in<br>
// Figure~\ref{fig:ThresholdTransferFunctionOutside}.<br>
//<br>
// The examples in this <br>
// section also illustrate the limitations of the thresholding
filter for performing<br>
// segmentation by itself. These limitations are particularly
noticeable<br>
// in noisy images and in images lacking spatial uniformity, as is
the case<br>
// with MRI due to field bias.<br>
//<br>
// \relatedClasses<br>
// \begin{itemize}<br>
// \item \doxygen{BinaryThresholdImageFilter}<br>
// \end{itemize}<br>
//<br>
// Software Guide : EndLatex <br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
<hr>Sigue los principales acontecimientos deportivos en directo. <a
href="http://video.msn.com/video.aspx?mkt=es-es" target="_new">MSN
Motor</a>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Insight-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Insight-users@itk.org">Insight-users@itk.org</a>
<a class="moz-txt-link-freetext" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>
</pre>
</blockquote>
<br>
</body>
</html>