/* ImLib3D
 * Copyright (c) 2001, ULP-IPB Strasbourg.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
/*! \file ImageAs1DVector.hxx */

#ifndef _ImageAs1DVector_hxx
#define _ImageAs1DVector_hxx


template <class ImageType>
void
IP3D::ScalarProduct(const ImageType& im1, const ImageType& im2, double & retValue)
{
	ImageProcessorArgs<ImageType> args;
	args.AddSrc(im1);
	args.AddSrc(im2);
	args.SameSize();
	
	typename ImageType::const_iteratorFast p1;
	typename ImageType::const_iteratorFast p2;	

	retValue = 0;
	for (p1 = im1.begin(), p2 = im2.begin(); p1 != im1.end(); p1++, p2++)
	{
		retValue += (*p1) * (*p2);
	}
}
#ifdef DEPRECATED

namespace IP3D
{
template <class ImageType>
void
ForAllVoxels(Function1D<typename ImageType::value_type, typename ImageType::value_type>& fnc, const ImageType& im1, ImageType& res)
{
	ImageProcessorArgs<ImageType> args;
	args.AddSrc(im1);
	args.AddDest(res);
	args.SameSize();
	
	typename ImageType::const_iteratorFast p1;
	typename ImageType::iteratorFast p2;	

	for (p1 = im1.begin(), p2 = res.begin(); p1 != im1.end(); p1++, p2++)
	{
		(*p2) = fnc(*p1);
	}
}
#endif// DEPRECATED

#endif// _ImageAs1DVector_hxx
