Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
biasrgb2luv.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #include <Base/Image/Image.hh>
26 #include <Base/Image/ImageConvert.hh>
27 #include <Base/Image/ImageIO.hh>
28 #include <Image/Camera.hh>
29 #include <Utils/IOUtils.hh>
30 #include <Utils/Param.hh>
31 #include <Base/Common/FileHandling.hh>
32 
33 using namespace std;
34 using namespace BIAS;
35 
36 
37 /**
38  @file
39  @ingroup g_tools
40  @brief convert a rgb image into float luv color space image, see biasrgb2luv.cpp
41  @author bartczak 12/2008
42  */
43 int main(int argc, char* argv[]) {
44 
45  Param params(true);
46  int fup = 0;
47  if(!IOUtils::ParseCommandLineEvalHelp(params, argc, argv, fup) || fup >= argc) {
48  cout<<"Usage:\n";
49  cout<<"\t"<<argv[0]<<" <rgb_image.###> \n";
50  cout<<"result is delivered into a float image named '<rgb_image>_LUV.mip'.\n\n";
51  return 0;
52  }
53 
54  ImageBase in;
55  if(ImageIO::Load(argv[fup], in)!=0) {
56  BIASERR("error loading input image named :"<<argv[fup]);
57  return -1;
58  }
59 
60  Image<float> out;
61  switch(in.GetStorageType()) {
62  case ImageBase::ST_unsignedchar :
63  if(ImageConvert::RGBToLUV(Image<unsigned char>(in), out)!=0) {
64  BIASERR("error converting to LUV!");
65  return -1;
66  }
67  break;
68  case ImageBase::ST_float :
69  if(ImageConvert::RGBToLUV(Image<float>(in), out)!=0) {
70  BIASERR("error converting to LUV!");
71  return -1;
72  }
73  break;
74  default:
75  BIASERR("not implemented for storage type :"<<in.GetStorageType());
76  return -1;
77  break;
78  }
79 
80 
81  out.SetMetaData(*in.GetMetaData());
82 
83  string basenameIn = FileHandling::Basename(argv[fup]);
84  //if(ImageIO::Save(basenameIn+"_LUV.mip", out)!=0) {
85  if(ImageIO::Save(basenameIn+"_LUV.mip", out)!=0) {
86  BIASERR("error saving output image named :"<<basenameIn+"_LUV.mip");
87  return -1;
88  }
89  cout<<"\ndone!\n";
90  return 0;
91 }
MetaData * GetMetaData()
Definition: ImageBase.hh:456
This class Param provides generic support for parameters.
Definition: Param.hh:231
enum EStorageType GetStorageType() const
Definition: ImageBase.hh:414
void SetMetaData(const MetaData &m)
Definition: ImageBase.hh:470
This is the base class for images in BIAS.
Definition: ImageBase.hh:102