%
% Complete documentation on the extended LaTeX markup used for Insight
% documentation is available in ``Documenting Insight'', which is part
% of the standard documentation for Insight.  It may be found online
% at:
%
%     http://www.itk.org/

\documentclass{InsightArticle}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  hyperref should be the last package to be loaded.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[dvips,
bookmarks,
bookmarksopen,
backref,
colorlinks,linkcolor={blue},citecolor={blue},urlcolor={blue},
]{hyperref}
% to be able to use options in graphics
\usepackage{graphicx}
% for pseudo code
\usepackage{listings}
% subfigures
\usepackage{subfigure}


%  This is a template for Papers to the Insight Journal. 
%  It is comparable to a technical report format.

% The title should be descriptive enough for people to be able to find
% the relevant document. 
\title{ImageLinearIterator - WithIndex removed}

% Increment the release number whenever significant changes are made.
% The author and/or editor can define 'significant' however they like.
\release{0.00}

% At minimum, give your name and an email address.  You can include a
% snail-mail address if you like.
\author{Richard Beare}
\authoraddress{Richard.Beare@ieee.org}

\begin{document}
\maketitle

\ifhtml
\chapter*{Front Matter\label{front}}
\fi


\begin{abstract}
\noindent
% The abstract should be a paragraph or two long, and describe the
% scope of the document.
ITK includes a number of iterators including the {\em
itkImageLinearConstIteratorWithIndex} and {\em
itkImageLinearIteratorWithIndex} that support visiting voxels along
lines parallel to the image axes. This is particularly useful for
separable filters. This article introduces modified versions that do
not maintain location index so that filters that don't require index
information can perform faster. 

Preliminary tests indicate that the iteration speed is improved, but
that filters such as the RecursiveSmoothingGaussianImageFilter do not
change significantly.
\end{abstract}

\tableofcontents


% \url{http://www.itk.org}
% \code{Insight/Documentation/Style.pdf}
% \section{Principles of Solar Spot Detection}
% \cite{ITKSoftwareGuide}.
% \doxygen{ImageToImageFilter}

% \small \begin{verbatim}
% \end{verbatim} \normalsize


% The {itemize} environment uses a bullet for each \item.  If you want the 
% \item's numbered, use the {enumerate} environment instead.
% \begin{itemize}
%   \item  Insight Toolkit 2.4.
%   \item  CMake 2.2
% \end{itemize}

% \ref{cthead1}

\section{Introduction}
The two iterators presented here are the {\em
itkImageLinearConstIterator} and {\em itkImageLinearIterator}. They
are simply modifications of the {\em WithIndex} filters with the index
tracking code removed. The start and end of line offsets are
pre-computed and used to iterate along a line. The methods used to
move to the next line are based on the {\em WithIndex} versions of the
iterator.

The interface to the new iterators has the standard form.

The most recent versions of these packages can be
obtained from \url{http://voxel.jouy.inra.fr/darcsweb/}\footnote{
The most recent versions can be obtained using darcs \cite{DarcsWebSite}
with the command {\em darcs get http://voxel.jouy.inra.fr/\\darcs/contrib-itk/package},
where {\em package} must be replace by {\em linearIterator}}.

\section{Correctness testing}
Functionality of the the modified iterators was validated using an
extended version of {\em itkImageLinearIteratorTest} from the
InsightToolkit distribution. The extensions were to test the iterators
using lines in 3 directions, rather than the one direction of the
original.

It is possible that some constructors are missing or incorrect because
I don't have a feel for what is necessary or expected.

\section{Performance testing}
Two performance tests have been provided. The first simply visits each
voxel using the new and old iterators, while the second used a version
of RecursiveSmoothingGaussianImageFilter that was modified to use the
new iterators. The results on an AMD Athlon(TM) XP 2000, 256Kb cache are shown in Tables \ref{tab:iterationPerf} and \ref{tab:smoothingPerf}.

\begin{table}[htbp]
\centering
\begin{tabular}{ccc}
\hline
Direction  &  WithIndex &  New \\
\hline
0   &    0.659  & 0.29 \\
1   &    0.698  & 0.297 \\
\hline
\end{tabular}
\caption{Change in iteration speed for 500 repeats of a $487 \times 609$ image. \label{tab:iterationPerf}}
\end{table}

\begin{table}[htbp]
\centering
\begin{tabular}{cc}
\hline
WithIndex &  New \\
\hline
0.0597 & 0.0583 \\
\hline
\end{tabular}
\caption{Very similar smoothing performance for a $487 \times 609$ image. \label{tab:smoothingPerf}}
\end{table}

The raw iteration time is slightly better than half the original
time. However the modified smoothing filter did not exhibit a
significant change in performance, presumably because the proportion
of time spent in the iterator is quite low. A similar result was
obtained for the parabolicMorphology filters, which prompted this
development.

\appendix



\bibliographystyle{plain}
\bibliography{InsightJournal,local}
\nocite{ITKSoftwareGuide}

\end{document}

