00001 //=========================================================================== 00002 // The Level-Set Segmentation Library (LSSEG) 00003 // 00004 // 00005 // Copyright (C) 2000-2005 SINTEF ICT, Applied Mathematics, Norway. 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation version 2 of the License. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with this program; if not, write to the Free Software 00018 // Foundation, Inc., 00019 // 59 Temple Place - Suite 330, 00020 // Boston, MA 02111-1307, USA. 00021 // 00022 // Contact information: e-mail: tor.dokken@sintef.no 00023 // SINTEF ICT, Department of Applied Mathematics, 00024 // P.O. Box 124 Blindern, 00025 // 0314 Oslo, Norway. 00026 // 00027 // 00028 // Other licenses are also available for this software, notably licenses 00029 // for: 00030 // - Building commercial software. 00031 // - Building software whose source code you wish to keep private. 00032 // 00033 //=========================================================================== 00034 //=========================================================================== 00035 // 00036 // File: image_utils.h 00037 // 00038 // Created: Wed Feb 22 14:59:21 2006 00039 // 00040 // Author: Odd A. Andersen <Odd.Andersen@sintef.no> 00041 // 00042 // Revision: $Id: image_utils.h,v 1.2 2006/11/13 02:29:26 oan Exp $ 00043 // 00044 // Description: 00047 00048 //=========================================================================== 00049 00050 #ifndef _IMAGE_UTILS_H 00051 #define _IMAGE_UTILS_H 00052 00053 #include "errormacros.h" 00054 namespace lsseg { 00055 00056 //=========================================================================== 00065 template<typename T> 00066 void combine_channel_images(const Image<T>** channel_array, // pointer to an array of pointers 00067 int num_input_images, 00068 Image<T>& result) 00069 //=========================================================================== 00070 { 00071 assert(num_input_images > 0); 00072 for (int i = 1; i < num_input_images; ++i) { 00073 ALWAYS_ERROR_IF(!((channel_array[i])->spatial_compatible(*channel_array[i-1])), 00074 "Channel size mismatch."); 00075 00076 } 00077 const int X = channel_array[0]->dimx(); 00078 const int Y = channel_array[0]->dimy(); 00079 const int Z = channel_array[0]->dimz(); 00080 int total_num_channels = 0; 00081 for (int i = 0; i < num_input_images; ++i) { 00082 total_num_channels += channel_array[i]->numChannels(); 00083 } 00084 result.resize(X, Y, Z, total_num_channels); 00085 00086 // filling result 00087 T* tp = result.begin(); 00088 for (int i = 0; i < num_input_images; ++i) { 00089 copy(channel_array[i]->begin(), channel_array[i]->end(), tp); 00090 tp += channel_array[i]->size(); 00091 } 00092 } 00093 00094 }; // end namespace lsseg; 00095 00096 #endif // _IMAGE_UTILS_H 00097