Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

NoiseEstimation.cpp

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00020 #include <ImLib3D/NoiseEstimation.hpp>
00021 #include <ImLib3D/Arithmetic.hpp>
00022 
00023 // remarq Vik : I couldn't get a template version to link when compiling in ../bin
00024 
00025 void 
00026 IP3D::NoiseVarianceEstimation(const Image3Df& image, double& variance)
00027 {
00028     Size3D size(3,3,3);
00029     SeparableFilter laplace1(size, Vect3Di(1,1,1));
00030     vector<float> onedir;
00031     onedir.push_back(1.0);
00032     onedir.push_back(-2.0);
00033     onedir.push_back(1.0);
00034     laplace1.xcomponent = onedir;
00035     laplace1.ycomponent = onedir;
00036     laplace1.zcomponent = onedir;
00037         
00038     Image3Df edgeImage;
00039     IP3D::SeparableConvolution(image, laplace1, edgeImage);
00040 //      ImLib3DDisplay::Show(edgeImage);
00041 
00042     edgeImage*=edgeImage;
00043     variance = edgeImage.Sum();
00044     variance/= 216*(edgeImage.Width()-2)*(edgeImage.Height()-2)*(edgeImage.Depth()-2);
00045 //      cout << "Estimated noise in image: " << variance << endl;
00046 
00047 }

Generated on Fri Jun 17 13:36:06 2005 for ImLib3D by  doxygen 1.4.2