Skip to content
Snippets Groups Projects
Commit c59ec9e8 authored by Bienchen's avatar Bienchen
Browse files

Merge branch 'develop' into mmcifparser

parents 6ac2f443 76cdc7e7
Branches
Tags
No related merge requests found
......@@ -14,6 +14,7 @@ test_power_spectrum.cc
test_shift.cc
test_stat.cc
test_transform.cc
test_normalizer.cc
tests.cc
)
......
//------------------------------------------------------------------------------
// 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;
}
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment