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

Example for usage of Image ROI (Region Of Interest)

,ImageBase

Author
MIP
/*
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
*/
#include <Base/Image/ImageBase.hh>
#include <Base/Image/ImageIO.hh>
using namespace BIAS;
using namespace std;
/**
@example ExampleROIImage.cpp
@relates ROI,ImageBase
@brief Example for usage of Image ROI (Region Of Interest)
@ingroup g_examples
@author MIP
*/
int main(int argc, char *argv[])
{
if(argc<2)
{
cout<<"loads image and embeds a roi mask."<<endl ;
return -4;
}
Image<unsigned char> img, roimg;
if(ImageIO::Load(argv[1],img)!=0)
{
cout<<"file not found "<<argv[1]<<endl;
return -8;
}
unsigned w = img.GetWidth();
unsigned h = img.GetHeight();
roimg.Init(w,h);
unsigned char** dat = roimg.GetImageDataArray();
for(unsigned y=0; y<h; y++)
{
for(unsigned x=0; x<w; x++)
{
if((x>(w/4))&&(x<((w*3)/4))&&
(y>(h/4))&&(y<((h*3)/4))
)
dat[y][x]= 0;
else
dat[y][x]= 255;
}
}
img.GetROI()->SetMaskImage(roimg);
ImageIO::Save("roimaskexample.mip",img);
return 0;
}