Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TestPyramidImage.cpp

shows usage of pyramid image

Author
MIP
Date
2007
/* This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS 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 2.1 of the License, or
(at your option) any later version.
BIAS 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 BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**
* @example TestPyramidImage.cpp
* @relates PyramidImage
* @brief shows usage of pyramid image
* @author MIP
* @date 2007
*/
#include <Image/PyramidImage.hh>
using namespace BIAS;
using namespace std;
void TestInit()
{
const unsigned width = 640, height = 480, channelcount=3, size = 2;
Image<unsigned char> im(width, height, channelcount);
ImageBase imb(im);
if (!pim.IsEmpty()) { BIASABORT; }
pim.Init(size);
if (!(pim.Size()==size)) { BIASABORT; }
if (pim.Size()>0 && !pim[0]->IsEmpty()) { BIASABORT; }
pim.Clear();
if (!pim.IsEmpty()) { BIASABORT; }
pim.Init(width, height, channelcount, size);
if (!(pim.Size()==size)) { BIASABORT; }
if ((pim.Size()>0) && (pim[0]->GetWidth()!=width)) { BIASABORT; }
if ((pim.Size()>0) && (pim[0]->GetChannelCount()!=channelcount)) { BIASABORT; }
pim.Clear();
if (!pim.IsEmpty()) { BIASABORT; }
pim.Init(im, size);
if (!(pim.Size()==size)) { BIASABORT; }
if ((pim.Size()>0) && (pim[0]->GetWidth()!=width)) { BIASABORT; }
if ((pim.Size()>0) && (pim[0]->GetChannelCount()!=channelcount)) { BIASABORT; }
if ((pim.Size()>1) && pim[1]->IsEmpty()) { BIASABORT; }
pim.InitFromImageBase(imb, size);
if (!(pim.Size()==size)) { BIASABORT; }
if ((pim.Size()>0) && (pim[0]->GetWidth()!=width)) { BIASABORT; }
if ((pim.Size()>0) && (pim[0]->GetChannelCount()!=channelcount)) { BIASABORT; }
if ((pim.Size()>1) && pim[1]->IsEmpty()) { BIASABORT; }
if (!(pim2.Size()==size)) { BIASABORT; }
if ((pim2.Size()>0) && (pim2[0]->GetWidth()!=width)) { BIASABORT; }
if ((pim2.Size()>0) && (pim2[0]->GetChannelCount()!=channelcount)) { BIASABORT; }
if ((pim2.Size()>1) && pim2[1]->IsEmpty()) { BIASABORT; }
}
void TestCopy()
{
const unsigned width = 640, height = 480, channelcount=3, size = 2;
if (!pim.IsEmpty()) { BIASABORT; }
pim.Init(width, height, channelcount, size);
if (!(pim2.Size()==size)) { BIASABORT; }
if ((pim2.Size()>0) && (pim2[0]->GetWidth()!=width)) { BIASABORT; }
if ((pim2.Size()>0) && (pim2[0]->GetChannelCount()!=channelcount)) { BIASABORT; }
if ((pim2.Size()>1) && pim2[1]->IsEmpty()) { BIASABORT; }
if (!(pim3.Size()==size)) { BIASABORT; }
if ((pim3.Size()>0) && (pim3[0]->GetWidth()!=width)) { BIASABORT; }
if ((pim3.Size()>0) && (pim3[0]->GetChannelCount()!=channelcount)) { BIASABORT; }
if ((pim3.Size()>1) && pim3[1]->IsEmpty()) { BIASABORT; }
if (RefCount(pim3[0])!=1) { BIASABORT; }
pim2.ShallowCopy(pim);
if (!(pim2.Size()==size)) { BIASABORT; }
if ((pim2.Size()>0) && (pim2[0]->GetWidth()!=width)) { BIASABORT; }
if ((pim2.Size()>0) && (pim2[0]->GetChannelCount()!=channelcount)) { BIASABORT; }
if ((pim2.Size()>1) && pim2[1]->IsEmpty()) { BIASABORT; }
if (RefCount(pim2[0])!=2) { BIASABORT; }
}
void TestResize()
{
const unsigned width = 640, height = 480, channelcount=3, size = 2;
Image<unsigned char> im(width, height, channelcount);
if (!pim.IsEmpty()) { BIASABORT; }
pim.Init(width, height, channelcount, size);
pim.resize(3);
if (!pim[2]) { BIASABORT; }
if (!pim[2]->IsEmpty()) { BIASABORT; }
pim.Downsample();
if (pim[2]->IsEmpty()) { BIASABORT; }
// the following should creat a total of 5 levels when th ebiggest image
// has size 640x480
pim.CreateAdditionalLayer(2u, 32);
if (pim.Size()!=5u) { BIASABORT; }
}
int main(int argc, char *argv[])
{
TestInit();
TestCopy();
TestResize();
return 0;
}