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>
33 #include <Image/ConvertHDR.hh>
45 int main(
int argc,
char* argv[])
50 p->
AddParamString(
"imageList",
"List of images in Bayer pattern",
"",
'l');
52 p->
AddParamInt(
"colorDepth",
"Specify color depth (e.g. use 255 for 8 bit image)", 255);
53 if (!IOUtils::ParseCommandLineEvalHelp(*p, argc, argv)) {
62 vector<string> imageNames;
63 if (!imageListName.empty()) {
64 if (Param::ParseListFile(imageListName, imageNames) != 0) {
65 BIASERR(
"Failed to load image list file " << imageListName <<
"!");
68 cout <<
"Loaded image list file " << imageListName << endl;
70 }
else if (!imageFileName.empty()) {
71 imageNames.push_back(imageFileName);
79 if (strcmp(bayer.c_str(),
"BGGR") == 0) {
80 cout <<
"Converting Bayer pattern BGGR to RGB" << endl;
81 pattern = ImageBase::CM_Bayer_BGGR;
82 }
else if (strcmp(bayer.c_str(),
"GBRG") == 0) {
83 cout <<
"Converting Bayer pattern GBRG to RGB" << endl;
84 pattern = ImageBase::CM_Bayer_GBRG;
85 }
else if (strcmp(bayer.c_str(),
"GRBG") == 0) {
86 cout <<
"Converting Bayer pattern GRBG to RGB" << endl;
87 pattern = ImageBase::CM_Bayer_GRBG;
88 }
else if (strcmp(bayer.c_str(),
"RGGB") == 0) {
89 cout <<
"Converting Bayer pattern RGGB to RGB" << endl;
90 pattern = ImageBase::CM_Bayer_RGGB;
92 cout <<
"Unknown Bayer pattern " << bayer <<
" given!" << endl;
97 for (
unsigned int i = 0; i < imageNames.size(); i++)
99 string imageName = imageNames[i];
100 string newImageName =
"rgb_" + imageName;
102 if (ImageIO::Load(imageName, tmp) != 0) {
103 BIASERR(
"Failed to load image " << imageName <<
"!");
108 if (colorDepth > 256)
112 ImageConvert::ConvertST(tmp, hdrFloat, ImageBase::ST_float);
128 ImageConvert::ToRGB(bayerImage, rgbImage);
129 cout <<
"Converted " << imageName <<
" : " << bayerImage.GetColorModel()
130 <<
" ---> " << newImageName <<
" : " << rgbImage.
GetColorModel() << endl;
132 if (ImageIO::Save(newImageName, rgbImage) != 0) {
133 BIASERR(
"Failed to save RGB image to file " << newImageName <<
"!");
137 BIASERR(
"Bayer image " << imageName <<
" has invalid storage type "
138 "(unsigned char needed)!");
EColorModel
These are the most often used color models.
This class handles conversions of HDR images to for example unsigned char.
void SetColorModel(EColorModel Model)
int ToUnsignedCharGamma(BIAS::Image< StorageType > &src, BIAS::Image< unsigned char > &dst, float gamma, unsigned int currentMaxVal)
Conversion to unsigned char image, leaves min/max part intact.
void Usage(std::ostream &os=std::cout)
print Help-Information to stdout
std::string * GetParamString(const std::string &name) const
int * GetParamInt(const std::string &name) const
enum EColorModel GetColorModel() const
This class Param provides generic support for parameters.
invalid (not set) image format
enum EStorageType GetStorageType() const
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
void SetMetaData(const MetaData &m)
This is the base class for images in BIAS.
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)
int ParseMetaData(bool bUse2x64bitTS=true)
After ImageIO::Load() operated on AppData_, this method fills P_, Timestamp, DC_*, ...