25 #include "ConvertHDR.hh"
26 #include <Base/Image/ImageConvert.hh>
27 #include <Base/Debug/LogFacility.hh>
39 template<
class StorageType>
44 template<
class StorageType>
63 dst.Init(src.GetWidth(), src.GetHeight(), src.GetChannelCount(), targetST);
64 dst.SetROI(*src.GetROI());
65 if (targetST == src.GetStorageType()) {
70 dst.SetColorModel(src.GetColorModel());
72 switch (src.GetStorageType()) {
75 unsigned int values = src.GetPixelCount() * src.GetChannelCount();
76 unsigned char *d = (
unsigned char*)dst.GetImageData();
77 float *s =(
float*) src.GetImageData();
78 for (
unsigned int i=0; i<values; i++){
79 d[i] = (
unsigned char) *s;
84 #ifdef BUILD_IMAGE_USHORT
87 unsigned int values = src.GetPixelCount() * src.GetChannelCount();
88 unsigned char *d = (
unsigned char*)dst.GetImageData();
89 unsigned short int *s =(
unsigned short int*) src.GetImageData();
98 BIASWARN(
"Conversion from unsigned short int to unsigned char by cast only!!!");
99 for (
unsigned int i=0; i<values; i++)
100 d[i] = (
unsigned char) (s[i]/65535.0*255.0);
103 #endif // BUILD_IMAGE_SHORT
105 BIASERR(
"ConvertHDR() not fully implemented "<<src.GetStorageType());
121 float gamma,
unsigned int currentMaxVal){
145 float maxVal = 0, minVal=FLT_MAX, maxValTmp, minValTmp;
148 if(minValTmp < minVal){
151 if(maxValTmp > maxVal){
156 BLD(
"convertHDR - maxVal is " << maxVal <<
" highestVal is " << currentMaxVal << endl);
159 fImage.
ScaleShiftBetween(minVal/(
float)currentMaxVal, maxVal/(
float)currentMaxVal);
168 for (
unsigned int i=0; i<values; i++){
169 gammaVal = pow((*s), gamma);
170 d[i] = (
unsigned char) (gammaVal*255);
180 #define INST(type) template class ConvertHDR<type>;
184 #ifdef BUILD_IMAGE_USHORT
void Release()
reimplemented from ImageBase
(16bit) unsigned integer image storage type
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
int ScaleShiftBetween(double Min, double Max)
scales and shifts image so afterwards every pixel has a value between Min and Max ...
void SetColorModel(EColorModel Model)
void GetMinMaxPixelValue(StorageType &min, StorageType &max, unsigned short int channel=0, unsigned int *mincoo=NULL, unsigned int *maxcoo=NULL) const
returns the minimal and maximal pixel value in channel only Finds minimum and maximum pixel value in ...
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.
unsigned int GetWidth() const
ROI * GetROI()
Returns a pointer to the roi object.
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
unsigned int GetHeight() const
The image template class for specific storage types.
int SetROI(unsigned int UpperLeftX, unsigned int UpperLeftY, unsigned int LowerRightX, unsigned int LowerRightY)
deprecated, use SetROICorners()
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
enum EColorModel GetColorModel() const
int ToUnsignedChar(BIAS::Image< StorageType > &src, BIAS::Image< unsigned char > &dst)
simple conversion to unsigned char, assumed bit depth is 16 -> all pixel values are divided by 65535 ...
enum EStorageType GetStorageType() const
(8bit) unsigned char image storage type
ConvertHDR()
std Con-/Destructor
unsigned long int GetPixelCount() const
returns number of pixels in image