Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > d5e74628f0e673bb8680aebce32b2c04 > files > 19

itk-doc-3.12.0-1mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta name="robots" content="noindex">
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>ITK: DataRepresentation/Image/Image2.cxx</title>
<link href="DoxygenStyle.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">


<!--  Section customized for INSIGHT : Tue Jul 17 01:02:45 2001 -->
<center>
<a href="index.html" class="qindex">Main Page</a>&nbsp;&nbsp; 
<a href="modules.html" class="qindex">Groups</a>&nbsp;&nbsp;
<a href="namespaces.html" class="qindex">Namespace List</a>&nbsp;&nbsp;
<a href="hierarchy.html" class="qindex">Class Hierarchy</a>&nbsp;&nbsp;
<a href="classes.html" class="qindex">Alphabetical List</a>&nbsp;&nbsp;
<a href="annotated.html" class="qindex">Compound List</a>&nbsp;&nbsp; 
<a href="files.html" class="qindex">File
List</a>&nbsp;&nbsp; 
<a href="namespacemembers.html" class="qindex">Namespace Members</a>&nbsp;&nbsp; 
<a href="functions.html" class="qindex">Compound Members</a>&nbsp;&nbsp; 
<a href="globals.html" class="qindex">File Members</a>&nbsp;&nbsp;
<a href="pages.html" class="qindex">Concepts</a></center>


<!-- Generated by Doxygen 1.5.9 -->
<div class="contents">
<h1>DataRepresentation/Image/Image2.cxx</h1><div class="fragment"><pre class="fragment"><span class="comment">/*=========================================================================</span>
<span class="comment"></span>
<span class="comment">  Program:   Insight Segmentation &amp; Registration Toolkit</span>
<span class="comment">  Module:    $RCSfile: Image2.cxx,v $</span>
<span class="comment">  Language:  C++</span>
<span class="comment">  Date:      $Date: 2005-02-08 03:51:52 $</span>
<span class="comment">  Version:   $Revision: 1.19 $</span>
<span class="comment"></span>
<span class="comment">  Copyright (c) Insight Software Consortium. All rights reserved.</span>
<span class="comment">  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.</span>
<span class="comment"></span>
<span class="comment">     This software is distributed WITHOUT ANY WARRANTY; without even </span>
<span class="comment">     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR </span>
<span class="comment">     PURPOSE.  See the above copyright notices for more information.</span>
<span class="comment"></span>
<span class="comment">=========================================================================*/</span>
<span class="preprocessor">#if defined(_MSC_VER)</span>
<span class="preprocessor"></span><span class="preprocessor">#pragma warning ( disable : 4786 )</span>
<span class="preprocessor"></span><span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
<span class="preprocessor">#include "<a class="code" href="itkImage_8h.html">itkImage.h</a>"</span>

<span class="comment">//  Software Guide : BeginLatex</span>
<span class="comment">//</span>
<span class="comment">//  The first thing required to read an image from a file is to include</span>
<span class="comment">//  the header file of the \doxygen{ImageFileReader} class.</span>
<span class="comment">//</span>
<span class="comment">//  Software Guide : EndLatex </span>

<span class="comment">// Software Guide : BeginCodeSnippet</span>
<span class="preprocessor">#include "<a class="code" href="itkImageFileReader_8h.html">itkImageFileReader.h</a>"</span>
<span class="comment">// Software Guide : EndCodeSnippet</span>

<span class="keywordtype">int</span> <a name="a0"></a><a class="code" href="itkTestMain_8h.html#dacbe0175a79dff748855d8c9839f82b">main</a>( <span class="keywordtype">int</span> , <span class="keywordtype">char</span> * argv[])
{
  <span class="comment">// Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">// Then, the image type should be defined by specifying the</span>
  <span class="comment">// type used to represent pixels and the dimensions of the image.</span>
  <span class="comment">//</span>
  <span class="comment">// Software Guide : EndLatex </span>

  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>          PixelType;
  <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>             Dimension = 3;

  <span class="keyword">typedef</span> <a name="_a1"></a><a class="code" href="classitk_1_1Image.html" title="Templated n-dimensional image class.">itk::Image&lt; PixelType, Dimension &gt;</a>   ImageType;
  <span class="comment">// Software Guide : EndCodeSnippet</span>


  <span class="comment">// Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">// Using the image type, it is now possible to instantiate the image reader</span>
  <span class="comment">// class. The image type is used as a template parameter to define how the</span>
  <span class="comment">// data will be represented once it is loaded into memory. This type does</span>
  <span class="comment">// not have to correspond exactly to the type stored in the file. However,</span>
  <span class="comment">// a conversion based on C-style type casting is used, so the type chosen</span>
  <span class="comment">// to represent the data on disk must be sufficient to characterize it</span>
  <span class="comment">// accurately. Readers do not apply any transformation to the pixel data</span>
  <span class="comment">// other than casting from the pixel type of the file to the pixel type of</span>
  <span class="comment">// the ImageFileReader. The following illustrates a typical</span>
  <span class="comment">// instantiation of the ImageFileReader type.</span>
  <span class="comment">//</span>
  <span class="comment">// \index{itk::ImageFileReader!Instantiation}</span>
  <span class="comment">// \index{itk::Image!read}</span>
  <span class="comment">//</span>
  <span class="comment">// Software Guide : EndLatex </span>

  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  <span class="keyword">typedef</span> <a name="_a2"></a><a class="code" href="classitk_1_1ImageFileReader.html" title="Data source that reads image data from a single file.">itk::ImageFileReader&lt; ImageType &gt;</a>  ReaderType;
  <span class="comment">// Software Guide : EndCodeSnippet</span>


  <span class="comment">// Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">// The reader type can now be used to create one reader object.  A</span>
  <span class="comment">// \doxygen{SmartPointer} (defined by the \code{::Pointer} notation) is used</span>
  <span class="comment">// to receive the reference to the newly created reader.  The \code{New()}</span>
  <span class="comment">// method is invoked to create an instance of the image reader.</span>
  <span class="comment">//</span>
  <span class="comment">// \index{itk::ImageFileReader!New()}</span>
  <span class="comment">// \index{itk::ImageFileReader!Pointer}</span>
  <span class="comment">//</span>
  <span class="comment">// Software Guide : EndLatex </span>

  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  <a name="a3"></a><a class="code" href="itkFEMMacro_8h.html#539cce1a3282ba59952dedcbf9cdb23f">ReaderType::Pointer</a> reader = <a name="a4"></a><a class="code" href="namespaceHardConnectedComponentImageFilter.html#870262f145e0b45206db74df8053b59c">ReaderType::New</a>();
  <span class="comment">// Software Guide : EndCodeSnippet</span>


  <span class="comment">// Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">// The minimum information required by the reader is the filename</span>
  <span class="comment">// of the image to be loaded in memory. This is provided through</span>
  <span class="comment">// the \code{SetFileName()} method. The file format here is inferred</span>
  <span class="comment">// from the filename extension. The user may also explicitly specify the</span>
  <span class="comment">// data format explicitly using the \doxygen{ImageIO} (See</span>
  <span class="comment">// Chapter~\ref{sec:ImagReadWrite} \pageref{sec:ImagReadWrite} for more</span>
  <span class="comment">// information</span>
  <span class="comment">//</span>
  <span class="comment">// \index{itk::ImageFileReader!SetFileName()}</span>
  <span class="comment">//</span>
  <span class="comment">// Software Guide : EndLatex </span>

  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  <span class="keyword">const</span> <span class="keywordtype">char</span> * filename = argv[1];
  reader-&gt;SetFileName( filename );
  <span class="comment">// Software Guide : EndCodeSnippet</span>


  <span class="comment">// Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">// Reader objects are referred to as pipeline source objects; they</span>
  <span class="comment">// respond to pipeline update requests and initiate the data flow in the</span>
  <span class="comment">// pipeline. The pipeline update mechanism ensures that the reader only</span>
  <span class="comment">// executes when a data request is made to the reader and the reader has</span>
  <span class="comment">// not read any data.  In the current example we explicitly invoke the</span>
  <span class="comment">// \code{Update()} method because the output of the reader is not connected</span>
  <span class="comment">// to other filters. In normal application the reader's output is connected</span>
  <span class="comment">// to the input of an image filter and the update invocation on the filter</span>
  <span class="comment">// triggers an update of the reader. The following line illustrates how an</span>
  <span class="comment">// explicit update is invoked on the reader.</span>
  <span class="comment">//</span>
  <span class="comment">// \index{itk::ImageFileReader!Update()}</span>
  <span class="comment">//</span>
  <span class="comment">// Software Guide : EndLatex </span>

  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  reader-&gt;Update();
  <span class="comment">// Software Guide : EndCodeSnippet</span>


  <span class="comment">// Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">// Access to the newly read image can be gained by calling the</span>
  <span class="comment">// \code{GetOutput()} method on the reader. This method can also be called</span>
  <span class="comment">// before the update request is sent to the reader.  The reference to the</span>
  <span class="comment">// image will be valid even though the image will be empty until the reader</span>
  <span class="comment">// actually executes.</span>
  <span class="comment">//</span>
  <span class="comment">// \index{itk::ImageFileReader!GetOutput()}</span>
  <span class="comment">//</span>
  <span class="comment">// Software Guide : EndLatex </span>

  <span class="comment">// Software Guide : BeginCodeSnippet</span>
  <a class="code" href="itkFEMMacro_8h.html#539cce1a3282ba59952dedcbf9cdb23f">ImageType::Pointer</a> image = reader-&gt;GetOutput();
  <span class="comment">// Software Guide : EndCodeSnippet</span>

  <span class="comment">// Software Guide : BeginLatex</span>
  <span class="comment">//</span>
  <span class="comment">// Any attempt to access image data before the reader executes will yield</span>
  <span class="comment">// an image with no pixel data. It is likely that a program crash will </span>
  <span class="comment">// result since the image will not have been properly initialized.</span>
  <span class="comment">//</span>
  <span class="comment">// Software Guide : EndLatex </span>

  <span class="keywordflow">return</span> 0;
}


</pre></div> </div>
<hr><address><small>
Generated at Thu May 7 22:04:07 2009 for ITK  by <a href="http://www.stack.nl/~dimitri/doxygen/index.html"> <img 
src="http://www.stack.nl/~dimitri/doxygen/doxygen.png" alt="doxygen"
align="middle" border=0 width=110 height=53>
</a> 1.5.9 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
 &copy;&nbsp;1997-2000</small></address>
</body>
</html>