44 #include <Base/Image/Image.hh>
45 #include <Base/Image/ImageIO.hh>
46 #include <Base/ImageUtils/ImageDraw.hh>
53 int main(
int argc,
char *argv[]) {
55 const unsigned char LO_THRESHOLD = (
unsigned char)100;
56 const unsigned char HI_THRESHOLD = (
unsigned char)230;
64 const float BLENDING_RANGE = 1.0f;
68 cout <<
"wrong parameter count!!" << endl << endl;
69 cout <<
"usage:" << endl;
70 cout << argv[0] <<
" " <<
"<normal_image> <darker_image> <brighter_image>" << endl;
78 cout <<
"normal image could not be loaded!" << endl;
82 cout <<
"normal image loaded!" << endl;
85 cout <<
"darker image could not be loaded!" << endl;
89 cout <<
"darker image loaded!" << endl;
92 cout <<
"brighter image could not be loaded!" << endl;
96 cout <<
"brighter image loaded!" << endl;
99 cout <<
"images loaded" << endl;
114 unsigned char *imDriData = imDri.GetImageData();
115 unsigned int offset = 0;
116 unsigned char mean = 0;
119 cout <<
"starting iteration..." << endl;
122 for (
unsigned int y = 0; y < imNorm.
GetHeight(); y++) {
123 for (
unsigned int x = 0; x < imNorm.
GetWidth(); x++) {
126 mean = (imNormData[offset] + imNormData[offset+1] + imNormData[offset+2]) / 3;
128 if (mean < LO_THRESHOLD) {
129 weight = ((float)(LO_THRESHOLD - mean)) / (
float)(LO_THRESHOLD);
130 weight *= BLENDING_RANGE;
131 weight = weight > 1.0f ? 1.0f : weight;
132 imDriData[offset] = (
unsigned char)(weight*(
float)imBrightData[offset] + (1.0f-weight)*(
float)imNormData[offset]);
133 imDriData[offset+1] = (
unsigned char)(weight*(
float)imBrightData[offset+1] + (1.0f-weight)*(
float)imNormData[offset+1]);
134 imDriData[offset+2] = (
unsigned char)(weight*(
float)imBrightData[offset+2] + (1.0f-weight)*(
float)imNormData[offset+2]);
136 else if (mean > HI_THRESHOLD) {
137 weight = ((float)(mean - HI_THRESHOLD)) / (
float)(255 - HI_THRESHOLD);
138 weight *= BLENDING_RANGE;
139 weight = weight > 1.0f ? 1.0f : weight;
140 imDriData[offset] = (
unsigned char)(weight*(
float)imDarkData[offset] + (1.0f-weight)*(
float)imNormData[offset]);
141 imDriData[offset+1] = (
unsigned char)(weight*(
float)imDarkData[offset+1] + (1.0f-weight)*(
float)imNormData[offset+1]);
142 imDriData[offset+2] = (
unsigned char)(weight*(
float)imDarkData[offset+2] + (1.0f-weight)*(
float)imNormData[offset+2]);
145 imDriData[offset] = imNormData[offset];
146 imDriData[offset+1] = imNormData[offset+1];
147 imDriData[offset+2] = imNormData[offset+2];
154 cout <<
"done!" << endl;
unsigned int GetWidth() const
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
color values, 3 channels, order: red,green,blue
unsigned int GetHeight() const
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
enum EColorModel GetColorModel() const
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...