diff --git a/modules/img/alg/tests/CMakeLists.txt b/modules/img/alg/tests/CMakeLists.txt index cdbd8b459c114e0765bb53280f144043be34a8cc..cea46dcb979d4f6a73e515b81bf26858876f2468 100644 --- a/modules/img/alg/tests/CMakeLists.txt +++ b/modules/img/alg/tests/CMakeLists.txt @@ -14,6 +14,7 @@ test_power_spectrum.cc test_shift.cc test_stat.cc test_transform.cc +test_normalizer.cc tests.cc ) diff --git a/modules/img/alg/tests/test_normalizer.cc b/modules/img/alg/tests/test_normalizer.cc new file mode 100644 index 0000000000000000000000000000000000000000..e072626dbc562e70703ae226606c4c9e0d1f6c9d --- /dev/null +++ b/modules/img/alg/tests/test_normalizer.cc @@ -0,0 +1,76 @@ +//------------------------------------------------------------------------------ +// This file is part of the OpenStructure project <www.openstructure.org> +// +// Copyright (C) 2008-2011 by the OpenStructure authors +// Copyright (C) 2003-2010 by the IPLT authors +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License as published by the Free +// Software Foundation; either version 3.0 of the License, or (at your option) +// any later version. +// This library 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 Lesser General Public License for more +// details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this library; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +//------------------------------------------------------------------------------ + +/* + Author: Andreas Schenk +*/ + +#include <iostream> + +#include "tests.hh" + +#include <ost/img/image.hh> +#include <ost/img/alg/normalizer_factory.hh> +#include <ost/img/alg/stat.hh> + + + +namespace { + +using namespace ost::img; +using namespace ost::img::alg; + +void test() +{ + boost::test_tools::close_at_tolerance<Real> close_test(::boost::test_tools::percent_tolerance(0.001)); + ost::img::ImageHandle testimage=ost::img::CreateImage(ost::img::Extent(ost::img::Point(0,0),ost::img::Point(3,3))); + int counter=0; + for (ost::img::ExtentIterator i(testimage.GetExtent()); !i.AtEnd(); ++i, ++counter) { + testimage.SetReal(i, counter); + } + ost::img::alg::Normalizer norm=ost::img::alg::CreateLinearRangeNormalizer(testimage,0.0,65535.0); + ost::img::ImageHandle scaled_image=testimage.Apply(norm); + scaled_image+=0.01; //if all values are > 0.0 we can use close_at_tolerance + bool failed=false; + ost::img::ExtentIterator eit(testimage.GetExtent()); + for(;!eit.AtEnd();++eit) { + if( ! close_test(scaled_image.GetReal(eit),testimage.GetReal(eit)/15.0*65535.0+0.01)){ + failed=true; + break; + } + } + if(failed){ + BOOST_ERROR("Normalizer failed at point " + << ost::img::Point(eit)<< ". Should be " + << testimage.GetReal(eit)/15.0*65535.0+0.01 << ", but " + << scaled_image.GetReal(eit) << " found."); + } +} + +} // ns + +test_suite* CreateNormalizerTest() +{ + test_suite* ts=BOOST_TEST_SUITE("img alg Normalizer Test"); + + ts->add(BOOST_TEST_CASE(&test)); + + return ts; +} diff --git a/modules/img/alg/tests/tests.cc b/modules/img/alg/tests/tests.cc index 0a4ae6cecd7020190c0e6415ae0938ba0061a481..d3db88c2f29c5c3bbb19517e4d0800f9488f4ea3 100644 --- a/modules/img/alg/tests/tests.cc +++ b/modules/img/alg/tests/tests.cc @@ -41,6 +41,7 @@ extern test_suite* CreateClearTest(); extern test_suite* CreateFFTTest(); extern test_suite* CreateNegateTest(); extern test_suite* CreateConjugateTest(); +extern test_suite* CreateNormalizerTest(); bool init_ost_img_alg_unit_tests() { try { @@ -54,6 +55,7 @@ bool init_ost_img_alg_unit_tests() { framework::master_test_suite().add(CreateClearTest()); framework::master_test_suite().add(CreateNegateTest()); framework::master_test_suite().add(CreateFFTTest()); + framework::master_test_suite().add(CreateNormalizerTest()); } catch(std::exception& e) { return false; } diff --git a/modules/io/tests/test_io_img.cc b/modules/io/tests/test_io_img.cc index 9f21257d3b942bef23e9043651bc0addf4f0232f..269228f17d960876bc8b62b244de208f61bc7496 100644 --- a/modules/io/tests/test_io_img.cc +++ b/modules/io/tests/test_io_img.cc @@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(test_io_img) //int 32 formats std::map<String,ImageFormatBase*> int32_formats; - int32_formats["IPL (16 bit)"]=new IPL(true,OST_BIT32_FORMAT); + int32_formats["IPL (32 bit)"]=new IPL(true,OST_BIT32_FORMAT); for(std::map<String,ImageFormatBase*>::iterator it=int32_formats.begin();it!=int32_formats.end();++it){ ost::io::SaveImage(testimage,fname,*(it->second)); ost::img::ImageHandle loadedimage=ost::io::LoadImage(fname,*(it->second)); @@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(test_io_img) bool failed=false; ost::img::ExtentIterator eit(scaled_image.GetExtent()); for(;!eit.AtEnd();++eit) { - if( static_cast<int>(scaled_image.GetReal(eit))!=static_cast<int>(loadedimage.GetReal(eit))){ + if( static_cast<uint>(scaled_image.GetReal(eit))!=static_cast<uint>(loadedimage.GetReal(eit))){ failed=true; break; } @@ -129,8 +129,8 @@ BOOST_AUTO_TEST_CASE(test_io_img) if(failed){ BOOST_ERROR("Image IO failed for plugin " << it->first << " at point " << ost::img::Point(eit)<< ". Should be " - << static_cast<int>(scaled_image.GetReal(eit)) << ", but " - << static_cast<int>(loadedimage.GetReal(eit)) << " found."); + << static_cast<uint>(scaled_image.GetReal(eit)) << ", but " + << static_cast<uint>(loadedimage.GetReal(eit)) << " found."); } delete it->second; } diff --git a/modules/mol/alg/src/trajectory_analysis.cc b/modules/mol/alg/src/trajectory_analysis.cc index 7f81b91d13a68edaff14e5ea2fd3a20806443192..2d0e6f32f9d5873dd16ed823c6ce4a8d01ac024f 100644 --- a/modules/mol/alg/src/trajectory_analysis.cc +++ b/modules/mol/alg/src/trajectory_analysis.cc @@ -25,10 +25,8 @@ #include <ost/geom/vec3.hh> #include <ost/base.hh> #include <ost/geom/geom.hh> -#include <ost/gfx/entity.hh> -#include <ost/mol/entity_view.hh> +#include <ost/mol/mol.hh> #include <ost/mol/view_op.hh> -#include <ost/mol/coord_group.hh> #include "trajectory_analysis.hh" namespace ost { namespace mol { namespace alg {